Skip to content

Instantly share code, notes, and snippets.

@FilipDeVos
Created May 13, 2011 07:35
Show Gist options
  • Save FilipDeVos/970150 to your computer and use it in GitHub Desktop.
Save FilipDeVos/970150 to your computer and use it in GitHub Desktop.
Enabled Identity insert for normal users
create database identity_insert_test
GO
use identity_insert_test
exec sp_addlogin 'SimpleLogin', 'PasswordForSimpleLogin'
GO
exec sp_grantdbaccess 'SimpleLogin', 'SimpleLogin'
GO
if object_id('dbo.a') is not null
drop table dbo.a
create table dbo.a (keyfield int identity, somevalue varchar(10))
GO
if object_id('p_a')is not null
drop procedure p_a
go
create procedure p_a
as
set identity_insert dbo.a on
insert into dbo.a (keyfield, somevalue) values (2,'nice')
set identity_insert dbo.a off
return (0)
go
grant exec on p_a to SimpleLogin
go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment