ÔõÑù²ÅÄÜʵÏÖÅÅÐòÓÅ»¯µÄ²ã´Î¹Øϵ±íÉè¼Æ_SQL¼¼ÇÉ
Êý¾Ý²ã´ÎµÄ¸ÅÄî:
Êý¾Ý²ã´ÎÊDZí´ïÊý¾ÝµÄÒ»ÖÖÖØÒª¹Øϵ£¬ÔÚÊý¾Ý¿âµÄÉè¼ÆÖУ¬È磺×éÖ¯½á¹¹·Ö½â¡¢¹¤×÷ÈÎÎñ·Ö½â¡¢ÐÐÕþÇø»®µÄ·Ö½âµÈ¶¼ÊDzã´Î¹ØϵÊý¾ÝµÄµäÐÍʵÀý¡£
±í´ï²ã´Î¹ØϵµÄÊý¾ÝÒ»°ãÐèҪʵÏÖÈçÏÂÊôÐÔ£º
1.²ã´ÎµÄ×î´ó¼¶Áª²ã´ÎÊý¡£È磺Öйú£>ºþÄÏÊ¡->³¤É³ÊÐ->Ó껨Çø£¬¾ÍÊÇ4²ã¡£
2.ÄÜ·´Ó³Í¬Ò»²ã´ÎÖ®¼äµÄ˳Ðò¹Øϵ¡£È磺³¤É³ÊÐ ±ØÐëÔÚ ºâÑôÊеÄÇ°Ã棬£¨ÒòΪÆäÊÇÊ¡»á£©¡£
3.ÄÜ»ñÈ¡ÈÎÒâ²ã´ÎµÄ¸¸½Úµã¼¶×ӽڵ㣨×ӽڵ㼯£©¡£
4.Ö±½Ó»ñÈ¡ÈÎÒâ²ã´ÎµÄÊý¾Ý¡£±ÈÈ磺µÚÈý²ã Ê춱ðµÄÊý¾Ý¡£
5.ÄÜ·½±ã¹¹Ôì²ã´Î¹Øϵ±í´ïÊ÷¡£
6.²ã´Î½á¹¹¼°ÅÅÐò·½Ê½µÄ¸Ä±ä²»Ó°ÏìÆäÆäËûÊý¾ÝµÄÄÚ²¿Âß¼¹Øϵ¡£
Ò»°ãÓÐÈýÖÖ·½Ê½À´±íÏÖ²ã´Î¹ØϵµÄÊý¾Ý£º
1.½¨Á¢¶à¸öÊý¾Ý¿â±í£º
È磺 COUNTRY: ID(Ö÷¼ü) COUNTRY_NAME
PROVINCE: ID(Ö÷¼ü) COUNTRY_ID£¨Íâ¼ü£©,PROVINCE_NAME
CITY: ID(Ö÷¼ü), PROVINCE_ID£¨Íâ¼ü£©,CITY_NAME
´ËÖÖ·½Ê½±È½Ï¼òµ¥£¬µ«Éè¼ÆµÄÁé»îÐÔ²»¹»£¬Êý¾Ý´¦ÀíÆðÀ´±È½ÏÂé·³¡£
2.²ÉÓñíµÄ×Ô¹ØÁªÍâ¼üÒýÓÃ
È磺 DISTRICT_INFO: ID£¨Ö÷¼ü£©,PARENT_ID,£¨Íâ¼ü£©DISTRICT_INFO
ͨ¹ýÍâ¼ü(PARENT_ID)µÄ×ÔÉíÒýÓÃÖ÷¼ü(ID)À´È·Á¢²ã´Î¹Øϵ¡£
Óŵ㣺ÎÞÏÞ¼¶±ðµÄ²ã´Î¹Øϵ£¬À©³äÐÔÇ¿¡£¶ÔÓÚOracleÊý¾Ý¿âÀ´Ëµ£¬Äܼòµ¥Í¨¹ý Start With,,,Connect By--Óï¾äÀ´ÊµÏÖÊý¾ÝµÄ²éѯ¡£
ȱµã£º²»ÄÜÃ÷È·¿´³ö²ã´Î¹Øϵ£¬ÎÞ·¨ÊµÏÖÅÅÐò¡£
3.²ÉÓñàÂ뷽ʽÀ´ÊµÏÖ²ã´Î
DISTRICT: ID,CODE,NAME ÆäÖÐCODEµÄÌصãÊÇÉϼ¶±àÂëÊÇϼ¶±àÂëµÄǰ׺
Óŵ㣺ͨ¹ý±àÂëµÄÄÚÈÝÄܹ»ºÜÈÝÒ×»ØÈ¥Êý¾ÝµÄ²ã´Î¹Øϵ¡£
ȱµã£ºÊ¹ÓÃLike·½·¨»òº¯Êý²éѯÀ´ÊµÏÖ×Ó¼¯µÄ²éÕÒ£¬Ð§Âʽϵͣ¬ÄÜʵÏÖ²ã´Î¹ØϵµÄ¼¶ÊýÓÐÏÞ£¨ÊÜCODEµÄ×ֶ㤶ÈÓ°Ï죩¡£
ÓÅ»¯·½°¸£º
¼¯ºÏ2£¬3µÄÓŵ㣬²ÉÓù̶¨±àÂ뼶´ÎµÄ³¤¶ÈµÄ·½·¨À´Éè¼Æ±í¡£
DISTRICT:ID,CODE,PARENT_ID,NAME
ÆäÖÐIDΪÖ÷¼ü£¬CODE:¹æ¶¨Îª4λһ¼¶¡£±íÏÖµÄÊý¾ÝÈçÏ£º
ID,CODE PARENT_ID, NAME
1 0001 Öйú
2 00010001 1 ºþÄÏ
3 000100010001 2 ºâÑô
4 000100010002 2 ³¤É³
5 0001000100020001 4 Ó껨
´ÓÊý¾ÝÖпÉÒÔ¿´³ö£¬PARENT_ID¿ÉÒÔÖ±¹Û±í´ï²ã´ÎµÄÉÏϼ¶¹Øϵ
¶ø±àÂëCODE¿ÉÒÔÖ±¹Û±í´ï²ã´Î¹ØϵÓëͬһ²ã´ÎµÄ˳Ðò¹Øϵ¡£
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
create database example
use example
create table major
(
spno varchar(10) primary key not null,
spname varchar(20) not null
)
create table student
(
sno varchar(10) primary key not null,
sname varchar(10) not null,
ssex varchar(2) not null, ......
±¾ÎÄʵÏÖÔÚc#ÖпɸßЧµÄ½«excelÊý¾Ýµ¼Èëµ½sqlserverÊý¾Ý¿âÖÐ,ºÜ¶àÈËͨ¹ýÑ»·À´Æ´½Ósql£¬ÕâÑù×ö²»µ«ÈÝÒ׳ö´í¶øÇÒЧÂʵÍÏ£¬×îºÃµÄ°ì·¨ÊÇʹÓÃbcp£¬Ò²¾ÍÊÇSystem.Data.SqlClient.SqlBulkCopy ÀàÀ´ÊµÏÖ¡£²»µ«Ëٶȿ죬¶øÇÒ´úÂë¼òµ¥£¬ÏÂÃæ²âÊÔ´úÂëµ¼ÈëÒ»¸ö6Íò¶àÌõÊý¾ÝµÄsheet£¬°üÀ¨¶ÁÈ¡£¨È«²¿¶ÁÈ¡±È½ÏÂý£©ÔÚÎҵĿª·¢»·¾³ÖÐÖ»ÐèÒª1 ......
ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£ ......
£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLE µÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏÂ,Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£Èç¹ûÓÐ3¸öÒÔÉϵıíÁ¬½Ó²éѯ, ÄǾÍÐèҪѡÔñ½»²æ±í(intersectio ......