set nocount on
use shopping
go
declare @flag int,@cmd nvarchar(max)
PRINT 'DBCC CHECKDB operation started'+char(10)
set @cmd = 'dbcc checkdb(shopping)'
exec @flag=dbo.sp_executesql @cmd
if (@flag=0)
PRINT 'DBCC CHECKDB operation finished for database shopping'+char(10)
else
begin
PRINT 'DBCC CHECKDB operation FAILED for database shopping'+char(10)
GOTO FAIL
end
PRINT 'Shrinking of database shopping started'+char(10)
set @cmd = 'dbcc shrinkdatabase ('+''''+'shopping'+''''+',40)'
exec @flag=dbo.sp_executesql @cmd
if (@flag=0)
PRINT 'DBCC SHRINK DATABASE operation finished'+char(10)
else
begin
PRINT 'DBCC SHRINK DATABASE operation FAILED'+char(10)
GOTO FAIL
end
PRINT 'Shrinking of database shopping Fininshed'+char(10)
set @cmd = 'BACKUP DATABASE shopping to disk = '+''''+'C:SQLLabSPshopping.bak'+''''+' with init'
exec @flag=dbo.sp_executesql @cmd
if (@flag=0)
PRINT char(10)+'Backup of database shopping Fininshed'+char(10)
else
begin
PRINT char(10)+'Backup of database shopping FAILED'+char(10)
FAIL: PRINT 'Daily maint for database shopping FAILED'+char(10)
GOTO end1
end
PRINT 'Daily maint for database shopping finished'+char(10)
end1:
set nocount off

