MFC calls the System palette and database backup and shrink logs

Source: Internet
Author: User
Tags echo d getdate

CColorDialog Dlg;
Dlg. DoModal ();
M_crcurcolor = dlg. GetColor ();//colorref M_crcurcolor;
BYTE r = getrvalue (M_crcurcolor);

BYTE g = Getgvalue (M_crcurcolor);

BYTE B = Getbvalue (M_crcurcolor);

Database backup

Declare @name varchar (250)
EXEC Master. xp_cmdshell ' echo d:\ &cd d:\ &d: &if not exist database MD database '


Set @name = ' D:\database\naneXXXX _ ' +
CONVERT (varchar), GETDATE (), () + '. Bak '
BACKUP DATABASE nanexxxx to
[Email protected]
With Noformat, Noinit,
NAME = N ' nanexxxx-full database backup ',
SKIP, Norewind, Nounload


There are no problems to find ... xp_cmdshell Workaround:
SQL Server blocked access to the process ' Sys.xp_cmdshell ' for component ' xp_cmdshell ' because this component has been used as this server
Select the master database to execute the following statement
sp_configure ' show advanced options ', 1
Reconfigure
Go
sp_configure ' xp_cmdshell ', 1
Reconfigure
Go


Deleteoldbackup
DECLARE @OLDDATE DATETIME
EXEC Master. xp_cmdshell ' echo d:\ &cd d:\ &d: &if not exist database MD database '
SELECT @OLDDATE =getdate ()-7
EXECUTE master.dbo.xp_delete_file 0,n ' D:\database ', N ' bak ', @olddate
Shrink Log
Dump transaction nanexxxx with NO_LOG;
Backup log nanexxxx with no_log;
DBCC SHRINKFILE (2);


MFC calls the System palette and database backup and shrink logs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.