June 24, 2008 at 3:25 pm
Is there a script anywhere to do this?
June 24, 2008 at 3:32 pm
Search books online (BOL) for creating indexing and dropping indexes
Gethyn Elliswww.gethynellis.com
June 25, 2008 at 8:01 am
ok here goes, check if this is useful and change it to suite your needs or let me know:
declare @tabname_var varchar(25)
declare @sqlstm varchar(4000)
declare @dbname_var sysname
Declare dbnamecur cursor for
select name from master.dbo.sysdatabases where dbid>4
Open dbnamecur
fetch next from dbnamecur into @dbname_var
while @@fetch_status=0
BEGIN
declare tabcur cursor for
select TABLE_NAME from information_Schema.tables where table_type='BASE TABLE'
open tabcur
fetch next from tabcur into @tabname_var
while @@fetch_status=0
BEGIN
SET @sqlstm = ' ALTER TABLE ['+@dbname_var+'].[dbo].['+@tabname_var+']
ADD CONSTRAINT ['+@tabname_var+'_PK] PRIMARY KEY CLUSTERED
(
[column1],
[column2],
[column3],
[column4]
) WITH FILLFACTOR = 90'
PRINT (@sqlstm)
fetch next from tabcur into @tabname_var
END
close tabcur
deallocate tabcur
fetch next from dbnamecur into @dbname_var
END
close dbnamecur
deallocate dbnamecur
Maninder
www.dbanation.com
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply