SQL SERVER存储过程中能不能以字段名作为参数,比如输入一个参数✀A,B,C✀,然后返回A,B,C这几列的数据

2025-04-24 18:11:29
推荐回答(3个)
回答1:

参数名必须是以@开头的,不可能用字段名做为参数。 你要查看a,b,c这几列的数据直接 select a,b,c from table 就是了 何必要用个存储过程呢?

回答2:

存储过程使用exec
create proc stat
@par1 as varchar(10),
@par2 as varchar(10)
as
begin
select 1 ,2
exec('select 1 as '+@par1+',2 as '+@par2 )
end
测试
stat s1,s2

回答3:

你了解存储过程吗