Wednesday, 25 January 2012

Nodejs Tedious Sql Server Driver and GUID / UNIQUEIDENTIFIER

So you're using SQL Server / SQLEXPRESS with nodejs for some odd reason, and you're trying to pull back Ids from a table that is has the field declared as UNIQUEIDENTIFIER, but you keeping getting an error like :

Unrecognised data type 0x24 at offset 0x0009

But its OK when you pull back nvarchar's etc.

Nasty hack that works (considering js doesn't know what a GUID is anyway) :
Change :

select Id from table
to:
select convert(varchar(38) , Id) from table

and all is well.

No comments:

Post a Comment