|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Msg 402 aad uniqueidentifier to stringHi,
I get this message: The data types nvarchar and uniqueidentifier are incompatible in the add operator. I need to add an uniqueidentifier, this is what I have now: [UserId] = ' + @UserId + ' @UserId is the uniqueidentifier. How do I add this parameter? Thanks! Arjen You can use cast or convert functions:
select UserID + cast(@UserID as varchar(36) from..... or select UserID + convert(varchar(36), @userID) from.... Adi Arjen wrote: Show quote > Hi, > > I get this message: > The data types nvarchar and uniqueidentifier are incompatible in the add > operator. > > I need to add an uniqueidentifier, this is what I have now: > [UserId] = ' + @UserId + ' > > @UserId is the uniqueidentifier. > > How do I add this parameter? > > Thanks! > Arjen Better yet (IMHO) - explain what you actually need, rather that posting a
fragment of what seems to by dynamic SQL. Perhaps you should read this fine article on dynamic SQL by Erland Sommarskog: http://www.sommarskog.se/dynamic_sql.html Clue: "sp_executesql". ML --- http://milambda.blogspot.com/ |
|||||||||||||||||||||||