I am new to MSSQL. i need to change the condition in select statement where based same on the Condition.
I try to store the where clause Conditions in One variable and assign that variable in into the select statement where clause.
Like This..
declare @test varchar(max);
declare @test1 varchar(max);
set @test=' id = 14';
select FirstName from tblUser where @test;
But it so some error.
Like:
Msg 4145, Level 15, State 1, Line 4
An expression of non-boolean type specified in a context where a condition is expected, near ';'.
Please tell me any other way implement this flow…
Thanks…
You can do it using dynamic SQL. For more information see link from Obed’s answer