where caluse help please.

  • Hi,

    Sorry this has been posted twice. The Moderator can delete one .

    Can some one tell me how I can pass a integer value to where clause in a stord procedure.

    For Example

    __________

    ALTER PROCEDURE sp_Sample

    (

    @Empid nvarchar(100)

    )

    AS

    Declare @STR varchar(1000)

    Begin

    set @STR = 'SELECT * from Employee WHERE empid=' + @Empid

    Exec (@str)

    end

    Go

    now when executing i want to get the empid to be like select * from employee where empid= 'A1234'

    instead where am getting like empid = A1234

    How can i get the single qoute there while executing....

    Thanks,

  • you have to add the simple quotes to the string

    so, the string changes to:

    set @STR = 'SELECT * from Employee WHERE empid=''' + @Empid + ''''

    the quotes are escaped

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply