insert #ls_zyb4 select * from #ls_zyb6 order by NewId()
在查询分析器中一切都正常~
一用到存储过程就 报错说#ls_zyb4 #ls_zyb6 无效~
请问是什么问题呢?
请求帮助~
下面是我一部分的存储过程~ 在查询分析器中正常~ 一存进存储过程就给我报错~
说#ls_zyb4 #ls_zyb6 无效~ 红色部分为报错地方~
declare @nf int
set @nf= (right(str(YEAR(getdate())),1))
--生成临时志愿表1
SELECT distinct jw_xsb.xh, jw_xsb.xm, jwxt_zyb.xz, jw_kmb.xq, jw_xsb.byktzy1, jw_xsb.byktzy2,
jw_xsb.byktzy3, jw_xsb.byzskt, (cast(@nf as int)-cast(SUBSTRING(jw_xsb.xh,2,1) as int))*2 as xn,jw_xsb.byzdjs
into #ls_zyb1
FROM jw_xsb INNER JOIN
jw_bjb ON jw_xsb.bjdm = jw_bjb.bjdm INNER JOIN
jwxt_zyb ON jw_bjb.zydm = jwxt_zyb.zydm INNER JOIN
jw_kmb ON jw_xsb.bjdm = jw_kmb.bjdm
where jw_kmb.xq=8 and jwxt_zyb.xz=4
--生成临时志愿表2
SELECT distinct jw_xsb.xh, jw_xsb.xm, jwxt_zyb.xz, jw_kmb.xq, jw_xsb.byktzy1, jw_xsb.byktzy2,
jw_xsb.byktzy3, jw_xsb.byzskt, (cast(@nf as int)-cast(SUBSTRING(jw_xsb.xh,2,1) as int))*2 as xn,jw_xsb.byzdjs
into #ls_zyb2
FROM jw_xsb INNER JOIN
jw_bjb ON jw_xsb.bjdm = jw_bjb.bjdm INNER JOIN
jwxt_zyb ON jw_bjb.zydm = jwxt_zyb.zydm INNER JOIN
jw_kmb ON jw_xsb.bjdm = jw_kmb.bjdm
where jw_kmb.xq=6 and jwxt_zyb.xz=3
--生成临时志愿表3
create table #ls_zyb6(
[zdbh] [bigint] IDENTITY (1, 1) NOT NULL ,
[xh] [char] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[xm] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[xz] [int] NULL ,
[xq] [int] NULL ,
[byktzy1] [int] NULL ,
[byktzy2] [int] NULL ,
[byktzy3] [int] NULL ,
[byzskt] [int] NULL ,
[xn] [int] NULL ,
[byzdjs] [int] NULL ,
CONSTRAINT [PK_#ls_zyb6] PRIMARY KEY CLUSTERED
(
[zdbh]
) ON [PRIMARY]
) ON [PRIMARY]
--将符合条件的数据全部插入临时志愿表3
insert #ls_zyb6 select * from #ls_zyb2 where xn=6
insert #ls_zyb6 select * from #ls_zyb1 where xn=8
--生成临时志愿表4
CREATE TABLE #ls_zyb4 (
[zdbh] [bigint] NULL ,
[xh] [char] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[xm] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[xz] [int] NULL ,
[xq] [int] NULL ,
[byktzy1] [int] NULL ,
[byktzy2] [int] NULL ,
[byktzy3] [int] NULL ,
[byzskt] [int] NULL ,
[xn] [int] NULL ,
[byzdjs] [int] NULL ,
)
GO
-- 临时志愿表
CREATE TABLE #ls_zyb5 (
[zdbh1] [bigint] IDENTITY (1, 1) NOT NULL ,
[zdbh] [bigint] NULL ,
[xh] [char] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[xm] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[xz] [int] NULL ,
[xq] [int] NULL ,
[byktzy1] [int] NULL ,
[byktzy2] [int] NULL ,
[byktzy3] [int] NULL ,
[byzskt] [int] NULL ,
[xn] [int] NULL ,
[byzdjs] [int] NULL ,
CONSTRAINT [PK_ #ls_zyb5] PRIMARY KEY CLUSTERED
(
[zdbh1]
) ON [PRIMARY]
) ON [PRIMARY]
GO
--错乱数据
insert #ls_zyb4 select * from #ls_zyb6 order by NewId()
--填充志愿表数据
insert #ls_zyb5 select * from #ls_zyb4
加在哪里??
加在查询分析器??
还是 存储过程??
好像都没有必要加啊~
呵呵 不用你们帮了`我已经解决了`
原来是自己不细心~ 生成那两个临时表的时候多加了几个单词~