> I just want to convert nvarchar(wich represent column name) to column name in my WHERE statement.
.... and in order to do that you need to use dynamic SQL. See
"Hrvoje" <hrvoje.voda2@zg.htnet.hr> wrote in message news:f0jbi4$4sq$1@ss408.t-com.hr...
>I don't get anything with this code.
> I just want to convert nvarchar(wich represent column name) to column name in my WHERE statement.
>
> "Klas Klättermus" <2007@kolben.se> wrote in message news:uzm5iNehHHA.4600@TK2MSFTNGP05.phx.gbl...
>> DECLARE @column nvarchar(32);
>> DECLARE @sqlstmt nvarchar(256);
>>
>> EXEC sp_executesql @stmt=N'SELECT * FROM Users WHERE ' + @column + ' LIKE ...';
>>
>> However avoid sp_executesql if you can. Even temporary tables are a better solution.
>>
http://msdn2.microsoft.com/en-us/library/aa933299(SQL.80).aspx
>>
>>
>> "Hrvoje" <hrvoje.voda2@zg.htnet.hr> skrev i meddelandet news:f0j2k7$g5$1@ss408.t-com.hr...
>>> How to declare variable to define it as a column?
>>>
>>> declare @Column AS (what should be here?)
>>>
>>> AS
>>>
>>> SELECT * FROM Users
>>> WHERE @Column like....
>>>
>>> Hrcko
>>>
>>
>>
>
>