Skip to main content

Posts

Showing posts with the label SQL Server 2000

Python Turtle and Links

I just discovered the Turtle graphics module for Python 2.5 using the Tk graphics library. It is very "kid friendly", and it sets up a screen when you make your first function call. This was very fun, just like when I first played with LOGO on my Commodore 64! >>> from turtle import * >>> clear() >>> down() >>> goto(66,66) >>> for step in range(24): ... right(105) ... forward(100) ... >>> up() >>> goto(0,0) >>> color("red") >>> write("Done!") >>> exit() Seen on the Web in August 2008 Iron Python on ASP.Net http://ironpythonresource.com/post/2008/08/03/Beginning-IronPython-Creating-a-basic-ASPNET-Form-(Part-1).aspx Connecting to a database http://ironpythonresource.com/post/2008/08/09/Connecting-to-a-database-and-using-the-gridview.aspx Creating a class http://ironpythonresource.com/post/2008/08/10/Beginning-IronPython-Creating-a-class.aspx Creating an updat...

My take on Enums in SQL Server

I am a registered user on SQL Server Central , and I read a good article there on " Enums in SQL Server ". I thought that I would quickly present my own humble solution to this problem, although I do not mean to imply that my way is better - you can decide for yourself. First, the problem to be solved is to represent a limited set of choices, where new choices would typically require a developer's intervention to implement the business logic. An example would be a list of task priorities in a to-do list. CREATE TABLE Priorities( ID tinyint not null identity(1,1) PRIMARY KEY, Code char(3) not null unique, Priority varchar(20) not null ) ; INSERT INTO Priorities (Code, Priority) VALUES ('911', 'Emergency') ; INSERT INTO Priorities (Code, Priority) VALUES ('HIG', 'High') ; INSERT INTO Priorities (Code, Priority) VALUES ('NOR', 'Normal') ; INSERT INTO Priorities (Code, Priority) VALUES ('LOW', 'Low') ; IN...

Auditing a SQL Server database

I do not believe that I have covered this before, but the Active Record Code Generator can also generate audit records for your database tables. The template that I wrote ( SqlAuditTrigger.vm ) adds records to an AuditChanges table, with a related AuditFields table containing the table and field name. I think that this is a fairly compact solution, but I also added code to the trigger to ignore SA (system administrator) changes. This may not be appropriate for your application, but it is easily removed. I also have a "TODO" item to detect related lookup tables (really ENUMs) and translate IDs to Names, so that changes to the FavoriteColor_ID field would look at the FavoriteColor table, and instead of recording FavoriteColor_ID changed from 2 to 5, it would say changed from "Ruby Red" to "Passionate Purple". The reason that I did not actually implement it is that I do not have enough information. My code generation schema does not list all of the f...

Table Functions in SQL Server 2000 and up

I recently added a customer tagging feature to our billing system. Users needed to be able to see a list of associated tags in their reports, so I needed to be able to collect all tags for a customer into a single string. Below is a rough approximation of the table schema. I did some research, and ended up creating a user-defined function (UDF) that returns a TABLE variable. Inside the UFD, I used a table variable, a cursor (which I wanted to avoid) and ran a query with the COALESCE() function for each customer. I was able to use my UDF as if it were a temporary table in my reports. Otherwise, I would have had to duplicate this code for each report. Before accepting this solution, I tried various flavors of selecting, updating, etc. but I couldn't find a solution without using a cursor. The code below is an untested generic adaptation of my working solution. TABLE: Customers Customer_ID INTEGER, CustomerName VARCHAR(50) TABLE: Membership Member_ID INTEGER, ...