Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
Declare @ColId uniqueidentifier

set @ColId = '1B233EE7-1668-4D03-995F-2D763BF03F06'

EXEC('update custom.location
    set siteid =' + @ColId +
    'where siteid is null')



when execute above sql query get below error-
Incorrect syntax near 'B233EE7'.

Any one can help?
Posted
Comments
CHill60 20-Jun-14 17:51pm    
How have you defined the column "siteid"? uniqueidentifier also or nvarchar?

For what you're doing, wouldn't it make sense to declare @ColID a varchar?

If not, you may wish to cast it to one.

Also, any reason you don't just build the query simply as:
SQL
update custom.location set siteid=@ColId where siteid is null
 
Share this answer
 
v2
If this is microsoft SQL server it should be custom..location or custom.dbo.location. Syntax is database.owner.tablename....otherwise the first solution of defining the value as a varchar will work
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900