create procedure TestA as
declare @Col1 varchar(10),@bi int
select @bi = 0
declare cur_select cursor
for select GoodstypeID from Goodstype order by GoodstypeID
OPen cur_select
fetch next from cur_select into @Col1
while @@fetch_status = 0
begin
if(@bi = 0)
begin
select IDENTITY(int, 1,1) AS ID_Num,GoodsID into TestAtable from allgoods where left(Middle_Item_ID,2) = @Col1
select @bi = @bi + 1
end
else
begin
select IDENTITY(int, 1,1) AS ID_Num,GoodsID into TestAtable1 from allgoods where left(Middle_Item_ID,2) = @Col1
SET IDENTITY_INSERT TestAtable ON --注意這裡
INSERT INTO TestAtable SELECT * from TestAtable1
drop table TestAtable1
end
FETCH NEXT FROM cur_select INTO @Col1end
select * from TestAtable
drop table TestAtable
close cur_select
deallocate cur_select
go--錯誤信息
位於資料表 'TestAtable' 的識別資料行其外顯值只有當使用了資料行清單且 IDENTITY_INSERT 為 ON 時才能指定。
請問各位這個存儲過程應該怎麼修改。
declare @Col1 varchar(10),@bi int
select @bi = 0
declare cur_select cursor
for select GoodstypeID from Goodstype order by GoodstypeID
OPen cur_select
fetch next from cur_select into @Col1
while @@fetch_status = 0
begin
if(@bi = 0)
begin
select IDENTITY(int, 1,1) AS ID_Num,GoodsID into TestAtable from allgoods where left(Middle_Item_ID,2) = @Col1
select @bi = @bi + 1
end
else
begin
select IDENTITY(int, 1,1) AS ID_Num,GoodsID into TestAtable1 from allgoods where left(Middle_Item_ID,2) = @Col1
SET IDENTITY_INSERT TestAtable ON --注意這裡
INSERT INTO TestAtable SELECT * from TestAtable1
drop table TestAtable1
end
FETCH NEXT FROM cur_select INTO @Col1end
select * from TestAtable
drop table TestAtable
close cur_select
deallocate cur_select
go--錯誤信息
位於資料表 'TestAtable' 的識別資料行其外顯值只有當使用了資料行清單且 IDENTITY_INSERT 為 ON 時才能指定。
請問各位這個存儲過程應該怎麼修改。
解决方案 »
- 在button_click事件中获取repeater某行某列的值
- 获取IP
- 哪个控件有超链接和能存ID的
- 城市切换如何做到更新相关信息,怎么做?
- 有没有什么办法让asp.net 页面返回空,没有任何内容、没有头内容
- DataList1嵌套DataList2 但是DataList2绑定了数据以后显示不出来 请高手帮忙
- 思归帮忙,继续上次您帮我回答的那个问题
- 关于Jquery UI Datepicker的minDate和maxDate,用过的告诉我一下,谢谢
- DataGrid中当进入编辑状态下,怎样能自己控制文本框的长度?能不能由该文本框而知道其字段名?
- MVC项目下用 MVCPager 分页,总是显示英文,更改配置文件也不行,求解答
- 如何添加控件到login control?
- 求一sql語句!
SET IDENTITY_INSERT TestAtable ON --注意這裡
INSERT INTO TestAtable SELECT * from TestAtable1
drop table TestAtable1這段改為select IDENTITY(int, 1,1) AS ID_Num,GoodsID into TestAtable1 from allgoods where left(Middle_Item_ID,2) = @Col1
SET IDENTITY_INSERT TestAtable ON --注意這裡
INSERT INTO TestAtable(ID_Num,GoodsID) SELECT ID_Num,GoodsID from TestAtable1 --修改的地方
SET IDENTITY_INSERT TestAtable OFF --加上的地方
drop table TestAtable1
paoluo(一天到晚游泳的鱼) 的分數的不公特此將本帖所有的分數給paoluo(一天到晚游泳的鱼)
----------------
Select
[排 行]=(Select Count(*) From TableName Where 部門=A.部門 And 商品編號<=A.商品編號
),
*
From TableName A給我的啟發不小,謝謝