Diễn đàn    Phân tích thiết kế hệ thống    insert và Reset id DBCC CHECKIDENT giúp mình với.Thanks

Thành viênTrả lời
itvntbu


2  bài
28-5-2011 16:42:34
Mình dùng 1 store pro.. để insert del repair nhưng khi mình cho dòng
"DBCC CHECKIDENT ('tgdGroupIDID', RESEED, 1)" để reset lại trường id tự tăng thì nó báo lỗi
Checking identity information: current identity value '19', current column value '18'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Msg 2627, Level 14, State 1, Procedure StoretgdGroupIDID, Line 15
Violation of PRIMARY KEY constraint 'PK_tgdGroupIDID'. Cannot insert duplicate key in object 'dbo.tgdGroupIDID'.
The statement has been terminated.


Còn nếu ko cho vào thì chạy Bình thường.Nhưng mình muốn reset khóa chính id tự động tăng có anh em Giúp mình với?.dưới đây là proc....

USE [DBGDnongsan]
GO
/****** Object: StoredProcedure [dbo].[StoretgdGroupIDID] Script Date: 05/28/2011 16:24:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


ALTER PROCEDURE [dbo].[StoretgdGroupIDID](
@mode int,
@id int,
@idGroup int,
@nameGroup nvarchar(50)=null,
@ddescription nvarchar(150)=null,
@icon nvarchar(50)=null
)
as
if(@mode = 1) --Them
begin
DBCC CHECKIDENT ('tgdGroupIDID', RESEED, 1)
INSERT INTO tgdGroupIDID VALUES(@idGroup,@nameGroup,@ddescription,@icon)
end
if(@mode = 0) --Sua
begin
if exists(select * from tgdGroupIDID where id = @id)
begin
update tgdGroupIDID set idGroup= @idGroup,nameGroup=@nameGroup,description=@ddescription,icon=@icon where id = @id
end
end
if(@mode =-1) --Xoa
begin
delete from tgdGroupIDID where id = @id
end


 

Chủ đề gần đây :

Cùng loại :

Tên file Mô tả chi tiết Ngày
NWeb.zip (1) Module đơn giản Newsweb trên Dotnetnuke v10.x.x.x10/18/2025 8:08:11 AM
vspforum.zip (11) Ma nguon vspforum ngay xua4/18/2023 6:38:37 AM
pdfjs.rar (2) pdfjs 2017 : hiển thị tốt trên iphone 11, 12, 13 không lỗi, bản 2012 sẽ lỗi trên iphone6/21/2022 11:52:48 AM
pdfjs2.rar (2) Xem file pdf bằng viewer.hml cua pdfjs (thư viện chuẩn mozilla) 2012. https://mozilla.github.io/pdf.js/getting_started/#download có thể download bản prebuild tại đây6/21/2022 11:52:04 AM
runner.zip (0) using three.js, orbitcontrol to view an object move random on map. Di chuyển 1 đồ vật ngẫu nhiên trên bản đồ, sử dụng với demo nhân viên di chuyển trong văn phòng. Toàn js download về là chạy12/5/2019 5:55:14 PM
gmap.zip (1) google map + marker7/17/2019 2:25:05 PM
vinsmarthomeservice.zip (1) java post json to api, use AsyncTask, event listener7/9/2019 5:00:10 PM
fblogin.zip (0) Login facebook bang javascript SDK7/9/2019 9:16:37 AM
autocomplete-location.zip (2) autocomplete location geo from google place, html + js7/4/2019 4:37:55 PM
WebAPI.zip (8) api for android access db (v1.0.0)7/4/2019 9:14:17 AM