Ò»¶ÎsqlÓï¾äµÄ·ÖÎö
--µ±Ç°Ê¹ÓõÄÊý¾Ý¿âÊÇ ÏµÍ³×Ô´øµÄ master
create database temp1
go --´Ë´¦²»¼ÓgoµÄ»°ÏÂÃæuse temp1 »á±¨´í£ºÕÒ²»µ½´æ´¢¹ý³Ì 'temp1'¡£
use temp1
set xact_abort on
begin tran
create table [order]( --orderÊǹؼü×Ö±ØÐëÓÃ[ ]£»
id int
)
create table fOrder(
id int
)
-- ÏÂÃæµÄ²Ù×÷Ö÷ÒªÊÇΪÁËʵÏÖfOrderµÄid ÒýÓà order ±íÖеÄid×öÍâ¼ü
alter table [order]
alter column id int not null --Èç¹û´Ë´¦²»°ÑidÉèÖÃΪ²»ÄÜΪ¿Õ£¬ÏÂÃæÊÇÎÞ·¨ÉèÖÃÆäΪÖ÷¼üµÄ
go -- ÓÖÊDZØÐëµÄ·ñÔò»á±¨´í˵£ºidÊÇ¿ÉÒÔΪnullµÄ
alter table [order] add
constraint Pk primary key(id) -- ÉèÖÃorder±íµÄidΪÖ÷¼ü²ÅÄܱ»×÷ΪfOrder±íµÄÍâ¼ü
alter table fOrder add -- Ôö¼ÓÍâ¼üÔ¼Êø
constraint fk foreign key(id) references [order](id)
commit tran
Ïà¹ØÎĵµ£º
Õ⼸ÌìÒ»Ö±±»ÖÐÎÄÂÒÂëÎÊÌâÀ§ÈÅ£¬ÖÐÎÄÊý¾Ý²åÈëµ½My SqlÖкÜÕý³££¬ÔÚCommand client lineÖÐÒ²ÄÜÕý³£ÏÔʾ£¬¿É´ÓÊý¾Ý¿âÖжÁµ½JSPÒ³ÃæÉÏʱ£¬¾Í±ä³É“»ðÐÇÎÄ”ÁË¡£
¡¡¡¡ÓÚÊÇÉÏÍø²éѯ£¬Ò²¿´µ½ºÃ¶à·½·¨£ºÓеÄ˵°Ñmy.iniÖÐdefault-character-set=latin1¸ÄΪdefault-character-set=utf8,ÓÐ ......
SELECT * into newtable
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\aaaa.xls";User ID=Admin;Password=;Extended properties=Excel 11.0')...[Sheet1$]
/******* µ¼³öµ½excel
¡¡¡¡exec master..xp_cmdshell 'bcp settledb.dbo.shanghu out c:\temp1.xls -c -q -s"gnetdata/gnetdata" - ......
ÔÚVSÖÐдSQLÓï¾äµÄʱºò£¬Ç§ÍòÍòǧҪСÐÄÔÙСÐÄ£¬±ÈÈç ˵ Êý¾ÝÀàÐ͵ÄÆ¥Å䣬 µ¥ÒýºÅ£¨Õâ¸öÄÜ°ÑÈËÃÔËÀ£©
where ×Ó¾äÖпÉǧÍò²»ÄÜÓпոñ£¨µ±²éѯÌõ¼þΪ×Ö·û´®µÄʱºòÄÜ°ÑÄãŪ·è£¬ÎÒŪÕâ¸öµÄʱºò¶¼·èÁ˼¸´ÎÁË£¬Ê²Ã´¶¼¶Ô¾ÍÊDz鲻³öÀ´£¬µ÷ÊÔÁËN±é²Å·¢ÏÖ¡££©²»ÐÐÁË£¬³Ô·¹È¥£¬ÔÙ²»³Ô¿´¼û»îÈ˶¼ÏëÒ§ÁË¡£ ......
Ç°²»¾Ã¿´µ½Í¬ÊÂÔÚÓÃSql Prompt3.9£¬¾õµÃÂù·½±ãµÄ¡£¸øÎÒÃÇд³ÌÐòÄÜʡϲ»ÉÙÁ¦Æø¡£·½±ã£¬sql´úÂë¿´ÆðÀ´ÓÖ¼ò½é¡£ÖµµÃÍƼö¡£http://www.red-gate.com/ÕâÊÇËüµÄ¹ÙÍø£¬ÊÇÒ»¿îÊշѵÄÈí¼þ¡£Õýʽ°æ±¾ÏÂÔØÏÂÀ´Ö»ÄÜʹÓÃ14Ìì¡£·Ï»°²»ËµÁË£¬ÏÈ¿´ÏÂЧ¹ûͼ£º
»¹²»´í°¡¡£
½ÓÏÂÀ´½éÉÜÏÂÆƽâµÄ·½·¨£¬Ïȵ½¹ÙÍø°Ñ×îаæ(ÏÖÔÚÒѾÊÇ3.9ÁË)ÏÂÏÂÀ ......
Èç¹ûÔÀ´µÄÊý¾Ý¿â¿ÉÓ㬷ÖÀëÊý¾Ý¿âºó£¬Ö»¸½¼ÓÊý¾ÝÎļþ£¬²»¸½¼ÓÈÕÖ¾
Èç¹û²»¿ÉÓã¬Ö»ÄÜÂýÂýµÈ»¹Ô²Ù×÷Íê³ÉÁË
ÈÕÖ¾ÎļþÌ«´óÁË£¬Ó¦¸Ã¶¨ÆÚÕûÀíÈÕÖ¾
--ѹËõÈÕÖ¾¼°Êý¾Ý¿âÎļþ´óС
&n ......