Giving values to multible Varibles with SET and SELECT

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Metalzed
    New Member
    • Sep 2006
    • 27

    Giving values to multible Varibles with SET and SELECT

    Hi my problem is real simple. I want to give 2 Varibles values from one SELECT query

    Here a exampel.

    Code:
    DECLARE @test1 int , @test2 int;
    
    SET @test1=SELECT a FROM Table_T
    SET @test2=SELECT b FROM Table_T
    I dont want to use 2 diffrent selects is there any way to do something like this
    Code:
    DECLARE @test1 int , @test2 int;
    
    SET @test1 , @test2=SELECT a , b FROM Table_T
    The , doesn't work but you get the idea.
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Try this:

    [PHP]

    DECLARE @test1 int , @test2 int;

    SELECT @test1 = a, @test2 = b FROM Table_T[/PHP]

    Comment

    • Metalzed
      New Member
      • Sep 2006
      • 27

      #3
      Thanks.. Worked perfekt.

      Comment

      Working...