Because I'm using dynamic variables to read linkedservers (excel files) I need to put my SQL statements into an executable string.
I've simplified my statements and included a SQL table, but get the same error on my @records Can anyone see what I'm doing wrong?
-- When I change it to the following: DECLARE @V_SQL NVARCHAR(1000) declare @records int
SET @V_SQL = 'SELECT ' + @records + ' = count(*) FROM MyTable WHERE page1id IS NULL'; EXEC (@V_SQL);
-- Returns this error: Conversion failed when converting the varchar value 'SELECT ' to data type int.
asked Jul 13 '10 at 08:05 AM in Default
Tim 3 1
answered Jul 13 '10 at 10:58 AM