¾«ÃîSqlÓï¾ä
1£® ÅжÏa±íÖÐÓжøb±íÖÐûÓеļǼ
select a.* from tbl1 a
left join tbl2 b
on a.key = b.key
where b.key is null
ËäȻʹÓÃinÒ²¿ÉÒÔʵÏÖ£¬µ«ÊÇÕâÖÖ·½·¨µÄЧÂʸü¸ßһЩ
2£® н¨Ò»¸öÓëij¸ö±íÏàͬ½á¹¹µÄ±í
select * into b
from a where 1<>1
3£®betweenµÄÓ÷¨,betweenÏÞÖÆ²éѯÊý¾Ý·¶Î§Ê±°üÀ¨Á˱߽çÖµ,not between²»°üÀ¨
select * from table1 where time between time1 and time2
select a,b,c, from table1 where a not between ÊýÖµ1 and ÊýÖµ2
4. ˵Ã÷£º°üÀ¨ËùÓÐÔÚ TableA Öе«²»ÔÚ TableBºÍTableC ÖеÄÐв¢Ïû³ýËùÓÐÖØ¸´ÐжøÅÉÉú³öÒ»¸ö½á¹û±í
(select a from tableA ) except (select a from tableB) except (select a from tableC)
5. ³õʼ»¯±í£¬¿ÉÒÔ½«×ÔÔö³¤±íµÄ×ÖÔö³¤×Ö¶ÎÖÃΪ1
TRUNCATE TABLE table1
6£®¶àÓïÑÔÉèÖÃÊý¾Ý¿â»òÕß±í»òÕßorder byµÄÅÅÐò¹æÔò
--ÐÞ¸ÄÓû§Êý¾Ý¿âµÄÅÅÐò¹æÔò
ater database dbname collate SQL_Latin1_General_CP1_CI_AS
--ÐÞ¸Ä×ֶεÄÅÅÐò¹æÔò
alter table a alter column c2 varchar(50) collate SQL_Latin1_General_CP1_CI_AS
--°´ÐÕÊϱʻÅÅÐò
select * from ±íÃû order by ÁÐÃû Collate Chinese_PRC_Stroke_ci_as
--°´Æ´ÒôÊ××ÖĸÅÅÐò
select * from ±íÃû order by ÁÐÃû Collate Chinese_PRC_CS_AS_KS_WS
7£®ÁгöËùÓеÄÓû§Êý¾Ý±í£º
SELECT TOP 100 PERCENT o.name AS ±íÃû
from dbo.syscolumns c INNER JOIN
dbo.sysobjects o ON o.id = c.id AND objectproperty(o.id, N'IsUserTable') = 1 AND
o.name <> 'dtproperties' LEFT OUTER JOIN
dbo.sysproperties m ON m.id = o.id AND m.smallid = c.colorder
WHERE (c.colid = 1)
ORDER BY o.name, c.colid
8£®ÁгöËùÓеÄÓû§Êý¾Ý±í¼°Æä×Ö¶ÎÐÅÏ¢£º
SELECT TOP 100 PERCENT c.colid AS ÐòºÅ, o.name AS ±íÃû, c.name AS ÁÐÃû,
t.name AS ÀàÐÍ, c.length AS ³¤¶È, c.isnullable AS ÔÊÐí¿Õ,
CAST(m.[value] AS Varchar(100)) AS ˵Ã÷
from dbo.syscolumns c INNER JOIN
dbo.sysobjects o ON o.id = c.id A
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃæ£¬ºóÃæ ......
Ëæ×ÅB/SģʽӦÓÿª·¢µÄ·¢Õ¹£¬Ê¹ÓÃÕâÖÖģʽ±àдӦÓóÌÐòµÄ³ÌÐòÔ±Ò²Ô½À´Ô½¶à¡£µ«ÊÇÓÉÓÚ³ÌÐòÔ±µÄˮƽ¼°¾ÑéÒ²²Î²î²»Æë£¬Ï൱´óÒ»²¿·Ö³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºò£¬Ã»ÓжÔÓû§ÊäÈëÊý¾ÝµÄºÏ·¨ÐÔ½øÐÐÅжϣ¬Ê¹Ó¦ÓóÌÐò´æÔÚ°²È«Òþ»¼¡£Óû§¿ÉÒÔÌá½»Ò»¶ÎÊý¾Ý¿â²éѯ´úÂ룬¸ù¾Ý³ÌÐò·µ»ØµÄ½á¹û£¬»ñµÃijЩËûÏëµÃÖªµÄÊý¾Ý£¬Õâ¾ÍÊÇËùνµÄSQL Inj ......
SQL> var v_str varchar2(100);
SQL> exec :v_str:=',id1,id11,id101,';
PL/SQL procedure successfully completed.
SQL> select :v_str a,replace(:v_str,',','') b
2 ,substr(:v_str,instr(:v_str,',',1,rownum)+1,
3 instr(:v_str,',',1,rownum+1)-ins ......
´óÁ¿µÄÏÖ´úÆóÒµ²ÉÓÃWebÓ¦ÓóÌÐòÓëÆä¿Í»§ÎÞ·ìµØÁ¬½Óµ½Ò»Æð£¬µ«ÓÉÓÚ²»ÕýÈ·µÄ±àÂ룬Ôì³ÉÁËÐí¶à°²È«ÎÊÌâ¡£WebÓ¦ÓóÌÐòÖеÄ©¶´¿ÉʹºÚ¿Í»ñÈ¡¶ÔÃô¸ÐÐÅÏ¢£¨Èç¸öÈËÊý¾Ý¡¢µÇ¼ÐÅÏ¢µÈ£©µÄÖ±½Ó·ÃÎÊ¡£
WebÓ¦ÓóÌÐò×¼Ðí·ÃÎÊÕßÌá½»Êý¾Ý£¬²¢¿Éͨ¹ý»¥ÁªÍø´ÓÊý¾Ý¿âÖмìË÷Êý¾Ý¡£¶øÊý¾Ý¿âÊǶàÊýWebÓ¦ÓóÌÐòµÄÐÄÔà¡£Êý¾Ý¿âά³Ö×ÅWebÓ¦ÓóÌÐò½«Ì ......
1 --ÏÂÃæµÄ´úÂëÉú³É³¤¶ÈΪ8µÄ±àºÅ£¬±àºÅÒÔBH¿ªÍ·£¬ÆäÓà6λΪÁ÷Ë®ºÅ¡£
2 --µÃµ½Ð±àºÅµÄº¯Êý
3 CREATE FUNCTION f_NextBH()
4 RETURNS char(8)
5 AS
6 BEGIN
7 RETURN(SELECT 'BH'+RIGHT(1000001+ISNULL(RIGHT(MAX(BH),6),0),6) from tb WITH(XLOCK,PAGLOCK))
8 END
9 GO
10
11 --ÔÚ±íÖÐ ......