Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLÊý¾Ý¿â¿ª·¢ÖеÄһЩ¾«µä´úÂë

ÕýÔÚ¼ÓÔØÊý¾Ý...
¡¡¡¡1.°´ÐÕÊϱʻ­ÅÅÐò: select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
¡¡¡¡2.Êý¾Ý¿â¼ÓÃÜ: select encrypt(’ԭʼÃÜÂë’) select pwdencrypt(’ԭʼÃÜÂë’) select pwdcompare(’ԭʼÃÜÂë’,’¼ÓÃܺóÃÜÂë’) = 1--Ïàͬ£»·ñÔò²»Ïàͬ
¡¡¡¡3.È¡»Ø±íÖÐ×Ö¶Î: declare @list varchar(1000),@sql nvarchar(1000) select @list=@list+’,’+b.name from sysobjects a,syscolumns b where a.id=b.id and a.name=’±íA’ set @sql=’select ’+right(@list,len(@list)-1)+’ from ±íA’ exec (@sql)
¡¡¡¡
¡¡¡¡4.²é¿´Ó²ÅÌ·ÖÇø: exec master..xp_fixeddrives
¡¡¡¡ 5.±È½ÏA,B±íÊÇ·ñÏàµÈ: if (select checksum_agg(binary_checksum(*)) from A)     =    (select checksum_agg(binary_checksum(*)) from B) print ’ÏàµÈ’ else print ’²»ÏàµÈ’
¡¡¡¡
¡¡¡¡6.ɱµôËùÓеÄʼþ̽²ìÆ÷½ø³Ì: DECLARE hcforeach CURSOR GLOBAL FOR select ’kill ’+RTRIM(spid) from master.dbo.sysprocesses where program_name IN(’SQL profiler’,N’SQL ʼþ̽²éÆ÷’) exec sp_msforeach_worker ’?’
¡¡¡¡7.¼Ç¼ËÑË÷: ¿ªÍ·µ½NÌõ¼Ç¼ select Top N * from ±í ------------------------------- Nµ½MÌõ¼Ç¼(ÒªÓÐÖ÷Ë÷ÒýID) select Top M-N * from ±í where ID in (select Top M ID from ±í) Order by ID Desc ---------------------------------- Nµ½½áβ¼Ç¼ select Top N * from ±í Order by ID Desc
¡¡¡¡8.ÈçºÎÐÞ¸ÄÊý¾Ý¿âµÄÃû³Æ: sp_renamedb ’old_name’, ’new_name’
¡¡¡¡ 9£º»ñÈ¡µ±Ç°Êý¾Ý¿âÖеÄËùÓÐÓû§±í select Name from sysobjects where xtype=’u’ and status>=0
¡¡¡¡10£º»ñȡijһ¸ö±íµÄËùÓÐ×ֶΠselect name from syscolumns where id=object_id(’±íÃû’)
¡¡¡¡11£º²é¿´Óëijһ¸ö±íÏà¹ØµÄÊÓͼ¡¢´æ´¢¹ý³Ì¡¢º¯Êý select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like ’%±íÃû%’
¡¡¡¡12£º²é¿´µ±Ç°Êý¾Ý¿âÖÐËùÓд洢¹ý³Ì select name as ´æ´¢¹ý³ÌÃû³Æ from sysobjects where xtype=’P’
¡¡¡¡13£º²éѯÓû§´´½¨µÄËùÓÐÊý


Ïà¹ØÎĵµ£º

¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨

1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
      Àý:      Select * from tableName
                Exec('select * from tableName')
        & ......

SQL Server ÈÕÆÚ²Ù×÷È«½Ó´¥

DECLARE @dt datetime
SET @dt=GETDATE()
DECLARE @number int
SET @number=3
--1£®Ö¸¶¨ÈÕÆÚ¸ÃÄêµÄµÚÒ»Ìì»ò×îºóÒ»Ìì
--A. ÄêµÄµÚÒ»Ìì
SELECT CONVERT(char(5),@dt,120)+'1-1'
--B. ÄêµÄ×îºóÒ»Ìì
SELECT CONVERT(char(5),@dt,120)+'12-31'
--2£®Ö¸¶¨ÈÕÆÚËùÔÚ¼¾¶ÈµÄµÚÒ»Ìì»ò×îºóÒ»Ìì
--A. ¼¾¶ÈµÄµÚÒ»Ìì
SELECT CON ......

MySQL¶Ô±ê×¼SQLµÄÀ©Õ¹

MySQL·þÎñÆ÷°üº¬Ò»Ð©ÆäËûSQL DBMSÖв»¾ß±¸µÄÀ©Õ¹¡£×¢Ò⣬Èç¹ûʹÓÃÁËËüÃÇ£¬½«ÎÞ·¨°Ñ´úÂëÒÆÖ²µ½ÆäËûSQL·þÎñÆ÷¡£ÔÚijЩÇé¿öÏ£¬Äã¿ÉÒÔ±àд°üº¬MySQLÀ©Õ¹µÄ´úÂ룬µ«ÈÔ±£³ÖÆä¿ÉÒÆÖ²ÐÔ£¬·½·¨ÊÇÓÓ/*... */”×¢Ê͵ôÕâЩÀ©Õ¹¡£MySQL·þÎñÆ÷Äܹ»½âÎö²¢Ö´ÐÐ×¢ÊÍÖеĴúÂ룬¾ÍÏñ¶Ô´ýÆäËûMySQLÓï¾äÒ»Ñù£¬µ«ÆäËûSQL·þÎñÆ÷½«ºöÂÔ ......

SQL Ñ­»·Óï¾ä while ½éÉÜ ÊµÀý ¼ò½é

 declare @i int
set @i=1
while @i<30
begin
insert into test (userid) values(@i)
set @i=@i+1
end
---------------
while Ìõ¼þ
begin
Ö´ÐвÙ×÷
set @i=@i+1
end
WHILE
ÉèÖÃÖظ´Ö´ÐÐ SQL Óï¾ä»òÓï¾ä¿éµÄÌõ¼þ¡£Ö»ÒªÖ¸¶¨µÄÌõ¼þΪÕ棬¾ÍÖظ´Ö´ÐÐÓï¾ä¡£¿ÉÒÔʹÓà BREAK ºÍ CONTINUE ¹Ø¼ü×ÖÔÚÑ­»·ÄÚ²¿¿ ......

¼¸ÌõÓÐÓõÄSqlÓï¾ä

1. Sql  ÑÓʱºòÖ´ÐÐ
a. ÈýÊ®ÃëºóÖ´ÐÐ WAITFOR DELAY  ºóÃæµÄÓï¾ä
WAITFOR DELAY '00:00:30'
b. 10:00·Ö¿ªÊ¼Ö´ÐкóÃæµÄ´úÂë
WAITFOR TIME '10:00';
 
2.  ÊÕËõÊý¾Ý¿â£¬Ê¹Æä¿ÕÓà¿Õ¼äΪ0%
DBCC SHRINKDATABASE (DataBaseName,0)
3.  È¡µÃÊý¾Ý¿âÎļþËùÔÚµÄÅÌ·û
declare @dirverNam ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ