USP_EMAILLIST_CREATEUPLOADEMAILTABLE
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@LISTID | int | IN | |
@LISTFIELDS | nvarchar(max) | IN |
Definition
Copy
create procedure dbo.USP_EMAILLIST_CREATEUPLOADEMAILTABLE
(
@LISTID int,
@LISTFIELDS nvarchar(MAX) = ''
) WITH EXECUTE AS OWNER
AS
BEGIN
set nocount on;
declare @TABLENAME nvarchar(128);
set @TABLENAME = dbo.fnUloadedListBuildTableName(@LISTID);
if @LISTFIELDS is null
set @LISTFIELDS = '';
-- delete the list table if it exists
exec dbo.spUploadedListDelete @LISTID;
declare @SQL nvarchar(MAX);
set @SQL = 'create table [' + @TABLENAME + '](' + char(13) +
'[BB_XListSequence] [int] IDENTITY (1, 1) NOT NULL, ' + char(13) +
'[BB_XListRecordGuid] [uniqueidentifier] rowguidcol not null constraint [DF_' + @TABLENAME + '_GUID] default (newid()) ' + char(13) +
(case when len(@LISTFIELDS) = 0 then '' else (',' + char(13) + @LISTFIELDS) end) + char(13) +
'constraint [PK_' + @TABLENAME + '] primary key clustered ([BB_XListRecordGuid] asc) ' + char(13) +
')';
exec (@SQL);
/* Grant select, insert, and update rights on the new table */
exec ('grant select, insert, update on [' + @TABLENAME + '] to BBPortalWebRole');
return 0;
end