T-SQL sql server 2005

  • hello (Urgent),

    There is any possibility is there in stored procedure to send query with parameter like this.

    This is my parameter:

    here I pass this paremeter with C# code.

    Parameter =Where studentname='giri'

    I wrote stored procedure like this..............

    create procedure proc_name(@parameter varchar(200))

    as

    select * from employee @paramerter.

    go,

    run:

    execute porc_name 'parameter'

    GO

    But I impliment it got error.

    Thanks
    Dastagiri.D

  • select * from employee

    where = @paramerter

  • you could try making you stored proc use dynamic sql.

    create procedure proc_name(@parameter varchar(200))

    as

    declare @sql nvarchar(max)

    set @sql = 'select * from employee '+ @parameter

    exec sp_executesql @sql

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]

  • I think the proposed solution will work.

    You're fortunate that a good SQL Scripter was reading the "backups" forum, because that might not always be the case.

    You'd have had a more certain chance of getting the help you need by posting in the correct forum.

    No worries, just trying to keep it all consistent.

    Cheers and happy Friday

    ~SQLBOT

  • I didn't even Realize this was the backup section 🙂

    Bob
    -----------------------------------------------------------------------------
    How to post to get the best help[/url]

  • hi..

    Robert klimes,

    I tried your answer.Its working fine.I am very happy of this.

    Thank you,

    Dastagiri.D

    Thanks
    Dastagiri.D

  • Hi,

    sorry for the sending in backup forums.

    Thank you,

    Dastagiri.D

    Thanks
    Dastagiri.D

Viewing 7 posts - 1 through 6 (of 6 total)

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