0

I have a query that is generating further queries, things like this:

select 'exec uspd_thing "'||name||'"'
from sometable

Which produces this :

exec uspd_thing "name1"
exec uspd_thing "name2"

But isql requires a 'go' statement after each statement.

There is an option to change the command terminator (-c) but the new terminator still needs to appear on the same line.

Any suggestions/tips on how to do this kind of thing... I guess I could post-process the results to add the 'go' lines...

Thanks, Chris

Chris Kimpton
  • 723
  • 9
  • 18

3 Answers3

4

AFAIK ISQL doesn't always need a go (or a ";", which will equally serve as a terminator. T-SQL commands may be allocated on consecutive lines without separator, the parser will handle that.

R. Pods

1

Try adding the go in the result:

select 'exec uspd_thing "'||name||'"'||char(10)||'go'||char(10)
from sometable
pascal
  • 126
  • 2
0

The post-process option via awk is as follows:

awk '{print $0}; /exec / {print "go"}' 
Chris Kimpton
  • 723
  • 9
  • 18