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

SQL ServerÖÐÁÙʱ±íÓë±í±äÁ¿µÄÇø±ð

ÎÒÃÇÔÚÊý¾Ý¿âÖÐʹÓñíµÄʱºò,¾­³£»áÓöµ½Á½ÖÖʹÓñíµÄ·½·¨,·Ö±ð¾ÍÊÇʹÓÃÁÙʱ±í¼°±í±äÁ¿¡£ÔÚʵ¼ÊʹÓõÄʱºò£¬ÎÒÃÇÈçºÎÁé»îµÄÔÚ´æ´¢¹ý³ÌÖÐÔËÓÃËüÃÇ£¬ËäÈ»ËüÃÇʵÏֵŦÄÜ»ù±¾ÉÏÊÇÒ»ÑùµÄ£¬¿ÉÈçºÎÔÚÒ»¸ö´æ´¢¹ý³ÌÖÐÓÐʱºòȥʹÓÃÁÙʱ±í¶ø²»Ê¹Óñí±äÁ¿£¬ÓÐʱºòȥʹÓñí±äÁ¿¶ø²»Ê¹ÓÃÁÙʱ±íÄØ?
¡¡¡¡ÁÙʱ±í
¡¡¡¡ÁÙʱ±íÓëÓÀ¾Ã±íÏàËÆ£¬Ö»ÊÇËüµÄ´´½¨ÊÇÔÚTempdbÖУ¬ËüÖ»ÓÐÔÚÒ»¸öÊý¾Ý¿âÁ¬½Ó½áÊøºó»òÕßÓÉSQLÃüÁîDROPµô£¬²Å»áÏûʧ£¬·ñÔò¾Í»áÒ»Ö±´æÔÚ¡£ÁÙʱ±íÔÚ´´½¨µÄʱºò¶¼»á²úÉúSQL ServerµÄϵͳÈÕÖ¾£¬ËäËüÃÇÔÚTempdbÖÐÌåÏÖ£¬ÊÇ·ÖÅäÔÚÄÚ´æÖеģ¬ËüÃÇÒ²Ö§³ÖÎïÀíµÄ´ÅÅÌ£¬µ«Óû§ÔÚÖ¸¶¨µÄ´ÅÅÌÀï¿´²»µ½Îļþ¡£
¡¡¡¡ÁÙʱ±í·ÖΪ±¾µØºÍÈ«¾ÖÁ½ÖÖ£¬±¾µØÁÙʱ±íµÄÃû³Æ¶¼ÊÇÒÔ“#”Ϊǰ׺£¬Ö»ÓÐÔÚ±¾µØµ±Ç°µÄÓû§Á¬½ÓÖвÅÊǿɼûµÄ£¬µ±Óû§´ÓʵÀý¶Ï¿ªÁ¬½Óʱ±»É¾³ý¡£È«¾ÖÁÙʱ±íµÄÃû³Æ¶¼ÊÇÒÔ“##”Ϊǰ׺£¬´´½¨ºó¶ÔÈκÎÓû§¶¼ÊǿɼûµÄ£¬µ±ËùÓÐÒýÓøñíµÄÓû§¶Ï¿ªÁ¬½Óʱ±»É¾³ý¡£
¡¡¡¡ÏÂÃæÎÒÃÇÀ´¿´Ò»¸ö´´½¨ÁÙʱ±íµÄÀý×Ó£º¡¡¡¡
       CREATE TABLE dbo.#News
¡¡¡¡(
¡¡¡¡News_id int NOT NULL,
¡¡¡¡NewsTitle varchar(100),
¡¡¡¡NewsContent varchar(2000),
¡¡¡¡NewsDateTime datetime
¡¡¡¡)
¡¡¡¡ÁÙʱ±í¿ÉÒÔ´´½¨Ë÷Òý£¬Ò²¿ÉÒÔ¶¨Òåͳ¼ÆÊý¾Ý£¬ËùÒÔ¿ÉÒÔÓÃÊý¾Ý¶¨ÒåÓïÑÔ(DDL)µÄÉùÃ÷À´×èÖ¹ÁÙʱ±íÌí¼ÓµÄÏÞÖÆ£¬Ô¼Êø£¬²¢²ÎÕÕÍêÕûÐÔ£¬ÈçÖ÷¼üºÍÍâ¼üÔ¼Êø¡£±ÈÈçÀ´Ëµ£¬ÎÒÃÇÏÖÔÚÀ´Îª#News±í×Ö¶ÎNewsDateTimeÀ´Ìí¼ÓÒ»¸öĬÈϵÄGetData()µ±Ç°ÈÕÆÚÖµ£¬²¢ÇÒΪNews_idÌí¼ÓÒ»¸öÖ÷¼ü£¬ÎÒÃǾͿÉÒÔʹÓÃÏÂÃæµÄÓï¾ä£º¡¡
      ALTER TABLE dbo.#News
¡¡¡¡ADD
¡¡¡¡CONSTRAINT [DF_NewsDateTime] DEFAULT (GETDATE()) FOR [NewsDateTime],
¡¡¡¡PRIMARY KEY CLUSTERED
¡¡¡¡(
¡¡¡¡[News_id]
¡¡¡¡) ON [PRIMARY]
¡¡¡¡GO
¡¡¡¡ÁÙʱ±íÔÚ´´½¨Ö®ºó¿ÉÒÔÐÞ¸ÄÐí¶àÒѶ¨ÒåµÄÑ¡Ï°üÀ¨£º
¡¡¡¡1)Ìí¼Ó¡¢Ð޸ġ¢É¾³ýÁС£ÀýÈ磬ÁеÄÃû³Æ¡¢³¤¶È¡¢Êý¾ÝÀàÐÍ¡¢¾«¶È¡¢Ð¡ÊýλÊýÒÔ¼°Îª¿ÕÐÔ¾ù¿É½øÐÐÐ޸ģ¬Ö»ÊÇÓÐһЩÏÞÖƶøÒÑ¡£
¡¡¡¡2)¿ÉÌí¼Ó»òɾ³ýÖ÷¼üºÍÍâ¼üÔ¼Êø¡£
¡¡¡¡3)¿ÉÌí¼Ó»òɾ³ý UNIQUE ºÍ CHECK Ô¼Êø¼° DEFAULT ¶¨Òå(¶ÔÏó)¡£
¡¡¡¡4)¿ÉʹÓà IDENTITY »ò ROWGUIDCOL ÊôÐÔÌí¼Ó»òɾ³ý±êʶ·ûÁС£ËäÈ» ROWGUIDCOL ÊôÐÔÒ²¿ÉÌí¼ÓÖÁÏÖÓÐÁлò´ÓÏÖÓÐÁÐɾ³ý£¬µ«ÊÇÈκÎʱºòÔÚ±íÖÐÖ»ÄÜÓÐÒ»ÁпɾßÓиÃÊôÐÔ
5)±í¼°±íÖÐËùÑ¡¶¨µÄÁÐÒÑ×¢²áΪȫÎ


Ïà¹ØÎĵµ£º

ÔÚ°²×°SQL Server2005 ÎÊÌâÐÅÏ¢£º

"SQL Server °²×°³ÌÐòÎÞ·¨»ñÈ¡ ASPNET ÕÊ»§µÄϵͳÕÊ»§ÐÅÏ¢"
½â¾ö°ì·¨£º
ÓÃaspnet_regiisʵÓù¤¾ßжÔغÍÖØа²×°Ò»Ï¾ͿÉÒÔÁË¡£
¾ßÌåµÄ²Ù×÷£º
1¡¢½øÈëCMD£º
C:\windows\microsoft.net\framework\v2.0.50727Îļþ¼ÐÏ£¬ÔËÐÐaspnet_regiis -uжÔØ
È»ºóÔËÐÐaspnet_regiis -i ÖØа²×°£¬ÉÏÊöÎÊÌâ¼´¿É½â¾ö¡£
2¡¢C:\WINDOWS\ ......

SQL 2000 Insert·µ»Ø×Ô¶¯±àºÅidÈýÖÖ·½·¨±È½Ï


SQL Server 2000ÖУ¬insertÊý¾ÝµÄʱºò·µ»Ø×Ô¶¯±àºÅµÄid£¬ÓÐÈýÖÖ·½·¨ÊµÏÖSCOPE_IDENTITY¡¢IDENT_CURRENT ºÍ @@IDENTITY£¬ËüÃǶ¼·µ»Ø²åÈëµ½ IDENTITY ÁÐÖеÄÖµ¡£
IDENT_CURRENT £º·µ»ØΪÈκλỰºÍÈκÎ×÷ÓÃÓòÖеÄÌض¨±í×îºóÉú³ÉµÄ±êʶֵ¡£IDENT_CURRENT ²»ÊÜ×÷ÓÃÓòºÍ»á»°µÄÏÞÖÆ£¬¶øÊÜÏÞÓÚÖ¸¶¨µÄ±í¡£IDENT_CURRENT ·µ»ØΪÈÎ ......

Linq to SQL DataContext Lifetime Management


Linq to SQL uses a DataContext to manage it's access to the database as well as tracking changes made to entities retrieved from the database. Linq to SQL has a persistent approach to managing its 'connection' to the database via this data context and it basically assumes that you use a single Dat ......

SQLÖÐEXISTSµÄÓ÷¨


±ÈÈçÔÚNorthwindÊý¾Ý¿âÖÐ
ÓÐÒ»¸ö²éѯΪ
SELECT c.CustomerId, CompanyName
from Customers c
WHERE EXISTS(
SELECT OrderID from Orders o
WHERE o.CustomerID = cu.CustomerID)
ÕâÀïÃæµÄEXISTSÊÇÈçºÎÔË×÷ÄØ£¿×Ó²éѯ·µ»ØµÄÊÇOrderId×ֶΣ¬¿ÉÊÇÍâÃæµÄ²éѯҪÕÒµÄÊÇCustomerIDºÍCompanyName×ֶΣ¬ÕâÁ½¸ö×Ö¶Î¿Ï ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ