-- ===============================================
-- EPCIS Demo DATABASE
-- Grant permissions 
-- 
-- Version:	1.0 - 01/2005
--
-- ===============================================

USE master
IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname = 'EPCISDemoUser')
BEGIN
    declare @logindb nvarchar(132), @loginlang nvarchar(132) select @logindb = N'master', @loginlang = N'us_english'
    if @logindb is null or not exists (select * from master.dbo.sysdatabases where name = @logindb)
        select @logindb = N'master'
    if @loginlang is null or (not exists (select * from master.dbo.syslanguages where name = @loginlang) and @loginlang <> N'us_english')
        select @loginlang = @@language
    exec sp_addlogin 'EPCISDemoUser', 'EPCISDemoUser', @logindb, @loginlang
END
GO

USE [<<DATABASE_NAME>>]
EXEC sp_grantdbaccess N'EPCISDemoUser'
GO
USE [<<DATABASE_NAME>>]
EXEC sp_addrolemember N'db_owner', N'EPCISDemoUser'
GO