Speaking in Code

Tuesday, February 10, 2009

Coding resource

I have heard tell that this is an invaluable resource for coding questions of all sorts.

I do know it is run (sponsored?) by a guy named Joel Spolsky who DEFINITELY has developers in mind when he does things.
See his post on how he designed his new office space in NYC.

Labels: , ,

Wednesday, February 04, 2009

Using Identity Insert

When copying data from one database to another, in a table with an IDENTITY column, you want to keep the values for the IDENTITY column. Set IDENTITY_INSERT ON for the table being inserted into.

SET IDENTITY_INSERT dbo.Client ON
INSERT INTO dbo.CLIENT (ClientID, ClientName) VALUES (782, 'Edgewood Solutions')
INSERT INTO dbo.CLIENT (ClientID, ClientName) VALUES (783, 'Microsoft')
SET IDENTITY_INSERT dbo.Client OFF

Monday, February 02, 2009

How to Convert Image to VarChar(Max)

You can use the CAST to convert the image column to varbinary, binary or timestamp. From those you can convert to nvarchar. You can read only the binary values stored in the image column.

SELECT CAST(CAST (urImageColumn AS varbinary) AS varchar(max)) FROM urTble

(this answer was found in Expert's Exchange)

The VarChar(Max) field will contain binary data. If I find a way to convert it to readable text, I'll update this post.