SET VALUES INTO TWO VARIABLES USING QUERY

  • hi

    i want to set values into two variables in a sp using select query.

    ex:

    create proc test

    as

    begin

    set nocount on

    declare @var1 varchar(50),@var2 varchar(50)

    select @var1,@var2=col1,col2 from tab;

    print @var1

    print @var2

    end

    i am getting error to set the values in variables. is the above query was correct.

    or i need to use two seperate set statements.

    thanks

    RocK..

  • select @var1 = col1,

    @var2=col2

    from tab

    BrainDonor

  • Thanks a lot BrainDonor.

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

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