SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,361 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have the following code
SET @sqlCommand = '
select
*
from
#temptable
where
SALES_OFFICE not in
(SELECT [SalesOfficeCode] from ' + (SELECT schema_name FROM #schema WHERE ROWNUMBER = @Init)
+ '.[DimSalesOffice]) and sales_division = ' + (SELECT schema_name FROM #schema WHERE ROWNUMBER = @Init)
However I am receiving the error
Invalid column name
The error seems to be related to the last part when is doing the comparison
sales_division = ' + (SELECT schema_name FROM #schema WHERE ROWNUMBER = @Init)
The part above that pulls the row value fine? Any ideas?
Print our your sql string.
My guess is this:
and sales_division = ''' + (SELECT schema_name FROM #schema WHERE ROWNUMBER = @Init)+''''
Found the answer .. needed to add a few more quoates
sales_division = ''' + (SELECT schema_name FROM #schema WHERE ROWNUMBER = @Init)+''''