SQL Server SELECT INTO @variable?

前端 未结 7 1500
走了就别回头了
走了就别回头了 2020-12-02 03:56

I have the following code in one of my Sql (2008) Stored Procs which executes perfectly fine:

    CREATE PROCEDURE [dbo].[Item_AddItem]
        @CustomerId u         


        
7条回答
  •  再見小時候
    2020-12-02 04:27

    If you wanted to simply assign some variables for later use, you can do them in one shot with something along these lines:

    declare @var1 int,@var2 int,@var3 int;
    
    select 
        @var1 = field1,
        @var2 = field2,
        @var3 = field3
    from
        table
    where
        condition
    

    If that's the type of thing you're after

提交回复
热议问题