Stored prosedur Set Value Column

  • Hi member ,

    My problem Stored prosedur Comments RATES1 Set Value @kur how do I..?

    CREATE PROCEDURE DvzkuruCek

    AS

    BEGIN

    DECLARE

    @T1 DATETIME = '02.02.2015',

    @kur INT

    ----- RATES1 VALUES @kur set value how do I ?

    SET @kur =(SELECT RATES1 FROM dbo.L_DAILYEXCHANGES WHERE EDATE= @T1 AND CRTYPE =1 );

    PRINT @kur

    END

    Best Regards

  • Try rewriting it to:

    SELECT @kur = RATES1 FROM dbo.L_DAILYEXCHANGES WHERE EDATE= @T1 AND CRTYPE =1;

    But, it's only going to work if that only returns a single value. If it returns multiple rows, it won't work.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • CREATE PROCEDURE DvzkuruCek

    @T1 DATETIME = '20150202' --'YYYYMMDD' is always interpreted correctly

    AS

    SET NOCOUNT ON;

    DECLARE

    @kur INT;

    SELECT TOP (1) @kur = RATES1

    FROM dbo.L_DAILYEXCHANGES

    WHERE EDATE= @T1 AND CRTYPE =1

    ORDER BY EDATE DESC --get the last rate for that day, if multiple

    --SELECT @kur;

    GO --end of proc

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

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

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