Variables scope which are defined within a while block in stored procedures - SQl Server

后端 未结 8 875
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 07:46

I\'ve come across a interesting scenario (at least for me) in a stored procedure. Would like to have experts opinion and thoughts on it.

DECLARE @loopcounter         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 08:12

    In T-SQL a WHILE..END is not individually scoped, you can for example SELECT @insidevalue after the WHILE's END.

提交回复
热议问题