Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Can we move the CT Tables to different filegroup or Different Disk from Base tables. Expand / Collapse
Author
Message
Posted Monday, February 11, 2013 12:23 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 4:07 AM
Points: 180, Visits: 516
Hi All,
I understand that when we enable CDC on a database, all the respective CT Tables are created on the same array as base tables. can we possibly move these CT Tables to different disk?

How is it possible? Can some one please tell me.?
Post #1418597
Posted Monday, February 11, 2013 12:29 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 4:07 AM
Points: 180, Visits: 516
I just read online that While enabling CDC, we can point the CT table to reside on different filegroup. Now my question is is there a way to move the CT table without loosing the existing History.

Something like backup and restore with Keep_CDC Option and point the CT tables to different file group..?

I might be completely wrong....
Post #1418600
Posted Thursday, February 14, 2013 1:59 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 6:13 AM
Points: 116, Visits: 298
I'm sure you already foun this script

DECLARE @schema_name VARCHAR(50)
DECLARE @table_name VARCHAR(100)
DECLARE @sql VARCHAR(500)
DECLARE @new_filegroup VARCHAR(100)

SET @schema_name = 'Person'
SET @table_name = 'Contact'
SET @new_filegroup = 'AW_CDC'


IF NOT EXISTS (SELECT * FROM sys.filegroups F WHERE name = @new_filegroup)
BEGIN
PRINT 'Invalid Filegroup'
RETURN
end



IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[cdc].['+@schema_name+'_'+@table_name+'_CT]') AND name = @schema_name+'_'+@table_name+'_CT_clustered_idx')
BEGIN
PRINT 'No CDC table for specified schema and table name'
RETURN
END
ELSE
begin
SET @sql = 'DROP INDEX ['+@schema_name+'_'+@table_name+'_CT_clustered_idx] ON [cdc].['+@schema_name+'_'+@table_name+'_CT] WITH ( ONLINE = OFF )'
EXEC (@sql)

SET @sql = '
CREATE UNIQUE CLUSTERED INDEX ['+@schema_name+'_'+@table_name+'_CT_clustered_idx] ON [cdc].['+@schema_name+'_'+@table_name+'_CT]
(
[__$start_lsn] ASC,
[__$seqval] ASC,
[__$operation] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON '+@new_filegroup

EXEC (@sql)
end

You could maybe copy the existing data to a temporary table and then copy it back.

Take a look at this link!

Now you just have to do the transfer :P...


Greetz
SQL Pizza



sometimes you dont see the pizza for the toppings...
seek and ya shall find...
Post #1419874
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse