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

link|improve this question

feedback

3 Answers

up vote 3 down vote accepted

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

link|improve this answer
feedback

Try adding the go in the result:

select 'exec uspd_thing "'||name||'"'||char(10)||'go'||char(10)
from sometable
link|improve this answer
feedback

The post-process option via awk is as follows:

awk '{print $0}; /exec / {print "go"}'
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.