ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

°õ¦æ¶¥¬q¿ù»~13¡A«¬ºA¤£²Å¦X»Psql»yªk«üÂI

°õ¦æ¶¥¬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
  1. Sub ªÑ²¼¦X¨Ö´ú¸Õ()
  2. '

  3.     Sheets("Sheet4").Select
  4.     Range("A1").Select
  5.     With ActiveSheet.QueryTables.Add(Connection:= _
  6.         "ODBC;DRIVER=SQL Server;SERVER=.;UID=sa;PWD=wxyz1234;APP=Microsoft Office 2003;WSID=CS5111;DATABASE=stock" _
  7.         , Destination:=Range("A1"))
  8.         .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")
  9.         .Name = "¨Ó¦Û "
  10.         .FieldNames = True
  11.         .RowNumbers = False
  12.         .FillAdjacentFormulas = False
  13.         .PreserveFormatting = True
  14.         .RefreshOnFileOpen = False
  15.         .BackgroundQuery = True
  16.         .RefreshStyle = xlInsertDeleteCells
  17.         .SavePassword = True
  18.         .SaveData = True
  19.         .AdjustColumnWidth = True
  20.         .RefreshPeriod = 0
  21.         .PreserveColumnInfo = True
  22.         .Refresh BackgroundQuery:=False
  23.     End With

  24. End Sub
½Æ»s¥N½X
  1. Sub ªÑ²¼¦X¨Ö´ú¸Õ()
  2. '

  3.     Sheets("Sheet4").Select
  4.     Range("A1").Select
  5.     With ActiveSheet.QueryTables.Add(Connection:= _
  6.         "ODBC;DRIVER=SQL Server;SERVER=.;UID=sa;PWD=wxyz1234;APP=Microsoft Office 2003;WSID=CS5111;DATABASE=stock" _
  7.         , Destination:=Range("A1"))
  8.         .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")
  9.         .Name = "¨Ó¦Û "
  10.         .FieldNames = True
  11.         .RowNumbers = False
  12.         .FillAdjacentFormulas = False
  13.         .PreserveFormatting = True
  14.         .RefreshOnFileOpen = False
  15.         .BackgroundQuery = True
  16.         .RefreshStyle = xlInsertDeleteCells
  17.         .SavePassword = True
  18.         .SaveData = True
  19.         .AdjustColumnWidth = True
  20.         .RefreshPeriod = 0
  21.         .PreserveColumnInfo = True
  22.         .Refresh BackgroundQuery:=False
  23.     End With

  24. End Sub
½Æ»s¥N½X

½Ð°Ý.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¤£¬O­n¬Û¦P«¬ºAªº¡A¤£µM«ç·|¡u°õ¦æ¶¥¬q¿ù»~13¡v¡A½Ð°Ý«ç»ò§ï¦¨¬Û¦P«¬ºA©O¡H

½Ð°ª¤â«ü¾É¤@¤U¡H

ÁÂÁÂ

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD