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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-04-10 : 07:51:28
|
| arindam writes "Hello I have a simple sql database With 2 table .But data of one table is very important for me , In every month we are inserting new new data in that table . But we are not keeping any record of that .So I want at the end of the month, to download all the data of that table in aexcel sheet . I am using it with ASP. So i am just trying to keep a "download report"button on my page So anybody will click on that button ,should be able to download the total reprot of that particular table in a excel file .....Can u please help me .....How can I do that ?ThankyouArindam" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-04-10 : 09:23:03
|
| dts can export to an excel spreadsheet but probably better to export to a csv file.If this is important then do the export every day - you can change the earliest date to export at the end of the month.Easiest is bcpjust schedule to run every night something likedeclare @d varchar(8), @cmd varchar(1000)select @d = '20030401'select @cmd = 'bcp "select * from mydb.dbo.mytbl where @updateddate >= ''' + @d + '''" queryout c:\dir\mytbl' + @d + '_' + convert(varchar(8),getdate(),112) + '.txt -c'exec master..xp_cmdshell @cmdYou can calculate the start of the month if you wish.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-04-10 : 13:16:09
|
| Instead of exporting the data, why don't you just move the data into another table that is an archive table? I would rather have the data in SQL Server than in a bunch of files. If you do it this way, you can easily query the data.But if you really want the data exported to an Excel file, then DTS is the way to go.Tara |
 |
|
|
|
|
|