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

vba ½«excel²åÈësqlÊý¾Ý¿â

Private Sub insert1_click()
Dim iCount As Integer
Dim cn
Set cn = CreateObject("ADODB.Connection")
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=8233;Initial Catalog=hskmis;Data Source=127.0.0.1"
cn.Open
cn.Execute ("delete temp9")
'¼ÆËã¸Ã±íÓжàÉÙÐÐ
RowCount = Worksheets("FC").UsedRange.Rows.Count
'ÐÐÑ­»·
For irow = 1 To RowCount
    strRecord = ""
'ÁÐÑ­»·,¼ÙÉèÓÐÎåÁÐ,´ÓµÚÒ»ÁпªÊ¼
For icol = 1 To 5
If icol <> 5 Then
    strRecord = strRecord & "'" & Worksheets("FC").Cells(irow, icol).Value & "'" & ","
Else
strRecord = strRecord & "'" & Worksheets("FC").Cells(irow, icol).Value & "'"
End If
 Next
MsgBox strRecord
Sql = cn.Execute("insert into temp9 values(" & strRecord & ")")
Next
MsgBox "²åÈëÍê³É"
End Sub


Ïà¹ØÎĵµ£º

Sql Server2005¶Ôt sqlµÄÔöǿ֮Cross Apply

Cross Applyʹ±í¿ÉÒԺͱíÖµº¯Êý½á¹û½øÐÐjoin£¬ÔÚÏÂÃæµÄʾÀýÖн¨ÁËÁ½¸ö±íºÍÒ»¸ö±íÖµº¯Êý£¬T_bµÄÁÐa_idsÖÐ»á´æ·Åa±íµÄidÓÃ,·Ö¸îµÄ×Ö·û´®Á¬½Ó£»ÎÒÃÇͨ¹ýcross applyʹT_a£¬T_b±íͨ¹ýsplitIDs inner join Á¬½Ó¡£Ç뿴ʾÀý£ºGO
if object_id('T_a','U') is not null
drop table T_a
GO
CREATE TABLE T_a(    ......

ͨ¹ýSQL´æ´¢¹ý³Ìɾ³ý¹ýÆÚµÄÊý¾Ý¿âBak±¸·ÝÎļþ

1.ÏÈÆôÓà xp_cmdshell À©Õ¹´æ´¢¹ý³Ì£º
Use Master
GO
Exec sp_configure 'show advanced options', 1
GO
Reconfigure;
GO
sp_configure 'xp_cmdshell', 1
GO
Reconfigure;
GO
 (×¢£ºÒòΪxp_cmdshellÊǸ߼¶Ñ¡ÏËùÒÔÕâÀïÆô¶¯xp_cmdshell£¬ÐèÒªÏȽ« show advanced ......

SQL Server 2005ÖеÄÎļþºÍÎļþ×é

--> Title  : SQL Server 2005ÖеÄÎļþºÍÎļþ×é
--> Author : wufeng4552
--> Date   : 2009-10-23
1¡¢ÎļþºÍÎļþ×éµÄº¬ÒåÓë¹ØÏµ
    ÿ¸öÊý¾Ý¿âÓÐÒ»¸öÖ÷Êý¾ÝÎļþ.ºÍÈô¸É¸ö´ÓÎļþ¡£ÎļþÊÇÊý¾Ý¿âµÄÎïÀíÌåÏÖ¡£ Îļþ×é¿ÉÒÔ°üÀ¨·Ö²¼ÔÚ¶à¸öÂß¼­·ÖÇøµÄÎļþ£¬ÊµÏÖ¸ºÔØÆ½ºâ¡£Îļþ×éÔÊÐ ......

sqlÓï·¨

Distinct
SELECT DISTINCT "À¸Î»"
from "±í¸ñÃû"
Where
SELECT "À¸Î»"
from "±í¸ñÃû"
WHERE "condition"
And/Or
SELECT "À¸Î»"
from "±í¸ñÃû"
WHERE "¼òµ¥Ìõ¼þ"
{[AND|OR] "¼òµ¥Ìõ¼þ"}+
In
SELECT "À ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ