excel ³s±µ SQL 2008»yªk ¦p¦ó§ï¶i »P°j°é
- ©«¤l
- 361
- ¥DÃD
- 57
- ºëµØ
- 0
- ¿n¤À
- 426
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- 2003,2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-13
- ³Ì«áµn¿ý
- 2022-12-8
|
excel ³s±µ SQL 2008»yªk ¦p¦ó§ï¶i »P°j°é
¤p§Ì§Q¥ÎEXCELŪ¨úSQL2008ªº¸ê®Æ¡A·Qn±q¸ê®Æ®w¤¤§ì¥X¨Ópºâ¡A³Ì«á·Q¦A«ö·ÓªÑ²¼¥N½X¶]°j°é¡A¤U±¬O¤p§Ì¿ý»sªº¥N½X¡A§Úı±o¦n¹³¥i¥H§ó²³æ¤@¨Ç¡A½Ð°ª¤â«üÂI¤@¤U¡A·íµM¿ý»sªº¥N½X¬O2330¡A³Ì«á2330·|¥Î¦¨ÅܼƨӶ]¡A¤£ª¾¹D¦³¤H¥i¥HÅý¤U±ªº³s±µ¤è¦¡§ó¦n©Î§ó§Ö¤@¨Ç¡IÁÂÁÂ
¤p§Ì¥u·|³o¼Ë¼g¡A·íµM¦³°ª¤â¥i¥HÀ°¤p§Ì§ïªº§óº}«G¤@¨Ç- Sub ªÑ²¼¸ê®Æ1()
- '
- '
- Sheets("Sheet1").Select
- Range("A1").Select
- With ActiveSheet.QueryTables.Add(Connection:= _
- "ODBC;DRIVER=SQL Server;SERVER=.;UID=sa;PWD=WXYZ1234;APP=Microsoft Office 2003;WSID=CS5111;DATABASE=stock" _
- , Destination:=Range("A1"))
- .CommandText = Array( _
- "select * from (SELECT TOP 12 * FROM stock.dbo.StockStore WHERE stockid=2330 ORDER BY sdate DESC) AAA ORDER BY sdate")
- .Name = "¨Ó¦Û "
- .FieldNames = True
- .RowNumbers = False
- .FillAdjacentFormulas = False
- .PreserveFormatting = True
- .RefreshOnFileOpen = False
- .BackgroundQuery = True
- .RefreshStyle = xlInsertDeleteCells
- .SavePassword = True
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .PreserveColumnInfo = True
- .Refresh BackgroundQuery:=False
- End With
- End Sub
- Sub ªÑ²¼¸ê®Æ2()
- '
- '
- '
- Sheets("Sheet2").Select
- Range("A1").Select
- With ActiveSheet.QueryTables.Add(Connection:= _
- "ODBC;DRIVER=SQL Server;SERVER=.;UID=sa;PWD=WXYZ1234;APP=Microsoft Office 2003;WSID=CS5111;DATABASE=stock" _
- , Destination:=Range("A1"))
- .CommandText = Array( _
- " select * from (SELECT TOP 12 sdate,stockid, CreditMoney,CreditTick FROM stock.dbo.CreditExchangeMonth WHERE stockid=2330 ORDER BY sdate DESC) AAA ORDER BY sdate" _
- )
- .Name = "¨Ó¦Û "
- .FieldNames = True
- .RowNumbers = False
- .FillAdjacentFormulas = False
- .PreserveFormatting = True
- .RefreshOnFileOpen = False
- .BackgroundQuery = True
- .RefreshStyle = xlInsertDeleteCells
- .SavePassword = True
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .PreserveColumnInfo = True
- .Refresh BackgroundQuery:=False
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 361
- ¥DÃD
- 57
- ºëµØ
- 0
- ¿n¤À
- 426
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- 2003,2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-13
- ³Ì«áµn¿ý
- 2022-12-8
|
¥»©«³Ì«á¥Ñ joey0415 ©ó 2010-6-4 21:44 ½s¿è
[quote]¦^´_ joey0415
¬d¸ß¤w¸g¦s¦b¤£¦A¨Ï¥ÎAdd
°²³]¥N¸¹¬O2030~2032
´N¦P¤@Ó¬d¸ß¨Ï¤§ÅܤÆ- # Sub ªÑ²¼¸ê®Æ1()
- # For Each MyID In Array("2030","2031",2032")
- # With Sheets("Sheet1").QueryTables(1)
- # .CommandText = Array( _
- # "select * from (SELECT TOP 12 * FROM stock.dbo.StockStore WHERE stockid=" & MyID & " ORDER BY sdate DESC) AAA ORDER BY sdate")
- # .Name = "¨Ó¦Û "
- # .FieldNames = True
- # .RowNumbers = False
- # .FillAdjacentFormulas = False
- # .PreserveFormatting = True
- # .RefreshOnFileOpen = False
- # .BackgroundQuery = True
- # .RefreshStyle = xlInsertDeleteCells
- # .SavePassword = True
- # .SaveData = True
- # .AdjustColumnWidth = True
- # .RefreshPeriod = 0
- # .PreserveColumnInfo = True
- # .Refresh BackgroundQuery:=False
- # End With
- # Next
½Æ»s¥N½X ½Ð°Ýª©¥D¡A¬O¤£¬On¥ý°õ¦æ¿é¤J±b¸¹»P±K½XªºSQL³s½u³]©w¡A¤~¯à¨Ï¥Îª©¥Dªº§å¦¸³]©w¡A½Ð°Ýn¦p¦ó¼W¥[¦bª©¥D©Ò¼gªºµ{¦¡¤W©O¡H·PÁª©¥D¥Î¤ß¦^À³ |
|
|
|
|
|
|