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'
Ïà¹ØÎĵµ£º
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. ......
oracle tips
ExistµÄÓ÷¨£º
select gw.ndocid from
(select ndocid from wf_doc_gw_shouwen union select ndocid from wf_doc_gw_fawen) gw
where
not exists (select null from wf_doc_gw_sn sn where sn.ndocid=gw.ndocid)
2¡£°ÑGW±íºÍSN±íÀïÏàͬµÄNDOCIDÏÔʾ³öÀ´
select gw.ndocid from
(se ......
ÒÔǰһֱ¾õµÃlinq to sqlÉú³ÉÀàËÆwhere id not in (1,3,5)»òwhere id not in (select id from ...)ÕâÑùµÄÌõ¼þ²»ÊǺܷ½±ã£¬Ã¿´ÎÎÒ¶¼ÊǰÑÌõ¼þIDÊÂÏÈÈ¡µ½Ò»¸öÊý×éÀȻºóÓà !Arr.Contains(c.Id)ÕâÑù´¦Àí£¬½ñÌìͻȻ·¢ÏÖÕâÑùºÃɵ£¬Æäʵ¿ÉÒÔÍêȫֱ½ÓÓÃlinqд³ÉÒ»¾ä£¬Ìù¸öʾÀýÔÚÕâÀÒԺ󱸲é
from a in TableA where !(fr ......
ͨÅä·û_
"_"ºÅ±íʾÈÎÒâµ¥¸ö×Ö·û,¸Ã·ûºÅÖ»ÄÜÆ¥ÅäÒ»¸ö×Ö·û."_"¿ÉÒÔ·ÅÔÚ²éѯÌõ¼þµÄÈÎÒâλÖÃ,ÇÒÖ»ÄÜ´ú±íÒ»¸ö×Ö·û.Ò»¸öºº×ÖֻʹÓÃÒ»¸ö"_"±íʾ.
Àý×Ó£º
if PATINDEX('%[ß¹-×ö]%','ÐèÒªÅжϵÄ×Ö·û')>0 -- ÅжÏÊÇ·ñÓÐ×Ö·û
print 'Óкº×Ö'
else
print 'ÎÞºº×Ö'
ͨÅä·û%
"%"·ûºÅÊÇ×Ö·ûÆ¥Åä·û,ÄÜÆ¥Åä0¸ö»ò¸ü¶à×Ö·ûµÄÈÎÒⳤ¶ ......
Ê×ÏÈÒªÌí¼Ó
using System.Data;
using System.Data.SqlClient;
½ÓÏÂÀ´£º
SqlConnection conn = new SqlConnection("server=QLPC\\SQL2005;uid=sa;pwd=£¨ÄãµÄÃÜÂ룩;database=£¨ÄãµÄÊý¾Ý±í£©"); &n ......