Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 alternatives

Author  Topic 

karamjeet2004
Starting Member

1 Post

Posted - 2014-02-04 : 07:07:33
any alternative to this query, i dont want to use temp tables.

select * from (

if(@i=1)
select query
else
select query

)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-04 : 07:25:56
just this is enough

select query
where @i=1
union all
select query
where @i<>1



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -