SQL: Dynamic Variable Names

后端 未结 3 746
闹比i
闹比i 2021-01-07 01:34

I am attempting to set variables whose names are dynamic in a stored procedure:

DECLARE @var01 varchar(50)  
DECLARE @var02 varchar(50) 
...
DECLARE @var30 v         


        
3条回答
  •  感情败类
    2021-01-07 01:51

    You can also use stored procedure sp_executesql which allows passing parameters. Although I recommend to use additional table to store variables.

提交回复
热议问题