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

SQL server×Ó²éѯ

exec xp_cmdshell 'md E:\project'
--ÏÈÅжÏÊý¾Ý¿âÊÇ·ñ´æÔÚÈç¹û´æÔÚ¾Íɾ³ý
if exists(select * from sysdatabases where name='bbsDB')
drop database bbsDB
--´´½¨Êý¾Ý¿âÎļþ
create database bbsDB
--Ö÷Êý¾Ý¿âÎļþ
 on primary
(
 name='bbsDB_data',--ΪÖ÷ÒªÊý¾Ý¿âÎļþÃüÃû
 filename='E:\project\bbsDB_data.mdf',--Ö÷Êý¾Ý¿âÎļþµÄ·¾¶
 size=10mb--³õʼ´óС
)
log on(
--ÈÕÖ¾Îļþ
 name='bbsDB_log',
 filename='E:\project\bbsDB_log.ldf',
 size=3mb,
 maxsize=20mb--×î´óÔö³¤Á¿Îª
)
go
use bbsDB
drop table BBSUsers
create table BBSUsers(
 UID   int identity(1,1) primary key  not null,--±êʶÁÐ×ÔÔö³¤
 UName   varchar(15)  not null,--Óû§Ãû£¬êdzÆ
 UPassword  varchar(16)   not null,--ÃÜÂë²»ÄÜÉÙÓÚ6λÊýĬÈÏΪ£¨888888£©
 USex   bit    not null,--ÐÔ±ð1´ú±íÄР
 UEmail  varchar(20)       null, --µç×ÓÓʼþ±ØÐë°üº¬@ĬÈÏֵΪ£¨P@P.com£©
 UClass   int    not null,--Óû§µÄµÈ¼¶(1)
 UregDate datetime      null,--×¢²áÈÕÆÚ£¨×¢²áʱϵͳʱ¼ä£©
 Uremark  varchar(255)      null, --±¸×¢ÐÅÏ¢£¨±¸×¢£©
 Upoint  int   not null,--Óû§µÄ»ý·Ö£¬µãÊý£¨20£©
 UBirthday   datetime       null,--Óû§ÉúÈÕ
 Ustate  int       null--״̬£¨0ĬÈÏΪÀëÏߣ©
)
go
select UPassword from BBSUsers
alter table BBSUsers-- ΪÃÜÂëÌí¼Ó¼ì²éÔ¼Êø³¤¶È´óÓÚ=6µÄ³¤¶È
 add constraint CK_upassword check(len(UPassword)>=6)
alter table BBSUsers--ΪÃÜÂëÌí¼ÓĬÈÏÔ¼Êø(888888)
 add constraint DE_upassword default ('888888') for UPassword
alter table BBSUsers--Email¼ì²éÔ¼Êø@
 add constraint CK_uemail check (UEmail like '%@%')
alter table BBSUsers--ΪE-mailÌí¼ÓĬÈÏÔ¼ÊøP@P.com
 add constraint DE_uemail default('P@P.co


Ïà¹ØÎĵµ£º

SQL SERVER2008Êý¾ÝÍÚ¾ò


¸ÅÊö
Microsoft SQL Server 2008 ÈÃÄúÄܹ»Í¨¹ýÖ±¹ÛµÄÊý¾ÝÍÚ¾òµÄÔ¤²âÐÔ·ÖÎöÀ´×ö³öÃ÷ÖǺÏÀíµÄ¾ö²ß£¬ÎÞ·ìµØÕûºÏ Microsoft ÉÌÒµÖÇÄÜƽ̨²¢¿ÉÀ©Õ¹ÖÁÉÌÒµÓ¦ÓóÌÐò¡£
ÖØ´óµÄй¦ÄÜ
ͬʱÀûÓôíÎóºÍ¾«È·¶ÈµÄͳ¼Æ·ÖÊýÀ´²âÊÔ¶à¸öÊý¾ÝÍÚ¾òÄ£ÐÍ£¬²¢ÀûÓý»²æÑéÖ¤À´È·ÈÏÆäÎȶ¨ÐÔ
ÔÚµ¥Ò»½á¹¹Öн¨Á¢¶à¸ö²»¼æÈݵÄÍÚ¾òÄ£ÐÍ¡¢ÔÚɸѡ¹ýµÄÊ ......

SQl 2005 For XMl ¼òµ¥²éѯ(Raw£¬Auto£¬Pathģʽ)(2)

ÎÄÕµ¼º½ SQL Server 2005 ѧϰ±Ê¼ÇϵÁÐÎÄÕµ¼º½
     ÔÚSQl 2005 For XMl ¼òµ¥²éѯ(Raw£¬Auto£¬Pathģʽ)(1) ÀïÎÒÃÇ˵Á˹ØÓÚPath£¬RawºÍAutoģʽµÄÓ÷¨£¬ÆäʵÀïÃæ²»½ö½ö ÊÇÕâЩ¼òµ¥µÄ²Ù×÷£¬»¹ÓÐһЩÆäËüµÄÌØÐÔ£¬±ÈÈç˵Type»òOpenXml·½·¨£¬sp_xml_preparedocument´æ´¢¹ý³Ì µÈÕâЩÔö¼ÓµÄ¶«¶«£¬ÎÒÃÇÀ´Ò» ......

SQL server 2005(´æ´¢¹ý³Ì)


Ò»£®¸ÅÊö
   ´æ´¢¹ý³ÌÊÇÒ»×éÔ¤ÏȱàÒëºÃµÄT--SQL´úÂ룬ǿµ÷Ò»µã£ºÕâЩ´úÂëÊÇÔ¤±àÒëºÃµÄ£¬¼´ÔÚÖ´ÐÐʱ¾Í²»ÓÃÔÚ½øÐбàÒëÁË£¬ÕâÑù»áÌá¸ß³ÌÐòµÄÔËÐÐЧÂÊ¡£ËüÀàËÆÓÚÆäËû¸ß¼¶ÓïÑÔÀïµÄ¹ý³Ì£¬¼´Íê³ÉÌض¨¹¦Äܵĺ¯Êý¡£´æ´¢¹ý³Ì·ÖÁ½ÀࣺϵͳÌṩµÄ´æ´¢¹ý³Ì£¬Óû§×Ô¼º¶¨ÒåµÄ´æ´¢¹ý³Ì£¬ÏµÍ³¶¨ÒåµÄÒÔ sp_Ϊǰ׺¡£
¶ ......

SQL·ÖÒ³¼¼Êõ

±¾ÎÄÀ´×Ô£ºhttp://niunan.javaeye.com/blog/264197
±È½ÏÍòÄܵķÖÒ³£º
select top Ã¿Ò³ÏÔʾµÄ¼Ç¼Êý * from topic where id not in  
(select top £¨µ±Ç°µÄÒ³Êý-1£©×ÿҳÏÔʾµÄ¼Ç¼Êý id from topic order by id& ......

sqlÉú³É½Å±¾ÀïSET ANSI_NULLS ONʲôÒâ˼

±¾ÎÄÀ´×Ô£ºhttp://zhidao.baidu.com/question/27978123.html?si=1
ÕâЩÊÇ SQL-92 ÉèÖÃÓï¾ä£¬Ê¹ SQL Server 2000/2005 ×ñ´Ó SQL-92 ¹æÔò¡£
µ± SET QUOTED_IDENTIFIER Ϊ ON ʱ£¬±êʶ·û¿ÉÒÔÓÉË«ÒýºÅ·Ö¸ô£¬¶øÎÄ×Ö±ØÐëÓɵ¥ÒýºÅ·Ö¸ô¡£µ± SET QUOTED_IDENTIFIER Ϊ OFF ʱ£¬±êʶ·û²»¿É¼ÓÒýºÅ£¬ÇÒ±ØÐë·ûºÏËùÓÐ Transact-SQL ±êÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ