Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

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

share|improve this answer

Try adding the go in the result:

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

The post-process option via awk is as follows:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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