MFC调用系统调色板和数据库备份和收缩日志

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);

数据库备份

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(50),getdate(),112)+'.bak' 
BACKUP DATABASE naneXXXX TO  
DISK=@name 
WITH NOFORMAT, NOINIT,  
NAME = N'naneXXXX -完整 数据库 备份', 
SKIP, NOREWIND, NOUNLOAD


出现问题找不到 ···xp_cmdShell的解决方法:
SQL Server 阻止了对组件 'xp_cmdshell' 的 过程'sys.xp_cmdshell' 的访问,因为此组件已作为此服务器
选择master数据库执行下面语句
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
收缩日志 
dump transaction naneXXXX with no_log;
backup log naneXXXX  with no_log;
dbcc shrinkfile(2);


你可能感兴趣的:(个人心得)