Truncate Logs for SQL Server 2008
Truncate Logs for SQL Server 2008
I had previously posted how to Truncate Logs for SQL Server 2005. Unfortunately, this method does not work in SQL Server 2008. The reason is because the “WITH TRUNCATE_ONLY” command is no longer in SQL 2008. Assuming you run in full recovery mode, the new script to do this is:
USE [{DatabaseName}]
GO
ALTER DATABASE [{DatabaseName}] SET RECOVERY SIMPLE
GO
DBCC SHRINKFILE({TransactionLogLogicalName})
GO
ALTER DATABASE [{DatabaseName}] SET RECOVERY FULL
GO
Simply setting the database mode into simple recovery mode performs the actual truncation but the file is not shrunk by that. DBCC SHRINKFILE will take care of that second step. And don’t forget to put it back into full recovery mode at the end!!
Ïà¹ØÎĵµ£º
ÔÚÎÒÃǽøÐÐsql×¢ÈëµÄ¹ý³ÌÖг£³£»áÓõ½union²éѯ·½·¨£¬´ó¶àÊýÇé¿öÏÂʹÓÃunion²éѯ·¨¿ÉÒÔÈÃÎÒÃǺܿìµÄÖªµÀÄ¿±êµÄÊý¾Ý×éÖ¯·½Ê½¡£È»¶øµ±ÎÒÃÇÓöµ½ntext¡¢text»òimageÊý¾ÝÀàÐÍʱ£¬union²éѯ¾Í²»Ì«¹ÜÓÃÁË¡£ÒÔsql serverΪÀý£¬ÔÚÕâÖÖÇé¿öÏ»áÅ׳öÈçÏ´íÎó£ºntext Êý¾ÝÀàÐͲ»ÄÜѡΪ DISTINCT£¬ÒòΪËü ......
¡¡
¡¡¡¡1. ʹÓÃ%TYPE
¡¡¡¡ÔÚÐí¶àÇé¿öÏ£¬PL/SQL±äÁ¿¿ÉÒÔÓÃÀ´´æ´¢ÔÚÊý¾Ý¿â±íÖеÄÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬±äÁ¿Ó¦¸ÃÓµÓÐÓë±íÁÐÏàͬµÄÀàÐÍ¡£ÀýÈ磬students±íµÄfirst_nameÁеÄÀàÐÍΪVARCHAR2(20),ÎÒÃÇ¿ÉÒÔ°´ÕÕÏÂÊö·½Ê½ÉùÃ÷Ò»¸ö±äÁ¿£º
¡¡¡¡DECLARE
¡¡¡¡ v_FirstName VARCHAR2(20);
¡¡
¡¡µ«ÊÇÈç¹ûfirst_nameÁеĶ¨Òå¸Ä±äÁ ......
SQL Server Êý¾Ý¿â¹ÜÀí³£ÓõÄSQLºÍT-SQLÓï¾ä
1. ²é¿´Êý¾Ý¿âµÄ°æ±¾
select @@version
2. ²é¿´Êý¾Ý¿âËùÔÚ»úÆ÷²Ù×÷ϵͳ²ÎÊý
exec master..xp_msver
3. ²é¿´Êý¾Ý¿âÆô¶¯µÄ²ÎÊý
sp_configure
4. ²é¿´Êý¾Ý¿âÆô¶¯Ê±¼ä
select convert(varchar(30),login_time,120) from master..sysprocesses where spid=1
²é¿´Êý ......
ͨÅä·û ˵Ã÷
_ ÓëÈÎÒâµ¥×Ö·ûÆ¥Åä
% Óë°üº¬Ò»¸ö»ò¶à¸ö×Ö·ûµÄ×Ö·û´®Æ¥Åä
[ ] ÓëÌض¨·¶Î§£¨ÀýÈ磬[a-f]£©»òÌض¨¼¯£¨ÀýÈ磬[abcdef]£©ÖеÄÈÎÒâµ¥×Ö·ûÆ¥Åä¡£
[^] ÓëÌض¨·¶Î§£¨ÀýÈ磬[^a-f]£©»òÌض¨¼¯£¨ÀýÈ磬[^abcdef]£©Ö®ÍâµÄÈÎÒâµ¥×Ö·ûÆ¥Åä¡£
......
½ñÌì³é³öÒ»µãʱ¼ä½âÊͼ¸¸ö¹ØÓÚSQLÈÕÖ¾µÄ¸ÅÄËûÃÇÒ²¾³£Ê¹³õѧÕßÍû¶øÖ¹²½£¬·´Õý¼ÆËã»úµÄÊõÓﶼÊǺܳéÏóµÄ£¬ËùÒÔµÚÒ»¸Ð¾õ¾ÍÊÇÍ·ÌÛ£¬È»ºóÈ»ºó¼¸´Îºó¾Íû¸Ð¾õÁË.ÒÔÏÂÓÐЩÊÇ´ÓÊéÉÏÕª³µÄ,ÓеÄÊÇ´ÓÍøÉÏÕÒµÄËãÊǽ軨Ï×·ð°É!!
¡¡¡¡ÎïÀíÈÕÖ¾Îļþ£º
Õâ¸ö±È½ÏºÃÀí½â£¬ÊµÊµÔÚÔڵĶ«Î÷£¬Êý¾Ý¿âĿ¼ÏÂÃæµÄ.ldfÎļþ ......