jimspicer
08-21-2011, 04:10 AM
Hi,
We are using common table structures with different names so Dynamic SQL may work for us. But I am having a problem with this query:
DECLARE @SQL nvarchar(4000)
SET @SQL = 'SELECT UsersData_ID FROM ' + @Tablename + ' WHERE Users = ' + @UserName
exec sp_executeSql @SQL
The @UserName column contains email addresses. When I run this query I get this error...
The multi-part identifier "jim@perpetualbudget.com" could not be bound.
or I get this error...
Invalid column name 'jim@spicer'
It seems the query engine doesn't like the @ sign but what can I do about it? All of our other dynamic SQL queries are working. Thanks for any help, Jim Spicer
We are using common table structures with different names so Dynamic SQL may work for us. But I am having a problem with this query:
DECLARE @SQL nvarchar(4000)
SET @SQL = 'SELECT UsersData_ID FROM ' + @Tablename + ' WHERE Users = ' + @UserName
exec sp_executeSql @SQL
The @UserName column contains email addresses. When I run this query I get this error...
The multi-part identifier "jim@perpetualbudget.com" could not be bound.
or I get this error...
Invalid column name 'jim@spicer'
It seems the query engine doesn't like the @ sign but what can I do about it? All of our other dynamic SQL queries are working. Thanks for any help, Jim Spicer