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

SQL ServerȨÏÞ¹ÜÀí²ßÂÔ ·þÎñÆ÷

SQL ServerȨÏÞ¹ÜÀí²ßÂÔ
Êý¾Ý¿â½¨Á¢Ö®ºó£¬Êý¾ÝµÄ°²È«¾ÍÏÔµÃÓÈΪÖØÒª£¬¶ÔÓÚÒ»¸öÊý¾Ý¿â¹ÜÀíÔ±À´Ëµ£¬°²È«ÐÔ¾ÍÒâζ×ÅËû±ØÐë±£Ö¤ÄÇЩ¾ßÓÐÌØÊâÊý¾Ý·ÃÎÊȨÏÞµÄÓû§Äܹ»µÇ¼µ½SQL Server£¬²¢ÇÒÄܹ»·ÃÎÊÊý¾ÝÒÔ¼°¶ÔÊý¾Ý¿â¶ÔÏóʵʩ¸÷ÖÖȨÏÞ·¶Î§ÄڵIJÙ×÷£»Í¬Ê±£¬Ëû»¹Òª·ÀÖ¹ËùÓеķÇÊÚȨÓû§µÄ·Ç·¨²Ù×÷¡£Õý»ùÓÚ´Ë£¬SQL Server 2000ÌṩÁ˼ÈÓÐЧÓÖÈÝÒ׵ݲȫ¹ÜÀíģʽ£¬ÕâÖÖ°²È«¹ÜÀíģʽÊǽ¨Á¢ÔÚ°²È«ÕÊ»§ÈÏÖ¤ºÍ·ÃÎÊÐí¿ÉÁ½Õß»úÖÆÉϵġ£
Ò»¡¢°²È«ÕÊ»§ÈÏÖ¤
°²È«ÕÊ»§ÈÏÖ¤ËäÓÃÀ´È·ÈϵǼSQL ServerµÄÓû§µÄµÇ¼ÕÊ»§ºÍÃÜÂëµÄÕýÈ·ÐÔ£¬ÓÉ´ËÀ´ÑéÖ¤¸ÃÓû§ÊÇ·ñ¾ßÓÐÁ¬½ÓSQL ServerµÄȨÏÞ¡£ÈκÎÓû§ÔÚʹÓÃSQL ServerÊý¾Ý¿â֮ǰ£¬±ØÐë¾­¹ý°²È«ÕÊ»§ÈÏÖ¤¡£SQL Server 2000ÌṩÁËÁ½ÖÖÈ·ÈÏÓû§µÄÈÏ֤ģʽ£º¼´Windows NTÈÏ֤ģʽºÍ»ìºÏÈÏ֤ģʽ¡£
SQL ServerÊý¾Ý¿âϵͳͨ³£ÔËÐÐÔÚWindows NT·þÎñÆ÷ƽ̨ÉÏ£¬¶øNT×÷ΪÍøÂç²Ù×÷ϵͳ£¬±¾Éí¾Í¾ß±¸¹ÜÀíµÇ¼¡¢ÑéÖ¤Óû§ºÏ·¨ÐÔµÄÄÜÁ¦£¬Òò´ËWindows NTÈÏ֤ģʽÕýÊÇÀûÓÃÁËÕâÒ»Óû§°²È«ÐÔºÍÕʺŹÜÀíµÄ»úÖÆ£¬ÔÊÐíSQL ServerÒ²¿ÉÒÔʹÓÃNTµÄÓû§ÃûºÍ¿ÚÁî¡£ÔÚÕâÖÖģʽÏ£¬Óû§Ö»ÐèҪͨ¹ýWindows NTµÄÈÏÖ¤£¬¾Í¿ÉÒÔÁ¬½Óµ½SQL Server£¬ÕâÑùSQL Server±¾ÉíÒ²¾Í²»ÐèÒª¹ÜÀíÒ»Ì׵ǼÊý¾Ý¡£
»ìºÏÈÏ֤ģʽÔÊÐíÓû§Ê¹ÓÃNT°²È«ÐÔ»òSQL Server°²È«ÐÔÁ¬½Óµ½SQL Server£¬Õâ¾ÍÒâζ×ÅÓû§¿ÉÒÔʹÓÃËûµÄÕʺŵǼµ½Windows NT£¬»òÕßʹÓÃËûµÄµÇ¼ÃûµÇ¼µ½SQL Serverϵͳ¡£NTµÄÓû§¼È¿ÉÒÔʹÓÃNTÈÏÖ¤£¬Ò²¿ÉÒÔʹÓÃSQL ServerÈÏÖ¤¡£¶øWindows 9xϵÁвÙ×÷ϵͳµÄÓû§Ö»ÄÜʹÓÃSQL ServerÈÏ֤ģʽ£»ÔÚ¸ÃÈÏ֤ģʽÏ£¬Óû§ÔÚÁ¬½ÓSQL Serverʱ±ØÐëÌṩµÇ¼ÃûºÍµÇ¼ÃÜÂ룬ÕâЩµÇ¼ÐÅÏ¢´æ´¢ÔÚϵͳ±ísysloginsÖУ¬ÓëNTµÄµÇ¼ÕʺÅÎ޹ء£SQL Server×ÔÉíÖ´ÐÐÈÏÖ¤´¦Àí£¬Èç¹ûÊäÈëµÄµÇ¼ÐÅÏ¢Óëϵͳ±ísysloginsÖеÄijÌõ¼Ç¼ÏàÆ¥Å䣬Ôò±íÃ÷µÇ¼³É¹¦¡£
Òª¶ÔµÇ¼½øÐÐÔö¼Ó¡¢É¾³ýµÈ²Ù×÷£¬Ê×ÏȱØÐëÉèÖÃSQL ServerµÄÈÏ֤ģʽ¡£ÀûÓÃÆóÒµ¹ÜÀíÆ÷¿ÉÒÔ½øÐÐÈÏ֤ģʽµÄÉèÖá£ÆäÖ÷Òª¹ý³ÌÈçÏ£º
(1)´ò¿ªÆóÒµ¹ÜÀíÆ÷£¬ÓÒ»÷ÒªÉèÖÃģʽµÄ·þÎñÆ÷£¬´Ó²Ëµ¥ÖÐÑ¡Ôñ“ÊôÐÔ”£»
(2)ÔÚÊôÐÔ¶Ô»°¿òÖÐÑ¡Ôñ“°²È«ÐÔ”£»
(3)ÔÚ“Éí·ÝÑéÖ¤”ÖÐÑ¡ÔñÒªÉèÖõÄÈÏ֤ģʽ£¬Í¬Ê±ÔÚ“ÉóºË¼¶±ð”Öл¹¿ÉÒÔÑ¡Ôñ¸ú×ټǼÓû§µÇ¼ʱµÄÄÄÖÖÐÅÏ¢£¬ÈçµÇ¼³É¹¦»òʧ°ÜµÄÐÅÏ¢£»
(4)ÔÚ“Æô¶¯·þÎñÕÊ»§”ÖÐÉèÖõ±Æô¶¯²¢ÔËÐÐSQLServerʱ£¬Ä¬ÈϵĵǼÕßÖÐÄÄһλÓû§,RAID1¡£
¶þ¡¢·ÃÎÊÐí¿ÉÈ·ÈÏ
ͨ¹


Ïà¹ØÎĵµ£º

³£ÓÃSQLÓï¾äÊÕ¼¯

1.ɾ³ý±í
  select 'drop table ' || table_name || ' purge;'
  from user_tables
  where length(table_name) <= 4;
    ɾ³ý´øÔ¼ÊøµÄ±í
    Drop table ±íÃû cascade  constraints;
2.²éѯview&ͬÒå´Ê
   --˵Ã÷£º¿ÉÒÔ¸ù¾ÝÊÓͼµÄtext_length ......

SQL Server 2008±íÉè¼ÆÆ÷ÖÐÎÞ·¨±£´æÐÞ¸Ä

µ±Ê¹ÓÃMicrosoft SQL Server 2008 Management Studioʱ£¬ÓÐʱÔÚ±íÉè¼ÆÆ÷ÖжԱíËù×öµÄ¸ü¸ÄÎÞ·¨±£´æ£¬¾ßÌå±íÏÖΪ£ºµã»÷±£´æ°´Å¥ºóµ¯³ö±£´æ¶Ô»°¿òÌáʾ£º²»ÔÊÐí±£´æÐÞ¸Ä(Saving changes is not permitted)£¬µ¯³öµÄ¶Ô»°¿òÖ»ÓÐ2¸ö°´Å¥¿ÉÒÔµã»÷£¬Ò»¸öCancelÒ»¸öSave Text File£¬Ç°Ò»¸ö¾Í²»ÓÃ˵ÁË£¬ºóÒ»¸ö±£´æµÄÎļþ¸ù±¾Ã»ÒâÒ壨¿ÉÒ ......

Flat hierarchyid in SQL Server 2008

ÔÚSQL Server 2008ÖÐÒýÈëÁËhierarchyidÀ´´¦ÀíÊ÷×´½á¹¹¡£ÏÂÃæ¼òµ¥¾ÍÒÔAdventureWorks(ÎÞhierarchyid)ºÍAdventureWorks2008(ÓÐhierarchyid)ÀïµÄHumanResources.EmployeeΪÀý£¬À´ËµÃ÷Ò»ÏÂÔÚеÄhierarchyidÖÐÈçºÎ½øÐÐflat»¯µÄdimension³éÈ¡¡£
AdventureWorksÊÇ΢ÈíΪSQL ServerÌṩµÄÊý¾Ý¿âÐéÄâ°¸Àý¡£
AdventureWorksÖÐËùÒªµ ......

sql ²éѯ±íµÄÁÐÃû row_number()

select upper(name) from syscolumns
where id =any
(
select Id from sysobjects where name='tb_city'
)
lower
select row_number() over(order by firmid) from dbo.tb_BuildingMaterial
Éú³É  ×ÔÔö  123
select rank() over(order by firmid) from dbo.tb_BuildingMaterial
Éú³É×ÔÔö123  ¸ù¾ÝÅ ......

C#ÖÐÓÃÓÚÁ¬½ÓSQLÊý¾Ý¿âµÄSQLHelperÀà

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;   //ÒýÓÃÃüÃû¿Õ¼ä
namespace DAL
{
    /*******************************************************************************
  &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ