Results 1 to 2 of 2

Thread: how

  1. #1
    Join Date
    Dec 1969

    Default how

    can i write sql statement like the following.....<BR>DECLARE @condition varchar<BR>SET @condition="pno=1"<BR>SELECT * FROM XTABLE WHERE @condition<BR><BR>ie. can i use a local variable to specify entire condition in where clause?

  2. #2
    Join Date
    Dec 1969

    Default RE: how

    Sure you can, but there are some disadvantages: the stored proc won&#039;t be able to use an execution plan, and consequently the performance will be less...<BR><BR>This is how:<BR><BR>DECLARE @condition varchar(200)<BR>SET @condition = "pno=1"<BR>EXECUTE("SELECT * FROM XTABLE WHERE " + @condition)<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts