Excel±íÊý¾Ýµ¼ÈëSql ServerÊý¾Ý¿âÖÐ
C#¡¢ASP.NETÖн«Excel±íÖеÄÊý¾Ýµ¼Èëµ½Sql ServerÊý¾Ý¿âÖжÔÓ¦µÄ±íÖС£
ÕâÀïÎÒÃǽ«E:\test.xls
ÖÐSheet1
±íÖеÄÊý¾Ýµ¼Èëµ½testÊý¾Ý¿âÖеÄmy_test
±íÖС£
Èí¼þ£ºVS2005£¬SQL Server2000,
test.xlsÖÐSheet1±íÖÐÓÐÈý¸ö×ֶΣ¬±àºÅ¡¢Ãû³Æ¡¢±¸×¢¡£¾ßÌåÄÚÈÝÈçÏÂͼ¡£
1¡¢
Ê×ÏÈ£¬ÎÒÃÇÒªÏÈÔÚtestÊý¾Ý¿âÖÐн¨Ò»¸ömy_test±í£¬¸Ã±í¾ßÓÐÈý¸ö×Ö¶Î
tid
intÀàÐÍ£¬ tname
nvarcharÀàÐÍ, tt
nvarcharÀàÐÍ
£¨×¢Ò⣺my_test±íÖеÄÊý¾ÝÀàÐͱØÐëÓëExcelÖÐÏàÓ¦×ֶεÄÀàÐÍÒ»Ö£©
2¡¢
ÎÒÃÇÓÃ
SELECT * from OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 5.0;DatabASE=[Excel±í.xslÎļþµÄ·¾¶]
;HDR=YES;IMEX=1 ', Sheet1$')
À´¶ÁÈ¡Excel±íÖеÄÊý¾Ý£¬¶Á³öÀ´µÄÊý¾Ý¸ú´ÓÊý¾Ý¿âÖеıí¶Á³öµÄÊý¾ÝÊÇÒ»Ñù£¬Ò²°üÀ¨×Ö¶ÎÃûºÍÊý¾Ý¡£µ±È»ÎÒÃÇÒ²¿ÉÒÔÓÃ×Ö¶ÎÃûÁбíÀ´»ñÈ¡Excel±íÖеIJ¿ÃÅÊý¾Ý¡£
SELECT ×Ö¶Î1, ×Ö¶Î2£¬×Ö¶Î3 [...]
from OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 5.0;DatabASE=[Excel±í.xslÎļþµÄ·¾¶]
;HDR=YES;IMEX=1 ', Sheet1$')
3¡¢
Excel
ÖеÚÒ»ÐÐÊǶ¨ÒåµÄÊÇÁÐÃû£¬´ÓµÚ2ÐпªÊ¼²ÅÊÇÊý¾Ý¡£Í¨¹ýSqlÓï¾ä´ÓExcelÖжÁÈ¡µ½µÄÊý¾ÝÒ²ÊÇ´ÓµÚ¶þÐпªÊ¼µÄ£¬¶þÁÐÃû±ä³ÉÁË×Ö¶ÎÃû¡£Èç¹ûÄãµÄµÚÒ»ÐÐÓж¨
ÒåÁÐÃû£¬ÄÇô´ÓExcelÖлñÈ¡µÄÊý¾ÝµÄ¸÷¸ö×ֶεÄÃû³Æ¾ÍÊÇExcelÖеÄÁÐÃû¡£È磺´Ótest.xls sheet±íÖлñÈ¡µÄÊý¾ÝµÄ×Ö¶ÎÃû·Ö±ðÊDZàºÅ ÐÕÃû ±¸×¢
¡£Èç¹ûÄ㶨ÒåµÄExcel±íµÄµÚÒ»ÐÐûÓж¨ÒåÁÐÃû£¬ÄÇô»ñÈ¡ºóÊý¾ÝµÄ×Ö¶ÎÃû·Ö±ðÊÇF1¡¢F2¡¢F3...ÒÔ´ËÀàÍÆ¡£Èç¹ûÄãÖ»ÊÇÒª»ñÈ¡Excel±íÖв¿·ÖÁеÄÊý¾Ý£¬ÄÇôÄã¿ÉÒÔ¾ÍÒªÓõ½ÉÏÃæµÄÄÚÈÝ¡£
4¡¢
ÔÚVS2005ÖÐн¨Ò»¸öweb´°Ìå(test.aspx)£¬ÍùÆäÖÐÌí¼ÓÒ»¸öButton¿Ø¼þ£¬Ò»µã»÷¸Ã°´Å¥¾ÍÖ´Ðе¼È롣˫»÷¸Ã°´Å¥£¬¶¨Òåʼþ´¦Àíº¯Êý¡£test.aspx.csÖеĴúÂëÈçÏ£º
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class admin_test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
 
Ïà¹ØÎĵµ£º
ÏÖÔÚÓÃMSSQLµÄµØ·½Ì«¶àÁË£¬Óкܶà×ö¼¼ÊõµÄ¸öÈ˵çÄÔÉÏÒ²°²×°SQLרҵ°æ£¬ÒòΪËüÓõĶ࣬µ«ÓõÄÈ˶¼ÖªµÀ£¬SQLÓиö³¬¼¶Óû§sa£¬´ËÓû§Ä¬ÈÏÇé¿öÏ£¬ËüÖ¸Åɸø¹Ì¶¨·þÎñÆ÷½ÇÉ« sysadmin£¬²¢²»ÄܽøÐиü¸Ä¡£Ò»°ã¶®µã°²È«ÎÊÌâµÄ¼¼ÊõÈËÔ±¶¼»á°ÑÕâ¸öÃÜÂëÐ޸ĵô£¬µ«ÐÞ¸ÄÔÙ¸´ÔÓµÄÃÜÂë¶¼²»ÊǾø¶Ô°²È«µÄ£¬Ò»Ð©±©Á¦ÆÆ½âÈí¼þ£¬²ËÄñ¶¼»áÓá£
ÄÇ ......
Êý¾Ý¿â±¸·Ý ×÷ÒµÖеÄSqlÓï¾ä£º
DECLARE @strPath NVARCHAR(200)
set @strPath = convert(NVARCHAR(19),getdate(),120)
set @strPath = REPLACE(@strPath, ':' , '_')
set @strPath = REPLACE(@strPath, '-' , '_')
set @strPath = REPLACE(@strPath, ' ' , '_')
set @strPath = 'F:\Êý¾Ý¿â±¸·Ý\' + myData_'+@s ......
PowerDesignerÉú³ÉSQL½Å±¾Ê±±íÃû¡¢×Ö¶ÎÃû´øÒýºÅÎÊÌâ
ʹÓÃPowerDesignerÉú³ÉÊý¾Ý¿â½Å±¾Ê±£¬±íÃûÒ»°ã»á´øÒýºÅ¡£ÈçÏ£º
¼ÓÒýºÅÊÇPL/SQLµÄ¹æ·¶£¬Êý¾Ý¿â»áÑϸñ°´ÕÕ“”ÖеÄÃû³Æ½¨±í£¬Èç¹ûûÓГ”£¬»á°´ÕÕORACLEĬÈϵÄÉèÖý¨±í£¬Ä¬ÈÏÊÇÈ«²¿´óд£ ......
ÎÒÃÇÕâÀï¶Ô SQL Server ×Ö·û´®º¯Êý½øÐзÖÃűðÀàµØÁгö£¬±ãÓÚ²éÔĺͼÇÒ䣬ÏàÐÅ´ó¼Ò¶¼ÔÚÆäËü·½ÃæÓиßÉîµÄ±à³Ì»ù´¡£¬´Ó×ÖÃæÉÏÀ´Ëµ´ó¼Ò¶¼ÖªµÀÕâЩº¯ÊýµÄÒâÒ壬¾Í²»¶ÔÕâЩº¯Êý×÷¹ý¶àµÄ½âÊÍÁË£¬Ö÷Ҫ̸Щ¾Ñ飬¾ßÌåÇë²Î¼ûÁª»ú´ÔÊé¡£
ASCII(character_expression) ·µ»Ø×î×ó¶Ë×Ö·ûµÄ ASCII ´úÂëÖµ
CHAR(integer_expression)
UNICO ......
×ֺţº ´ó´ó ÖÐÖРСС
Ëø¶¨Êý¾Ý¿âµÄÒ»¸ö±í
SELECT * from table WITH (HOLDLOCK)
×¢Òâ: Ëø¶¨Êý¾Ý¿âµÄÒ»¸ö±íµÄÇø±ð
SELECT * from table WITH (HOLDLOCK)
ÆäËûÊÂÎñ¿ÉÒÔ¶ÁÈ¡±í£¬µ«²»ÄܸüÐÂɾ³ý
SELECT * from table WITH (TABLOCKX)
ÆäËûÊÂÎñ²»ÄܶÁÈ¡±í,¸üкÍɾ³ý
SELECT Óï¾äÖГ¼ÓË ......