Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
BobRoberts
Posting Yak Master
109 Posts |
Posted - 2010-02-11 : 12:11:13
|
| This is for SQL 2005/2008 Express: I notice that when I run the two scripts below, one to create a table, and the other to create a view of the table, the table and view it creates don't have any "Users or roles" when you click the Properties - Permissions. Because this table and view are used to insert, delete, update, and select rows, it needs to have a user/role of Public, and permissions for grantor to grant insert, delete update, and select. Is it possible to do this within the SQL script itself - or does that have to be done manually?BEGINCREATE TABLE [dbo].[TestTable]( [SequenceNumber] [int] NOT NULL, [EarningCode] [dbo].[pCode] NOT NULL, [PrintSeqNo] [smallint] NULL, [PrintCounter] [int] NOT NULL, [EmployeeID] [dbo].[pEmpID] NULL) ON [PRIMARY]ENDGOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE VIEW [dbo].[TestTable]ASSELECT SequenceNumber, EarningCode, PrintSeqNo, PrintCounter, EmployeeIDFROM dbo.TestTableGO |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-02-11 : 12:31:00
|
You can "script" it, and thus include it in your script, but you can't put it in the CREATE statement itself (AFAIK)GRANT SELECT, INSERT, UPDATE, DELETE ON [dbo].[TestTable] TO SomeUserOrRoleName |
 |
|
|
BobRoberts
Posting Yak Master
109 Posts |
Posted - 2010-02-11 : 14:46:50
|
| Yes, that's exactly what I needed - thanks. |
 |
|
|
|
|
|
|
|