SELECT NewID()
8E8DDFD9-568C-4815-832B-551604AEFB9F
SELECT NewID()
sp_changeobjectowner 'fasttrackuser.FastTrackPackageDocumentsCombinations', 'dbo'
CREATE PROCEDURE USP_DropTableConstraints @tablename VARCHAR(128) AS SET NOCOUNT ON DECLARE @constraintname VARCHAR(128), @sqlcmd VARCHAR(1024) DECLARE CONSTRAINTSCURSOR CURSOR FOR SELECT NAME FROM SYSOBJECTS WHERE XTYPE IN ('C','F','PK','UQ', 'D') AND (STATUS & 64) = 0 AND PARENT_OBJ = OBJECT_ID(@tablename) -- nb : xtype refers to CHECK, FOREIGN KEY, PRIMARY KEY, UNIQUE, and DEFAULT constraints. OPEN CONSTRAINTSCURSOR FETCH NEXT FROM CONSTRAINTSCURSOR INTO @constraintname WHILE (@@FETCH_STATUS = 0) BEGIN SELECT @sqlcmd = 'ALTER TABLE ' + @tablename + ' DROP CONSTRAINT ' + @constraintname EXEC( @sqlcmd) FETCH NEXT FROM CONSTRAINTSCURSOR INTO @constraintname END CLOSE CONSTRAINTSCURSOR DEALLOCATE CONSTRAINTSCURSOR RETURN 0 GO
IF EXISTS(select * from information_schema.tables where table_name ='FORECAST_BREAKDOWN') BEGIN DROP TABLE [dbo].[FORECAST_BREAKDOWN] END CREATE TABLE [dbo].[FORECAST_BREAKDOWN]( [STACK_ID] [numeric](10, 0) NOT NULL, [PLOT_CODE] [varchar](20) NOT NULL, [FB_AMOUNT] [numeric](35, 10) NOT NULL CONSTRAINT [DF__FORECAST___FB_AM__54EB90A0] DEFAULT ((0)), [DESCRIPTION] [varchar](255) NULL, [FB_DATE] [datetime] NULL) go
IF NOT EXISTS(select * from information_schema.columns where table_name ='forecast_breakdown' and column_name = 'srno') BEGIN PRINT 'Column not present, creating...' ALTER TABLE [FORECAST_BREAKDOWN] ADD SRNO INT END ELSE BEGIN PRINT 'Column already present' END
/* dynamic sql to search for data */ select 'if exists (select 1 from [' + table_name + '] where ' + column_name + ' like ''%Fred Bloggs%'' ) print ''' + table_name + '/' + column_name + '''' + char(10) + 'go' from information_schema.columns where data_type in ('ntext','smallint','int','char', 'varchar', 'nvchar', 'nvarchar') and table_schema = 'dbo' and column_name <> 'order'
select 'Grant EXEC on ' + name + ' to MyUser' from sysobjects where type = 'P'
sp_fulltext_service 'resource_usage' , n