sql serverµÄ¸´ÖƺͶ©ÔÄ
×î½üÓöµ½Ò»¸öÏîÄ¿£¬¿Í»§ÔÚ×ܲ¿Â¼ÈëÐÅÏ¢ºó£¬Êý¾ÝÐèҪͬ²½µ½ÏÂÊôµÄÈô¸É¸ö×ÓϵͳÖС£ÏÖÔÚ×ܲ¿µ¥¶ÀʹÓÃÒ»¸öÊý¾Ý¿â£¬ÏÂÊôµ¥Î»¸÷×ÔʹÓÃ×Ô¼ºµÄÊý¾Ý¿â¡£
¶ÔÓÚÕâ¸öÎÊÌ⣬Ïëµ½Á˼¸¸ö½â¾ö·½°¸£º
1¡¢×Ô¼ºÐ´´úÂë½â¾ö¡£¶¨ÒåºÃ·ÃÎÊÿ¸öÊý¾ÝµÄÁ¬½Ó×Ö·û´®£¬×ܲ¿Ìí¼ÓÊý¾Ýʱ£¬Í¬Ê±Ð´ÈëÆäËûËùÓÐÊý¾Ý£¬Ð޸ģ¬É¾³ýµÄҲͬʱ½øÐС£Õâ¸ö·½·¨ÓÐÒ»¸öÓŵãÁ½¸öȱµã£º
Óŵ㣺˼·¼òµ¥£¬×öÆðÀ´Ò²²»ÄÑ£»
ȱµã£ºa¡¢Êý¾ÝÍêÕûÐÔºÍÓÐЧÐÔ²»ºÃ±£ÕÏ£»
b¡¢´úÂë·±Ëö£¬¹¤×÷Á¿´ó£»
2¡¢Ê¹ÓÃÊý¾Ý¿â±¾ÉíµÄ¸´Öƹ¦ÄÜ¡£ÒÔǰûÓÐÓùýÕâ¸ö¹¦ÄÜ£¬ÔÚÍøÉϲéÁ˲é×ÊÁÏ£¬ÓÃÁËÁ½Ììʱ¼ä£¬¶ÔÕâ¸ö¶«Î÷ÓÐÁ˳õ²½µÄÁ˽⡣ÒÔÏÂתÔØ×Þ´ó¸ç£¬ÒԱ㽫À´²éÔÄ£º
¸´ÖÆÊǽ«Ò»×éÊý¾Ý´ÓÒ»¸öÊý¾ÝÔ´¿½±´µ½¶à¸öÊý¾ÝÔ´µÄ¼¼Êõ£¬Êǽ«Ò»·ÝÊý¾Ý·¢²¼µ½¶à¸ö´æ´¢Õ¾µãÉϵÄÓÐЧ·½Ê½¡£Ê¹Óø´ÖƼ¼Êõ£¬Óû§¿ÉÒÔ½«Ò»·ÝÊý¾Ý·¢²¼µ½¶ą̀·þÎñÆ÷ÉÏ£¬´Ó¶øʹ²»Í¬µÄ·þÎñÆ÷Óû§¶¼¿ÉÒÔÔÚȨÏÞµÄÐí¿ÉµÄ·¶Î§ÄÚ¹²ÏíÕâ·ÝÊý¾Ý¡£¸´ÖƼ¼Êõ¿ÉÒÔÈ·±£·Ö²¼ÔÚ²»Í¬µØµãµÄÊý¾Ý×Ô¶¯Í¬²½¸üУ¬´Ó¶ø±£Ö¤Êý¾ÝµÄÒ»ÖÂÐÔ¡£
SQL¸´ÖƵĻù±¾ÔªËØ°üÀ¨
³ö°æ·þÎñÆ÷£ºÊý¾ÝÔ´ËùÔڵķþÎñÆ÷¡£ÓÌÈçͼÊé³ö°æÉ磻
¶©ÔÄ·þÎñÆ÷£ºÐèҪͬ²½Êý¾ÝµÄ·þÎñÆ÷£¬ÓÌÈçͼÊ鶩ÔÄÕߣ¬Í¼Êé¹Ý£¬ÊéµêµÈ£»
·Ö·¢·þÎñÆ÷£º°ÑÊý¾Ý´ÓÊý¾ÝÔ´¸´ÖƵ½Ä¿±êÊý¾Ý¿âµÄ·þÎñÆ÷£¬ÓÌÈçÓʾ֣¬¿ìµÝ¹«Ë¾£»
³ö°æÎҪ¸´ÖƵÄÊý¾ÝµÄ¼¯ºÏ£¬ÓÌÈçijÅúͼÊ飻
ÎÄÕ £ºÒª¸´ÖƵÄÊý¾ÝÏîÄ¿£¬ÓÌÈçijÌ×ͼÊ飻
SQL¸´ÖƵŤ×÷ÔÀí
SQL SERVER Ö÷Òª²ÉÓóö°æÎï¡¢¶©Ôĵķ½Ê½À´´¦Àí¸´ÖÆ¡£Ô´Êý¾ÝËùÔڵķþÎñÆ÷Êdzö°æ·þÎñÆ÷£¬¸ºÔð·¢±íÊý¾Ý¡£³ö°æ·þÎñÆ÷°ÑÒª·¢±íµÄÊý¾ÝµÄËùÓиıäÇé¿öµÄ¿½±´¸´ÖƵ½·Ö·¢·þÎñÆ÷£¬·Ö·¢·þÎñÆ÷°üº¬ÓÐÒ»¸ö·Ö·¢Êý¾Ý¿â£¬¿É½ÓÊÕÊý¾ÝµÄËùÓиı䣬²¢±£´æÕâЩ¸Ä±ä£¬ÔÙ°ÑÕ
Ïà¹ØÎĵµ£º
ROW_NUMBER ·µ»Ø°´Ò»¶¨¹æÔòÅÅÐòµÄµ±Ç°¼Ç¼¶ÔÓ¦µÄÐкÅ
±ÈÈçÎÒÃÇÓÐÕâÑùÒ»¸öÓ¦Óó¡¾°£º
ÏÖÔÚÓиö±ÈÈü£¬ÐèÒª´ÓÍøÉϲÎÈüÕß´Ó´ÓÍøÂçÉϱ¨Ãû£¬È»ºóÈ¥×îÔ籨ÃûµÄ5¸öÈ˲μӱÈÈü£¬Îª´ËÎÒÃÇʵÏÖÈçÏ£º
1.Ϊ´ËÎÒÃÇÒª½¨Á¢Ò»ÕűíÀ´±£´æ±¨Ãû²ÎÈüÕßµÄÐÕÃû¼°Æð±¨Ãûʱ¼ä
CREATE
TABLE [dbo].[UserEnroll](
[UserName] [nvarchar] ......
Ò»¡¢»ù´¡
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¡¢Ëµ ......
·ÖÀàͳ¼Æ×ÜÊý²¢ÅÅÐò¶à±íÁªºÏ²éѯµÄÁ½ÖÖ·½·¨
Àý:
²éѯµØÇø±íÖи÷Ê¡ÏÂÃæ³ÇÊÐ×ÜÊý,²¢¶Ô²éѯ½á¹ûÈ¡Ç°Ê®Ãû
·¨Ò»:
select b.id,a.[name],b.counts from n_area a,(select top 10 parent_id as id,sum(parent_id) as counts from n_area where parent_id<>0 group by parent_id order by sum(parent_id) desc
) b where ......
DECLARE @T varchar(255),
@C varchar(255)
DECLARE Table_Cursor CURSOR FOR
Select
a.name,b.name
from sysobjects a,
syscolumns b
where a.id=b.id and
a.xtype='u' and
(b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167)
OPEN Table_Cursor
FETCH NEXT from Table_Cursor INTO @T,@C
WHILE(@@FET ......