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 |
|
bharatsql
Starting Member
22 Posts |
Posted - 2006-04-06 : 14:46:10
|
| Hi,I have this strange requirement where I need a query that should pull data (one record at a time) from database on a distinct eship_id and should write to separate flat files. I shall handle the writing to flat files issue if some one can provide insight or query with the first part.Any clues!!!Thanks |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-04-06 : 15:04:04
|
just use BCP to export the data to a flat file.for getting one row at the time (although i don't know why would you do that)you can use a cursor. read about it in BOL.Go with the flow & have fun! Else fight the flow Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"] |
 |
|
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2006-04-06 : 15:05:10
|
| Depending on how many rows of data, and where you want to save these flat files, you may use some kind of front end app (VB, VB.net, or even MS Access) to create a set of data, then loop through it, and create flat file on each loop. |
 |
|
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2006-04-06 : 15:05:45
|
| Depending on how many rows of data, and where you want to save these flat files, you may use some kind of front end app (VB, VB.net, or even MS Access) to create a set of data, then loop through it, and create flat file on each loop. |
 |
|
|
bharatsql
Starting Member
22 Posts |
Posted - 2006-04-06 : 15:12:16
|
| Thanks but can you help me with a sql query which can just fetch one row at a time? |
 |
|
|
heze
Posting Yak Master
192 Posts |
Posted - 2006-04-06 : 16:42:08
|
| hereis just the idea, hope its useful, in cursors youll see the exact snyntaxdeclare cursor urCursor onselect * from yourTableset @@rowcount....something, I dont remember exacltywhile fetchNext is true@somevar=urCursor/*do urOperation here ie copy to file*/ |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-04-06 : 20:11:22
|
| bharatsql,SQL Query is just a Select Query. U can loop thru the whole record set , take one by one, do whatever u want.What is ur Front End tool. If it is VB or ASP or .Net, I might be able to help.Srinika |
 |
|
|
|
|
|
|
|