CREATE proc dfjk @int_max varchar output
as
DECLARE @sql varchar(300) -- 定义变量 @sql
set @sql='select max(no) into'+@int_max+' from test' --变量赋值
--set @sql='select * from test' 注释了
--set @int_max='true' 注释了
exec(@sql)  --执行 @sql 中的 SQL 语句
set @sql=@int_max --变量赋值
print(@sql)   --输出 @sql上面'--'之后的是注释.
SQL语句: select max(no) into'+ @int_max+' from test
将表 test 中 no 列 的最大值赋给变量 @int_max