Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Importing data into excel

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-07-14 : 08:51:51
Björn writes "Hello,

i have a rather big problem, but i think there exists a rather simple solution to it. I want to import set of numbers into excel. these sets consist of 3 things.
1) an id number
2)a date
3) a value (price)

now i would like to import various kind of these id numbers simultanously but only where there is a price for all of them for a certain date. e.g

id1 begins in the year 2000
id2 begins in the year 2001
id3 begins in the year 2001
and id4 begins in the year 2004

now i do not know previously when each one starts i just know when the earliest and the latest id starts so i would like to write something like the following:

---------------------------------------------------------------Sql = "SELECT ts_histdata_isin, ts_histdata_date, ts_histdata_close FROM histdata WHERE ts_histdata_isin IN ('"
For i = 0 To UBound(isin)
Sql = Sql + CStr(isin(i)) + "','"
Next i
Sql = Left(Sql, Len(Sql) - 2) + ")"
Sql = Sql + " AND ts_histdata_date IN ('"

For i = 0 To UBound(datearray)
Sql = Sql + CStr(datearray(i)) + "','"
Next i
Sql = Left(Sql, Len(Sql) - 2) + ")"

Sql = Sql + " ORDER BY ts_histdata_date ASC, ts_histdata_isin ASC group by ts_histdata_date"
---------------------------------------------------------------

but here i get


id1 date price1

for the dates between 2000 and 2001
then it follows in the excel sheet with

id1 date price1
id2 date price2
id3 date price3 between the years 2001 and 2004 and finally i get what i only want to have

id1 date price1
id2 date price2
id3 date price3
id4 date price4
for the year 2005 till today (or the last date)

is there a different solution to this? i have tried everything but do not get it to work

any answer would be very appreciated

thank you

Björn"
   

- Advertisement -