Hey Steve you can use the exec() function ie;
declare @qryStr varchar(8000) set @qryStr = "select * from myTable where 1=1" if(datalength(@myParam)>0) set @qryStr = @qryStr + " and mycol in (@myParam)" exec(@qryStr) etc ... OR if you just need to check whether a variable exists or not use something like this select * from myTable where 1=1 and myColumn in (coalesce(@myParam, myColumn)) The coalesce function will use the first non null expression. hth Rod > Hey guys > > I am having to convert some large queries into stored proceedures but i > cant seem to work out how to do IF...ELSE inside the query in SQL. Im > using MSSQL 2000 > > According to the docs you cant put the IF...ELSE inside the query, rather > the whole query goes inside the IF...ELSE conditions. > > Is this right? or am i missing something > > Steve > > --- > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] > To unsubscribe send a blank email to > [EMAIL PROTECTED] > Aussie Macromedia Developers: http://lists.daemon.com.au/ > --- You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
