¾«Ãî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
Ïà¹ØÎĵµ£º
°´Ö¸¶¨´ÎÊýÖظ´×Ö·û±í´ïʽ¡£
Óï·¨
REPLICATE ( character_expression, integer_expression)
²ÎÊý
character_expression
×Ö·ûÊý¾ÝÐ͵Ä×ÖĸÊý×Ö±í´ïʽ£¬»òÕß¿ÉÒÔÒþʽת»»Îª nvarchar »ò ntext µÄÆäËûÊý¾ÝÀàÐ͵Ä×ÖĸÊý×Ö±í´ïʽ¡£
integer_expression
¿ÉÒÔÒþʽת»»Îª int µÄ±í´ïʽ¡£Èç¹û integer_expression Ϊ ......
±¾ÊµÀýÒ»Ì×ÈËʹÜÀíϵͳ£º¿ª·¢¹¤¾ßΪVFP9.0¡¢SQL2000¡¢EXCEL;ʹÓÃÁËAdobe PhotoshopƽÃæÉè¼ÆÈí¼þ£¬²ÉÓÃÁËSPT´©Í¸¼¼Êõ£¬µ÷ÓÃÁËAPIº¯Êý£¬ÊµÏÖÁ˶Ôϵͳʱ¼äµÄͳһ¿ØÖÆ¡¢¶ÔDNSµÄ´úÂë¿ØÖÆ¡¢¶ÔÓòÃû½âÎöµÄÓ¦Ó㬵ȵÈ
ÔΣ¬ÔõôÉÏ´«£¬£¨°üº¬Ô´Âëδ±àÒëµÄ£©ÏëÒªµÄ¸øÎÒ·¢E-MAIL:zhao@tom.com ......
SQL ServerÁ¬½ÓÖеÄËĸö×î³£¼û´íÎó:
Ò»."SQL Server ²»´æÔÚ»ò·ÃÎʱ»¾Ü¾ø"
Õâ¸öÊÇ×ÔÓµÄ,´íÎó·¢ÉúµÄÔÒò±È½Ï¶à,ÐèÒª¼ì²éµÄ·½ÃæÒ²±È½Ï¶à.
Ò»°ã˵À´,ÓÐÒÔϼ¸ÖÖ¿ÉÄÜÐÔ:
1,SQL ServerÃû³Æ»òIPµØַƴдÓÐÎó
2,·þÎñÆ÷¶ËÍøÂçÅäÖÃÓÐÎó
3,¿Í»§¶ËÍøÂçÅäÖÃÓÐÎó
Òª½â¾öÕâ¸öÎÊÌâ,ÎÒÃÇÒ»°ãÒª×ñÑÒÔϵIJ½ÖèÀ´Ò»²½²½ÕÒ³öµ¼Ö´íÎóµ ......
Èç¹ûÄãÕýÔÚ¸ºÔðÒ»¸ö»ùÓÚSQL ServerµÄÏîÄ¿£¬»òÕßÄã¸Õ¸Õ½Ó´¥SQL Server£¬Ä㶼ÓпÉÄÜÒªÃæÁÙһЩÊý¾Ý¿âÐÔÄܵÄÎÊÌ⣬ÕâƪÎÄÕ»áΪÄãÌṩһЩÓÐÓõÄÖ¸µ¼£¨ÆäÖдó¶àÊýÒ²¿ÉÒÔÓÃÓÚÆäËüµÄDBMS£©¡£
ÔÚÕâÀÎÒ²»´òËã½éÉÜʹÓÃSQL ServerµÄÇÏÃÅ£¬Ò²²»ÄÜÌṩһ¸ö°üÖΰٲ¡µÄ·½°¸£¬ÎÒËù×öµÄÊÇ×ܽáһЩ¾Ñé----¹ØÓÚÈçºÎÐγÉÒ»¸öºÃµÄÉè¼Æ¡£Õ ......
SELECT
(case when a.colorder=1 then d.name else '' end)±íÃû,
a.colorder ×Ö¶ÎÐòºÅ,
a.name ×Ö¶ÎÃû,
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity ......