Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

How can we write a dynamic where condition in sql which will change according to certain variable like

$
0
0

How can we write a dynamic where condition in sql which will change according to certain variable like

if @changestatus=0

Select * from  table where status=0 and name is 'vivek_kumar9'

if @changestatus=1


Select * from  table where status=1 and name is 'vivek_kumar'

I want to write a single query which will change vased on variable value..


Viewing all articles
Browse latest Browse all 4729