求一个存储过程,大家看看给个答案
要求传递2个参数
1、msg= "短信测试 "
2、sql= "select mb from user where sf= '上海 ' "
根据上面2个参数,将mb查询后,写入到sms表
sms表结构:
id mb msg
------解决方案--------------------create proc up_t1(@msg varchar(20))
as
insert into sms(mb,msg)
select mb,@msg from user where sf= '上海 '
--ID如果为自增列就不用写
------解决方案--------------------同意楼上.
如果要ID.
create proc up_t1(@msg varchar(20))
as
insert into sms(id , mb,msg)
select id , mb,msg = @msg from user where sf= '上海 '
------解决方案--------------------一个参数就可以declare @msg nvarchar(1000)
------解决方案-------------------- create proc test @msg varchar(20),@sf varchar(20)
as
exec( 'insert sms(mb,msg) select mb, '+quotename(@msg, ' ' ' ')+ ' from user where sf= ' ' '+@sf+ ' ' ' ')