SQL Server SELECT INTO @variable?

前端 未结 7 1448
走了就别回头了
走了就别回头了 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:47

    you can do this:

    SELECT 
        CustomerId, 
        FirstName, 
        LastName, 
        Email
    INTO #tempCustomer 
    FROM 
        Customer
    WHERE 
        CustomerId = @CustomerId
    

    then later

    SELECT CustomerId FROM #tempCustomer
    

    you doesn't need to declare the structure of #tempCustomer

    0 讨论(0)
提交回复
热议问题