when I run:
declare @guid uniqueidentifier
set @guid='{17D679DD-DB5E-41F9-9CCA-915A56624A32}'
exec('select * from profile where guid=' + @guid)
I get the message:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'D679DD'.
when I run:
declare @guid uniqueidentifier
set @guid='{17D679DD-DB5E-41F9-9CCA-915A56624A32}'
exec('select * from profile where guid=' + cast(@guid as varchar(255)))
I get the message:
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near 'cast'.
Just what are the rules for using uniqueidentifiers in tsql.
I want to use exec because I want the database name to be a parameter.
declare @guid uniqueidentifier
set @guid='{17D679DD-DB5E-41F9-9CCA-915A56624A32}'
exec('select * from profile where guid=' + @guid)
I get the message:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'D679DD'.
when I run:
declare @guid uniqueidentifier
set @guid='{17D679DD-DB5E-41F9-9CCA-915A56624A32}'
exec('select * from profile where guid=' + cast(@guid as varchar(255)))
I get the message:
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near 'cast'.
Just what are the rules for using uniqueidentifiers in tsql.
I want to use exec because I want the database name to be a parameter.