USP_IDSET_CREATESTATICTABLE
Parameters
| Parameter | Parameter Type | Mode | Description | 
|---|---|---|---|
| @TABLENAME | nvarchar(128) | IN | |
| @IDCOLUMNTYPENAME | nvarchar(128) | IN | 
Definition
 Copy 
                                    
        create procedure dbo.USP_IDSET_CREATESTATICTABLE
            @TABLENAME nvarchar(128),
            @IDCOLUMNTYPENAME nvarchar(128)
        with execute as owner
        as
        set nocount on
        declare @TABLEID as integer
        declare @SQL as nvarchar(300)
        select @TABLEID = ID from dbo.sysobjects where ID = object_id(@TABLENAME) and objectproperty(id, 'IsUserTable') = 1
        if @TABLEID > 0
            -- table already exists so just truncate it
            exec ('TRUNCATE table [' + @TABLENAME + ']')
        else
                -- create new static table
            begin
                exec ('create table [' + @TABLENAME + '] (
                        ID ' + @IDCOLUMNTYPENAME + ' not null 
                            constraint [PK_' + @TABLENAME + '] primary key clustered on OUTPUTGROUP
                        ) on OUTPUTGROUP;')
                exec ('grant select,insert on [' + @TABLENAME + '] to BBAPPFXSERVICEROLE;')
            end 
        return 0