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
 SQL Server Development (2000)
 SQL Query

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"]
Go to Top of Page

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.
Go to Top of Page

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.
Go to Top of Page

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?
Go to Top of Page

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 snyntax

declare cursor urCursor on
select * from yourTable

set @@rowcount....something, I dont remember exaclty

while fetchNext is true
@somevar=urCursor
/*
do urOperation here ie copy to file
*/

Go to Top of Page

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
Go to Top of Page
   

- Advertisement -