Select + variables from table by batch script

  • I need some helps.

    I need to put a result on a variable from a table but as this table is linked to a user inside a stored proc, I need to pass by batch script.

    here the original script :

    declare @aom_rate char(30)

    declare @aom_ccy_cts char(2)

    declare @aom_ccy char(3)

    DECLARE @cmd nvarchar(2000)

    DECLARE @cmd1 nvarchar(2000)

    DECLARE @current_user nvarchar(10)

    SET @current_user = RTRIM(LTRIM(user_name()))

    set @aom_ccy = 'AUD'

    SELECT @aom_rate = gccy.HCR_BMIDDLE, @aom_ccy_cts = gccy.HCR_CCY_CTS

    FROM @current_user.AO_InqCst_TEMPCCY AS gccy

    here what I'd like to have : ( something like that )

    set @cmd1 = "declare @aom_rate char(30), @aom_ccy_cts char(2) "

    set @cmd = "SELECT " + @aom_rate + "= gccy.HCR_BMIDDLE, " + @aom_ccy_cts + " = gccy.HCR_CCY_CTS FROM [" + @current_user + "].[AO_InqCst_TEMPCCY] AS gccy WHERE gccy.HCR_CODE = " -- + "'" + @aom_ccy + "'"

    set @cmd1 = @cmd1 + @cmd + "'" + @aom_ccy + "'"

    EXECUTE (@cmd1)

    the goal is to get variable '@aom_rate' and '@aom_ccy_cts' with a result.

    Please some help will be appreciated

    thanks in advance

    Edited by - freewarefw on 06/26/2003 08:53:29 AM

  • 
    
    set @cmd = "SELECT @aom_rate = gccy.HCR_BMIDDLE, @aom_ccy_cts = gccy.HCR_CCY_CTS FROM [" + @current_user + "].[AO_InqCst_TEMPCCY] AS gccy WHERE gccy.HCR_CODE = '" + @aom_ccy + "'"
    exec sp_executesql @cmd,N'@aom_rate char(30) output, @aom_ccy_cts char(2) output',@aom_rate output,@aom_ccy_cts output

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Thanks for your help!

    freewarefw

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

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