ISPrincess
Programmer
I am having problems with placemen t of quotation marks when attempting to build a sql statement in stored proc.
At least I think that is my problem.
declare @sql varchar(2000)
declare @fulldbname varchar(50)
declare @intTheID integer
set @fulldbname = 'ServerA.DB1.dbo.Tablename'
set @intTheID = 183254219
set @sql = 'select top 100 * from ' + @fulldbname + ' where TheID = "' + @intTheID + '"'
on exec i get the following error:
Syntax error converting the varchar value 'select top 100 * from 'ServerA.DB1.dbo.Tablename where TheID = "' to a column of data type int.
I know the variable fulldbname is working because I can execute without the 'Where' clause.
Quotation mark help would be Extremely appreciated.
Thank you!
PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips
At least I think that is my problem.
declare @sql varchar(2000)
declare @fulldbname varchar(50)
declare @intTheID integer
set @fulldbname = 'ServerA.DB1.dbo.Tablename'
set @intTheID = 183254219
set @sql = 'select top 100 * from ' + @fulldbname + ' where TheID = "' + @intTheID + '"'
on exec i get the following error:
Syntax error converting the varchar value 'select top 100 * from 'ServerA.DB1.dbo.Tablename where TheID = "' to a column of data type int.
I know the variable fulldbname is working because I can execute without the 'Where' clause.
Quotation mark help would be Extremely appreciated.
Thank you!
PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips