Friday, October 24, 2014

Saving SQL Server backup file in multiple parts


Normal backup
SET STATISTICS IO ON

SET STATISTICS TIME ON

BACKUP DATABASE DBNAME
TO DISK = 'D:\DBNAME.bak'

SET STATISTICS IO OFF

SET STATISTICS TIME OFF
to split the size into 3 use the following code, it will split the size of 3 gb into 1 GB each file you can add more files or less depending on the size you want
SET STATISTICS IO ON

SET STATISTICS TIME ON


BACKUP DATABASE DBNAME TO

DISK = 'D:\DBBackups\ReportServer\DBNAME _Split1.bak'

,DISK = 'D:\DBBackups\ReportServer\DBNAME _Split2.bak'

,DISK = 'D:\DBBackups\ReportServer\DBNAME _Split3.bak'


SET STATISTICS IO OFF

SET STATISTICS TIME OFF

Wednesday, March 19, 2014

SQL : Split string into Column


 SELECT Split.a.value('.', 'VARCHAR(24)') AS String  
 FROM (SELECT CAST ('<M>' + REPLACE('331AW150A01F01,331AW250A01F01,331AW350A01F01,331WF450A01F01', ',', '</M><M>') + '</M>' AS XML) AS String ) 
 AS A CROSS APPLY String.nodes ('/M') AS Split(a);