·ÀÖ¹SQL SERVERµÄʼþ̽²éÆ÷¸ú×Ù³ÌÐòÖÐSQL½Å±¾
ÈçºÎ·ÀÖ¹³ÌÐòÖÐSQL½Å±¾±»SQL SERVERµÄʼþ̽²éÆ÷¸ú×Ù£¬±£ÕÏ×Ô¼ºµÄÈí¼þ²»±»ËûÈË·ÖÎö£¿
ÏÂÃæÊÇÒ»¸öÍ£Ö¹ËùÓÐSQLSERVERµÄ¸ú×ÙÆ÷µÄ½Å±¾(Á½ÖÖ·½·¨µÄÔÀíÏàͬ)£º
µÚÒ»ÖÖ·½·¨£º
procedure SQLCloseAllTrack;
const
sql = 'declare @TID integer ' +
'declare Trac Cursor For ' +
'SELECT Distinct Traceid from :: fn_trace_getinfo(default) ' +
'open Trac ' +
'Fetch Next from Trac into @TID ' +
'while @@fetch_status=0 ' +
'begin ' +
' exec sp_trace_setstatus @TID,0 ' +
' exec sp_trace_setstatus @TID,2 ' +
' Fetch Next from Trac into @TID ' +
'end ' +
'Close Trac ' +
'deallocate Trac';
begin
//Í£Ö¹ËùÓÐSQLSERVERµÄ¸ú×ÙÆ÷,ÒÔ·ÀÖ¹³ÌÐò±»別È˸ú×Ù
ExecSql(sql);
end;
µÚ¶þÖÖ·½·¨£º
with faq1 do
begin
Close;
sql.Clear;
sql.add('declare @t_count int');
sql.add('set @t_count=1');
sql.add('while exists(SELECT * from ::::fn_trace_geteventinfo(@t_count))');
sql.add('begin');
sql.add('exec sp_trace_setstatus @t_count,0');
sql.add('set @t_count=@t_count+1');
sql.add('end');
try
execSQL;
except;
end;
close;sql.Clear;
end;
end;
Ïà¹ØÎĵµ£º
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢Ë ......
н¨Êý¾Ý±íÒÔºó£¬ÈôÔÙ¶Ô¸Ã±í½øÐиü¸Ä£¬Ôò»á³öÏÖ¾¯¸æÐÅÏ¢“²»ÔÊÐí±£´æ¸ü¸Ä ×èÖ¹±£´æÒªÇóÖØÐ´´½¨±íµÄ¸ü¸Ä”£¬µÈµÈ£¬ÐèÒª½øÐÐÒ»ÏÂÉèÖ㺹¤¾ß--->Ñ¡Ïî--->Designers--->±íÉè¼ÆÆ÷ºÍÊý¾Ý¿âÉè¼ÆÆ÷--->×éÖ¯±£´æÒªÇóÖØÐ´´½¨±íµÄ¸ü¸Ä£¬È¥µô¸´Ñ¡¿ò¡£
À´Ô´ÍøÂ磺“²»ÊǺÜÀí½âΪʲôÔÚ2008Öлá¼ÓÈë"×èÖ¹ ......
SELECT id,ip,from_unixtime(last_task_request_time) t1, from_unixtime(last_task_finish_time) t2
from yq_nodemanage
WHERE node_type=1
ORDER BY t1 DESC;
SELECT sum(unix_timestamp(gather_time)-unix_timestamp(publish_time))/(count(*)*60) from yq_bbs_docinfo
WHERE unix_timestamp(publish_time)>un ......
ÉÏÒ»½Ú½²ÊöµÄÊÇɾ³ý²Ù×÷£¬±¾½Ú½«½²ÊöÈçºÎÖ±½ÓÖ´ÐÐsqlÓï¾ä¡£ Ö±½ÓÖ´ÐÐsqlÓï¾äÊÇʹÓÃfromSql·½·¨¡£ DbSession.Default.fromSql("select * from products").ToDataTable();
ÕâÑù¿´ÆðÀ´Ç×ÇжàÁ˰ɣ¬Ö±½Ósql¾Í¿ÉÒÔÖ´ÐС£
µ±È»Ò²¿ÉÌí¼Ó²ÎÊýµÄ°¡¡£
DbSession.Default.fromSql("select * ......
CONVERTµÄʹÓ÷½·¨:
¡¡¡¡¸ñʽ:
¡¡¡¡CONVERT(data_type,expression[,style])
¡¡¡¡ËµÃ÷:
¡¡¡¡´ËÑùʽһ°ãÔÚʱ¼äÀàÐÍ(datetime,smalldatetime)Óë×Ö·û´®ÀàÐÍ(nchar,nvarchar,char,varchar)
¡¡¡¡Ï໥ת»»µÄʱºò²ÅÓõ½.
¡¡¡¡Àý×Ó:
¡¡¡¡Select CONVERT(varchar(30),getdate(),101) now
¡¡¡¡½á¹ûΪ
¡¡¡¡now
¡¡¡¡ ......