Pardeep, Try reading the "Books Online" that comes with SQL Server...there are examples of conditional processing.
I'm not sure you can do the IsDefined()....but you can work around that by simply passing in a blank value....and if blank...do not run that part of the SQL statement. Cheers Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: [EMAIL PROTECTED] web: www.electricedgesystems.com ----- Original Message ----- From: "Pardeep Singh" <[EMAIL PROTECTED]> To: "SQL" <[email protected]> Sent: Tuesday, February 22, 2005 1:04 PM Subject: Re: How 2 convert cfquery to TSQL (MS SQL stored proc) > Thanks for all your feedback, but its still not solving this key problem > which is how to convert the following code into TSQL. > _____________________________________________________________ > > select * > from profiles > where 0=0 > <cfif isdefined('form.firstname') and form.firstname neq ''> > and form.firstname='#form.firstname#' > </cfif> > _____________________________________________________________ > > Perhaps someone has a clean way of adding an IF statement to TSQL, i.e. > > ____________________________________________ > > @firstname (varchar 200)=null > > select * > from profiles > where 0=0 > IF @firstname is not null > and [EMAIL PROTECTED] > > ____________________________________________ > > It is only the if statement part that seems difficult to replicate. > > I know we can check to make sure a variable is not null. > > But I don't know how to check to see if it even exists. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:6:2148 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/6 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
