There is a problem when I run this query
BACKUP DATABASE Test TO DISK = \'C:\\backup\\t1.bak'
WITH NOFORMAT, COMPRESSION, NOINIT,
NAME = N'Test-Full Database Backup',
SKIP, STATS = 10
from SQL Server Management Studio it creates a file with size of 1,186 kb and when I use that code from C# it create a file with size of 11,853kb please anyone tell me why ?
I've got a strong feeeling you're appending to your backup media by specifying NOFORMAT
. Hence the size increase. I usually use FORMAT
to overwrite the backup media.
The NOINIT
option you are using is appending to the end of the backup set, so every time you run the script you're adding to the same file, increasing it's size. Please see the Media set options section in the documentation here.
I think calling it from SSMS vs C# is a red herring in this case - you probably just tried it from SSMS first, hence not noticing the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.