Stored procedure calling another procedure

  • Hi there,

    I can't find a way to use a parameter in quotes being passed to another stored procedure.

    The error always occurs in the where-part of the subquery.

    How could I pass the parameter so that it will be accepted?

    (side note: the stored procedure being called can be found here at sql server central - it's used for paging recordsets and it works like a charm!)

    Thank you in advance!

    Sascha

    This is my code:

    -----------------------------------

    CREATE PROCEDURE page_BTC_DE

    (@Page int,

    @NumRows int)

    AS

    BEGIN

    EXEC spGetDataPage 'products','ID, BI_number_BTC, European_product_number_new, Product_name_Supplier, Product_Name_german,

    Product_name_english, Area_of_Application,

    Use_Code, status',

    'status = " " OR ((status = "C" OR status = "P") AND (Anmelder IN (SELECT username FROM BTC_member WHERE BTC = "BTC_DE")))',

    null,

    'status DESC',

    @Page,

    @NumRows

    END

    GO

  • (1) You have to use single quotes in T-SQL.
    (2) To escape the single quotes you would  need another quote.
    Try this :
     
    EXEC spGetDataPage 'products',

     'ID, BI_number_BTC, European_product_number_new, Product_name_Supplier, Product_Name_german,

    Product_name_english, Area_of_Application, Use_Code, status',

    'status = '''' OR ((status = ''C'' OR status = ''P'') AND (Anmelder IN (SELECT username FROM BTC_member WHERE BTC = ''BTC_DE'')))',

    null,

    'status DESC',

    @Page,

    @NumRows

    ******************
    Dinakar Nethi
    Life is short. Enjoy it.
    ******************

  • or you can use

     

    set quoted_identifier off

     

    with this setting you can mix'n'match both single and double quotes.

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

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

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