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

EXCEL µ¼ÈëSQL SERVER´æ´¢¹ý³Ì

 set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[pr_xls_to_tb]
@path varchar(200),--EXCEL·¾¶Ãû
@tbName varchar(30),--±íÃû
@stName varchar(30) --excelÖÐÒª¶ÁµÄSHEETÃû
as
declare @sql varchar(500),--×îºóÒªÖ´ÐеÄSQL
@stName_Real varchar(35),--ÕæÕýµÄSHEETÃû
@drop_sql varchar(300) -- Èç¹û±íÒÑ´æÔÚ£¬ÏÈɾ³ý
set @stName_Real = '[' + @stName + '$]'
--set @path = 'C:\Inetpub\wwwroot\CarStock_ExcelWeb\Upload\CarStock\¹úóÆû³µ¿â´æ±í20090630.xls'
--set @tbName = 't32'
--set @stName = '[²»Á¼×ʲú$]'
set @sql =
'SELECT *
into '+ @tbName +'
from OpenDataSource(' + char(39)+ 'Microsoft.Jet.OLEDB.4.0' + char(39)+', '
+ char(39) +'Data Source=' + @path +';User ID=Admin;Password=;Extended properties=Excel 5.0;' + char(39)+')...'+@stName_Real
set @drop_sql = '
if exists(select * from sysobjects where name = ' + char(39) +@tbName + char(39)+')
begin
drop table '+@tbName+'
end '
--print @drop_sql
exec (@drop_sql)--ÏÈɾ³ý±í
exec (@sql)--ÔÙ´´½¨±í
/*
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
*/

µ÷ÓÃ:
exec pr_xls_to_tb 'C:\Tools\Ô¤ËãÊý¾Ý\ys_200908.xls' ,'ys_200908_new' ,'Source'


Ïà¹ØÎĵµ£º

SQLÓï¾äPART6

Differring Constraints:
Constraints can have the following attributes: DEFFERRABLE / NOT DEFFERRABLE,  INITIALLY DEFFERRED / INITIALLY IMMEDIATE.
e.g.:
alter table dept2 add constraint dept2_id_pk primary key (department_id) deferrable initially deferred; // deferring constraint on creation. ......

SQLÓï¾äPART8

PairWise subquery:
e.g.:
select * from wf_docsort where (ndocsortid,nmoduleinfoid)  in (select ndocsortid, nmoduleinfoid from wf_docsort where instr(cname,'ÎÄ')>0)
the above sql is the same function as:
select * from wf_docsort where ndocsortid = (select ndocsortid from wf_docsort where ......

SQLÖÐJOINµÄʹÓÃ


(×¢:outerµÄÒâ˼¾ÍÊÇ"ûÓйØÁªÉϵÄÐÐ"¡£)
1.cross join È«ÍâÁ¬½Ó(µÑ¿¨¶û³Ë»ý)
SELECT A.*, B.* from A FULL OUTER JOIN B ON A.ID = B.ID
2.inner join ÄÚÁ¬½Ó(Ôڵѿ¨¶û³Ë»ýµÄ½á¹û¼¯ÖÐÈ¥µô²»·ûºÏÁ¬½ÓÌõ¼þµÄÐÐ)
SELECT A.* from A INNER JOIN B ON A.ID=B.ID
3.left outer join ×óÍâÁ¬½Ó(ÔÚinner joinµÄ½á¹ ......

SQL Server

Êý¾ÝÀàÐÍ
ÔÚ Microsoft SQL ServerÖУ¬Ã¿¸öÁС¢¾Ö²¿±äÁ¿¡¢±í´ïʽºÍ²ÎÊý¶¼ÓÐÒ»¸öÏà¹ØµÄÊý¾ÝÀàÐÍ£¬ÕâÊÇÖ¸¶¨¶ÔÏó¿É³ÖÓеÄÊý¾ÝÀàÐÍ£¨ÕûÐÍ¡¢×Ö·û¡¢money µÈµÈ£©µÄÌØÐÔ¡£SQL Server ÌṩϵͳÊý¾ÝÀàÐͼ¯£¬¶¨ÒåÁË¿ÉÓë SQL Server Ò»ÆðʹÓõÄËùÓÐÊý¾ÝÀàÐÍ¡£ÏÂÃæÁгöϵͳÌṩµÄÊý¾ÝÀàÐͼ¯¡£
¿ÉÒÔ¶¨ÒåÓû§¶¨ÒåµÄÊý¾ÝÀàÐÍ£¬ÆäÊÇϵͳÌá ......

SQL Server ¾­³£Óõ½µÄ¼¸¸öÉèÖÃÑ¡Ïî

1. SET DEADLOCK_PRIORITY
˵Ã÷£º¿ØÖÆÔÚ·¢ÉúËÀËøÇé¿öʱ»á»°µÄ·´Ó¦·½Ê½¡£Èç¹ûÁ½¸ö½ø³Ì¶¼Ëø¶¨Êý¾Ý£¬²¢ÇÒÖ±µ½ÆäËü½ø³ÌÊÍ·Å×Ô¼ºµÄËøÊ±£¬Ã¿¸ö½ø³Ì²ÅÄÜÊÍ·Å×Ô¼ºµÄËø£¬¼´·¢ÉúËÀËøÇé¿ö¡£
Óï·¨£ºSET DEADLOCK_PRIORITY { LOW | NORMAL | @deadlock_var }
²ÎÊý£ºLOW   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ