这个存储该怎么写?
create procedure tj
@m_yue varchar(10)
begin
insert table(kh,zh,name,@m_yue)
select kh,zh,name,zh*zj
from table
end
执行报@m_yue有错误,如果不能用变量,那该怎么写哦
------解决方案--------------------exec( 'insert table(kh,zh,name, '+@m_yue+ ') select kh,zh,name,zh*zj from table ')
------解决方案--------------------create procedure tj
@m_yue varchar(10)
begin
insert table(kh,zh,name,@m_yue)
select kh,zh,name,zh*zj
from table
end
执行报@m_yue有错误,如果不能用变量,那该怎么写哦
------------------------
你的table表如果是3列的话,这样是无法插入的
不如这样插入新表 select * into 新表 from(select kh,zh,name,zh*zj from table)t
------解决方案--------------------create procedure tj
@m_yue varchar(10)
as ---加下
begin
insert table(kh,zh,name,@m_yue)
select kh,zh,name,zh*zj
from table
end
少個as
------解决方案--------------------create procedure tj
@m_yue varchar(10)
as
declare @stringa string
select @stringa= 'insert table(kh,zh,name, '
+@m_yue
+ ')select kh,zh,name,zh*zj from table '
execute (@stringa)
end
------解决方案----------------------try
exec( 'insert table(kh,zh,name, '+@m_yue+ ') select kh,zh,name,zh*zj from table
where kh= ' ' ' ' and zh= ' 'xxx ' ' ')