Bạn thể tắt thuộc tính Identity, nhưng nó liên quan đến bảng hệ thống chỉnh sửa mà không được xem là một thực hành tốt. Bạn cũng không có khả năng có các quyền cần thiết, và có lẽ sẽ thấy You do not have permission to run the RECONFIGURE statement
cố gắng đoạn mã sau:
DECLARE @tableName nvarchar(128) = 'YourTable';
-- Get a list of identity columns (informational)
SELECT OBJECT_NAME(object_id) tableName, sc.name colName, st.name dataType
FROM sys.columns sc
JOIN sys.types st
ON st.system_type_id = sc.system_type_id
WHERE sc.is_identity = 1
AND OBJECT_NAME(object_id) = @tableName
-- Allow ad-hoc changes to system catalogs
EXEC sp_configure 'allow update', 1
GO
reconfigure with override
GO
-- Eliminate the identityness
UPDATE syscolumns SET colstat = colstat - 1
WHERE id = object_id(@tableName)
AND name = 'Id' -- Specify column if you like, though only one identity per table is currently supported
GO
-- Unallow ad-hoc changes to system catalogs
exec sp_configure 'allow update', 0
GO
reconfigure with override
GO
Nguồn
2016-03-13 04:00:08
Cảm ơn rất nhiều ... –