prathibha_aviator (1/22/2013)
SET @OrgName = N'SELECT ORG_ID ' + CONVERT(varchar(10), @orgid) +' '+ '[Description]' + ' ' +'('+ CONVERT(varchar(20),+ 'pol_id)'+')'+ 'from'+ @dbname + '.dbo.Organization'+ 'where OrganizationID =' + @orgid;
Above is the dynamic i wrote in my Sql mgmt studio and i ran it to get the following error. Actually this script is a part of my program that uses cursors concept
Error:
Msg 102, Level 15, State 1, Line 53
Incorrect syntax near ';'.
I haven't actually tried this in SSMS so my answer may be off. The first thing I would try is to convert the @orgid at the end to a varchar as was done earlier. There may be a problem concatenating it at the end of the string without converting.
Good luck!