Created
May 13, 2011 07:35
-
-
Save FilipDeVos/970150 to your computer and use it in GitHub Desktop.
Enabled Identity insert for normal users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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