insert into xs_xjyd_temp (oc_xszb,oc_xxzb,oc_bjzb,dt_yd_start,dt_yd_end,oc_ydlx,dt_czrq,oc_czy,oc_yxbz)
select oc_xszb,oc_mbxxzb,oc_mbbjzb,dt_ydrq,'9999-01-01',oc_ydlx,getdate(),'','T' from
(select b.oc_xszb,b.oc_mbxxzb,b.oc_mbbjzb,dt_ydrq,oc_ydlx
from xs_xszb a,xs_xjyd b where a.c_id in (select oc_xszb from xs_xjyd where oc_yxbz='T' group by oc_xszb
having count(oc_xszb)=1) and a.oc_yxbz='T' and b.oc_yxbz='T' and a.c_id = b.oc_xszb and b.oc_ydlx in ('00','01','03') ) a上面是我的SQL语句,我在SQL查询分析器里可以执行。当我要生成储过程执行到该语句时,老提示:在关键字 'INSERT ' 附近有语法错
我的SQL语句确实又没问题。报这样的错,怎么解决。。期待中。
select oc_xszb,oc_mbxxzb,oc_mbbjzb,dt_ydrq,'9999-01-01',oc_ydlx,getdate(),'','T' from
(select b.oc_xszb,b.oc_mbxxzb,b.oc_mbbjzb,dt_ydrq,oc_ydlx
from xs_xszb a,xs_xjyd b where a.c_id in (select oc_xszb from xs_xjyd where oc_yxbz='T' group by oc_xszb
having count(oc_xszb)=1) and a.oc_yxbz='T' and b.oc_yxbz='T' and a.c_id = b.oc_xszb and b.oc_ydlx in ('00','01','03') ) a上面是我的SQL语句,我在SQL查询分析器里可以执行。当我要生成储过程执行到该语句时,老提示:在关键字 'INSERT ' 附近有语法错
我的SQL语句确实又没问题。报这样的错,怎么解决。。期待中。
解决方案 »
- sql 问题。。
- sql语句问题,请进!!!
- SQL 2000 表变量和临时表的区别
- 有人能帮我看看这个SQL语句错在哪里了吗?
- 求回答
- 这种问题自己居然不会,真是有点想不明白,请高手们帮忙看看啦。
- 王老师 mssql2000 转 mssql2005 怎么转啊
- sqlserver 2005 中文字符查询问题
- 为什么Microsoft OLE DB Provider for SQL Server在我的客户机上能够配置,而在服务器端却不能配置。我的服务器配置应当注意什么。很急!!!!!!!!!!!!!!!
- 腾训的速度这么快,用的什么数据库呀?
- 安装SQL server 2008 R2 需要依赖Power shell吗
- 安装VS2010的时候附带安装的SQL server compact,是一个服务器吗?
(oc_xszb,oc_xxzb,oc_bjzb,dt_yd_start,dt_yd_end,oc_ydlx,dt_czrq,oc_czy,oc_yxbz
)
select oc_xszb,oc_mbxxzb,oc_mbbjzb,dt_ydrq,'9999-01-01',oc_ydlx,getdate(),'','T' from
(
select b.oc_xszb,b.oc_mbxxzb,b.oc_mbbjzb,dt_ydrq,oc_ydlx
from xs_xszb a,xs_xjyd b where a.c_id in (select oc_xszb from xs_xjyd where oc_yxbz='T' group by oc_xszb
having count(oc_xszb)=1) and a.oc_yxbz='T' and b.oc_yxbz='T' and a.c_id = b.oc_xszb and b.oc_ydlx in ('00','01','03')
) a语法没有问题
字段类型与插入的不匹配
贴存储过程,可能问题不在这里,在insert的上面。
string str='create proc test as' +
'insert ...'这样的话,在insert 前加空格看看。
(oc_xszb,oc_xxzb,oc_bjzb,dt_yd_start,dt_yd_end,oc_ydlx,dt_czrq,oc_czy,oc_yxbz
)
select oc_xszb,oc_mbxxzb,oc_mbbjzb,dt_ydrq,'9999-01-01',oc_ydlx,getdate(),'','T' from
(
select b.oc_xszb,b.oc_mbxxzb,b.oc_mbbjzb,dt_ydrq,oc_ydlx
from xs_xszb a,xs_xjyd b where a.c_id in (select oc_xszb from xs_xjyd where oc_yxbz='T' group by oc_xszb
having count(oc_xszb)=1) and a.oc_yxbz='T' and b.oc_yxbz='T' and a.c_id = b.oc_xszb and b.oc_ydlx in ('00','01','03')
) a
两个a重命名了.
所以里面的a.引用无效.