°õ¦æ¶¥¬q¿ù»~13¡A«¬ºA¤£²Å¦X»Psql»yªk«üÂI
- ©«¤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
|
°õ¦æ¶¥¬q¿ù»~13¡A«¬ºA¤£²Å¦X»Psql»yªk«üÂI
¤p§Ì³Ìªñ¦b¼gsql»yªk¡A³Ì«án¥N¤Jexcel vba¤¤, «e±ªº¤@¬qcode¥i¥H¥Î¡A¤£¹L§ï¦¨¥t¤@³Ìsqlªº»y¥y«oµo¥Í¿ù»~¡A¤£¹L³o¤@¬q»y¥y¦bsql server¤¤¬O¥i¥H°õ¦æªº¡A¦bvba°õ¦æ¤¤¥X²{ªº¬O¡u°õ¦æ¶¥¬q¿ù»~13¡A«¬ºA¤£²Å¦X¡v¡A½Ð°ª¤â«üÂI¤@¤U¡A¥t¤@Ó°ÝÃD¬O·í»y¥y«Üªø®É«ç»ò´«¦æ©O¡H- Sub ªÑ²¼¦X¨Ö´ú¸Õ()
- '
- Sheets("Sheet4").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 a.sdate,a.stockid,a.buy,a.sell,b.sdate,b.stockid,b.eq0,b.eq1 from dbo.CompTradeMonth a inner join dbo.StockStore b on a.stockid=b.stockid where a.sdate='2010-03-31 00:00:00.000' and b.sdate='2010-03-31 00:00:00.000' and a.stockid>1000")
- .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- Sub ªÑ²¼¦X¨Ö´ú¸Õ()
- '
- Sheets("Sheet4").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 a.sdate,a.stockid,a.eq0,a.eq1,a.eq5,a.eq10,a.eq15,a.eq20,a.eq30,a.eq50,a.eq100,a.eq200,a.eq400,a.eq600,a.eq800,a.eq1000,a.eq,b.sdate,b.stockid,b.Buy,b.Sell,b.UD,b.EQ from dbo.StockStore a inner join dbo.CompTradeMonth b on a.stockid=b.stockid where a.sdate='2010-03-31 00:00:00.000' and b.sdate='2010-03-31 00:00:00.000' and a.stockid>1100")
- .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
|
½Ð°Ý.CommandText = Array("select a.*,b.*,c.*,d.* from dbo.StockStore a left join dbo.StockMonth b on a.stockid=b.stockid left join dbo.CompTradeMonth c on a.stockid=c.stockid left join dbo.CreditExchangeMonth d on a.stockid=d.stockid where a.stockid>1100 and a.sdate='2010-03-31 00:00:00.000' and b.sdate='2010-03-31 00:00:00.000' and c.sdate='2010-03-31 00:00:00.000' and d.sdate='2010-03-31 00:00:00.000'")
°}¦C¤¤ªºÈ¬O¤£¬On¬Û¦P«¬ºAªº¡A¤£µM«ç·|¡u°õ¦æ¶¥¬q¿ù»~13¡v¡A½Ð°Ý«ç»ò§ï¦¨¬Û¦P«¬ºA©O¡H
½Ð°ª¤â«ü¾É¤@¤U¡H
ÁÂÁÂ |
|
|
|
|
|
|