Home > database > Defines the variables and execute the stored procedure is said is not defined variables
Defines the variables and execute the stored procedure is said is not defined variables
Time:09-17
Create procedure test_p @ ipAddress1 varchar (20) output, @ ipAddress2 varchar (20) the output As The begin Declare @ a1 varchar (1000) Declare @ I int The set @ I=1 While @ i<=2 The begin Set @ a1='set @ ipAddress' + convert (varchar (30), @ I) + '=' "+ left (dbo. GetSplitOfIndex (' 162.168.0.1, 192.168.0.2 ', ', '@ I), 20) +"' "' Print @ a1 The exec (@ a1) The set @ I=@ I + 1 End End
The function of the stored procedure: loop will string 162.168.0.1 and 162.168.0.2 were assigned to two output variables @ ipAddress1, @ ipAddress2. But after the operation is prompt did not declare a variable, as shown:
CodePudding user response:
You define variables of the statement also spliced into, such as the following, one question before you not have any similar operations
The set @ a1='DECLARE @ IPADDRESS VARCHAR (100) The set @ ipAddress '+ convert (varchar (30), @ I) +'=' ' '+ left (dbo. GetSplitOfIndex (' 162.168.0.1, 192.168.0.2', ', '@ I), 20) +' "'