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 |
|
Kanati
Starting Member
36 Posts |
Posted - 2002-08-12 : 11:30:25
|
| I want to return a recordset and conditionally do "foo" on each record in the dataset. IE:SELECT * FROM FOO WHERE BLAH = 'Y' AND ACKNAME IS NOT NULL {Import a file located in column ack} {Process that file} {UPDATE FOO SET BLAH = 'N' but only on the current record} {next record}I have seen something similar I think... without cursors... but Ican't remember where. Also, are extended stored procedures frownedupon? I could write the process of importing, processing and updating the dataset in a powerbasic dll and save myself a major headache trying to learn advanced T-SQL on-the-fly so-to-speak (lotta hyphens there. :))Thanks a lot.Kanati |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-08-12 : 11:43:10
|
| You must have an identifier to distinguish rows so something likethis - use any unique fielddeclare @filename varchar(100)declare @id int,@maxid intselect @id = 0, @maxid = max(id) from tbl where Process = 'Y'while @id < @maxidbeginselect @id = min(id) from tbl where id > @idselect @filename = filename from tbl where id = @id/*import file here - dts, bcp, exe, ...and check that it is successfule.g. number of recs from control file*/update tbl set Process = 'N' where id = @idend==========================================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. |
 |
|
|
|
|
|