By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,663 Members | 1,477 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,663 IT Pros & Developers. It's quick & easy.

Executing multiple sql DDL statements

P: n/a
Hidely hodley everyone

I'd like to run a series of of sql ddl statements against an msde2000
server. Normally I just deploy cmd file that impliments as osql statement,
but I'd like to store the 'patch' in an mdb file and use say ado or even
a passthrough statement to execute it.

The problem I've got Is I access (?) seems to require me to execute one
ddl at a time, otherwise the script breaks at the 'go' statement. While I
_could_ do this - I don't really want to.

Any solutions,ideas,tips,wraps on knuckles etc?
thanks
Glenn
Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a

Do it as a Passthrough query. With a passthrough Access doen's interpret the
SQL it just passes it to the server to interpret and run.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...
Hidely hodley everyone

I'd like to run a series of of sql ddl statements against an msde2000
server. Normally I just deploy cmd file that impliments as osql statement,
but I'd like to store the 'patch' in an mdb file and use say ado or even
a passthrough statement to execute it.

The problem I've got Is I access (?) seems to require me to execute one
ddl at a time, otherwise the script breaks at the 'go' statement. While I
_could_ do this - I don't really want to.

Any solutions,ideas,tips,wraps on knuckles etc?
thanks
Glenn

Nov 13 '05 #2

P: n/a
Hi terry
I get the same problem with a passthrough query. I get the impression with
adodb.commands access doesn't interpret either e.g.

To impliment a script that executes this sql on the server:

"ALTER PROCEDURE ThisProc() AS
SET NO COUNT OFF
EXEC dbo.someprocedure
SELECT something from somewhere

GO

DROP PROCEDURE dbo.DontWantThisProcanymore
GO

ALTER FUNCTION dbo.FunctionToFix()
RETURNS INT AS
BEGIN
RETURN 10
END
GO"

I've tried both making it the body of a passthrough query, and
I've tried using something like this (please ignore obvious errors, just
pulling air code here)

sub ApplyMyPatch
dim cmd as new adodb.command
dim DDLScript as string

DDLScript = GetTheScriptContentFromSomewhere()
'In this case the script is the code above

set cmd.activeconnection=AppropriateConnection
cmd.commandtext=DDLScript
cmd.commandtype=acCmdText
cmd.execute

In either case the I get the same error & that is that it chokes on the go
statement. i.e. invalid syntax near go

Any one of these statements works fine

thx
Glenn

On Mon, 05 Jul 2004 10:13:38 +0100, Terry Kreft wrote:

Do it as a Passthrough query. With a passthrough Access doen's interpret the
SQL it just passes it to the server to interpret and run.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...
Hidely hodley everyone

I'd like to run a series of of sql ddl statements against an msde2000
server. Normally I just deploy cmd file that impliments as osql statement,
but I'd like to store the 'patch' in an mdb file and use say ado or even
a passthrough statement to execute it.

The problem I've got Is I access (?) seems to require me to execute one
ddl at a time, otherwise the script breaks at the 'go' statement. While I
_could_ do this - I don't really want to.

Any solutions,ideas,tips,wraps on knuckles etc?
thanks
Glenn


Nov 13 '05 #3

P: n/a
It's SQL returning the error then.

Try it without GO and see if that works for you.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...
Hi terry
I get the same problem with a passthrough query. I get the impression with
adodb.commands access doesn't interpret either e.g.

To impliment a script that executes this sql on the server:

"ALTER PROCEDURE ThisProc() AS
SET NO COUNT OFF
EXEC dbo.someprocedure
SELECT something from somewhere

GO

DROP PROCEDURE dbo.DontWantThisProcanymore
GO

ALTER FUNCTION dbo.FunctionToFix()
RETURNS INT AS
BEGIN
RETURN 10
END
GO"

I've tried both making it the body of a passthrough query, and
I've tried using something like this (please ignore obvious errors, just
pulling air code here)

sub ApplyMyPatch
dim cmd as new adodb.command
dim DDLScript as string

DDLScript = GetTheScriptContentFromSomewhere()
'In this case the script is the code above

set cmd.activeconnection=AppropriateConnection
cmd.commandtext=DDLScript
cmd.commandtype=acCmdText
cmd.execute

In either case the I get the same error & that is that it chokes on the go
statement. i.e. invalid syntax near go

Any one of these statements works fine

thx
Glenn

On Mon, 05 Jul 2004 10:13:38 +0100, Terry Kreft wrote:

Do it as a Passthrough query. With a passthrough Access doen's interpret the SQL it just passes it to the server to interpret and run.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...
Hidely hodley everyone

I'd like to run a series of of sql ddl statements against an msde2000
server. Normally I just deploy cmd file that impliments as osql statement, but I'd like to store the 'patch' in an mdb file and use say ado or even a passthrough statement to execute it.

The problem I've got Is I access (?) seems to require me to execute one
ddl at a time, otherwise the script breaks at the 'go' statement. While I _could_ do this - I don't really want to.

Any solutions,ideas,tips,wraps on knuckles etc?
thanks
Glenn

Nov 13 '05 #4

P: n/a
This is the reference I was looking for, from BOL

"GO is not a Transact-SQL statement; it is a command recognized by the osql
and isql utilities and SQL Query Analyzer."

So it won't work in a Passthrough query.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...
Hi terry
I get the same problem with a passthrough query. I get the impression with
adodb.commands access doesn't interpret either e.g.

To impliment a script that executes this sql on the server:

"ALTER PROCEDURE ThisProc() AS
SET NO COUNT OFF
EXEC dbo.someprocedure
SELECT something from somewhere

GO

DROP PROCEDURE dbo.DontWantThisProcanymore
GO

ALTER FUNCTION dbo.FunctionToFix()
RETURNS INT AS
BEGIN
RETURN 10
END
GO"

I've tried both making it the body of a passthrough query, and
I've tried using something like this (please ignore obvious errors, just
pulling air code here)

sub ApplyMyPatch
dim cmd as new adodb.command
dim DDLScript as string

DDLScript = GetTheScriptContentFromSomewhere()
'In this case the script is the code above

set cmd.activeconnection=AppropriateConnection
cmd.commandtext=DDLScript
cmd.commandtype=acCmdText
cmd.execute

In either case the I get the same error & that is that it chokes on the go
statement. i.e. invalid syntax near go

Any one of these statements works fine

thx
Glenn

On Mon, 05 Jul 2004 10:13:38 +0100, Terry Kreft wrote:

Do it as a Passthrough query. With a passthrough Access doen's interpret the SQL it just passes it to the server to interpret and run.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...
Hidely hodley everyone

I'd like to run a series of of sql ddl statements against an msde2000
server. Normally I just deploy cmd file that impliments as osql statement, but I'd like to store the 'patch' in an mdb file and use say ado or even a passthrough statement to execute it.

The problem I've got Is I access (?) seems to require me to execute one
ddl at a time, otherwise the script breaks at the 'go' statement. While I _could_ do this - I don't really want to.

Any solutions,ideas,tips,wraps on knuckles etc?
thanks
Glenn

Nov 13 '05 #5

P: n/a

Ok - that makes sense of why it doesnt "go". However it also doesn't
function without the GO statements, breaking at a new ddl statements.
Multiple select or manipulation statments seem fine

thx
GLenn
n Mon, 05 Jul 2004 15:37:53 +0100, Terry Kreft wrote:
It's SQL returning the error then.

Try it without GO and see if that works for you.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...
Hi terry
I get the same problem with a passthrough query. I get the impression with
adodb.commands access doesn't interpret either e.g.

To impliment a script that executes this sql on the server:

"ALTER PROCEDURE ThisProc() AS
SET NO COUNT OFF
EXEC dbo.someprocedure
SELECT something from somewhere

GO

DROP PROCEDURE dbo.DontWantThisProcanymore
GO

ALTER FUNCTION dbo.FunctionToFix()
RETURNS INT AS
BEGIN
RETURN 10
END
GO"

I've tried both making it the body of a passthrough query, and
I've tried using something like this (please ignore obvious errors, just
pulling air code here)

sub ApplyMyPatch
dim cmd as new adodb.command
dim DDLScript as string

DDLScript = GetTheScriptContentFromSomewhere()
'In this case the script is the code above

set cmd.activeconnection=AppropriateConnection
cmd.commandtext=DDLScript
cmd.commandtype=acCmdText
cmd.execute

In either case the I get the same error & that is that it chokes on the go
statement. i.e. invalid syntax near go

Any one of these statements works fine

thx
Glenn

On Mon, 05 Jul 2004 10:13:38 +0100, Terry Kreft wrote:
>
> Do it as a Passthrough query. With a passthrough Access doen's interpret the > SQL it just passes it to the server to interpret and run.
>
>
> --
> Terry Kreft
> MVP Microsoft Access
>
>
> "Glenn Davy" <gS***********@tpg.com.au> wrote in message
> news:pa****************************@tpg.com.au...
>> Hidely hodley everyone
>>
>> I'd like to run a series of of sql ddl statements against an msde2000
>> server. Normally I just deploy cmd file that impliments as osql statement, >> but I'd like to store the 'patch' in an mdb file and use say ado or even >> a passthrough statement to execute it.
>>
>> The problem I've got Is I access (?) seems to require me to execute one
>> ddl at a time, otherwise the script breaks at the 'go' statement. While I >> _could_ do this - I don't really want to.
>>
>> Any solutions,ideas,tips,wraps on knuckles etc?
>> thanks
>> Glenn
>>
>>


Nov 13 '05 #6

P: n/a
Have you set the "Returns Records" property to No, if it's purely DDL then
you should do this.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...

Ok - that makes sense of why it doesnt "go". However it also doesn't
function without the GO statements, breaking at a new ddl statements.
Multiple select or manipulation statments seem fine

thx
GLenn
n Mon, 05 Jul 2004 15:37:53 +0100, Terry Kreft wrote:
It's SQL returning the error then.

Try it without GO and see if that works for you.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...
Hi terry
I get the same problem with a passthrough query. I get the impression with adodb.commands access doesn't interpret either e.g.

To impliment a script that executes this sql on the server:

"ALTER PROCEDURE ThisProc() AS
SET NO COUNT OFF
EXEC dbo.someprocedure
SELECT something from somewhere

GO

DROP PROCEDURE dbo.DontWantThisProcanymore
GO

ALTER FUNCTION dbo.FunctionToFix()
RETURNS INT AS
BEGIN
RETURN 10
END
GO"

I've tried both making it the body of a passthrough query, and
I've tried using something like this (please ignore obvious errors, just pulling air code here)

sub ApplyMyPatch
dim cmd as new adodb.command
dim DDLScript as string

DDLScript = GetTheScriptContentFromSomewhere()
'In this case the script is the code above

set cmd.activeconnection=AppropriateConnection
cmd.commandtext=DDLScript
cmd.commandtype=acCmdText
cmd.execute

In either case the I get the same error & that is that it chokes on the go statement. i.e. invalid syntax near go

Any one of these statements works fine

thx
Glenn

On Mon, 05 Jul 2004 10:13:38 +0100, Terry Kreft wrote:

>
> Do it as a Passthrough query. With a passthrough Access doen's interpret
the
> SQL it just passes it to the server to interpret and run.
>
>
> --
> Terry Kreft
> MVP Microsoft Access
>
>
> "Glenn Davy" <gS***********@tpg.com.au> wrote in message
> news:pa****************************@tpg.com.au...
>> Hidely hodley everyone
>>
>> I'd like to run a series of of sql ddl statements against an
msde2000 >> server. Normally I just deploy cmd file that impliments as osql

statement,
>> but I'd like to store the 'patch' in an mdb file and use say ado or

even
>> a passthrough statement to execute it.
>>
>> The problem I've got Is I access (?) seems to require me to execute one >> ddl at a time, otherwise the script breaks at the 'go' statement.

While I
>> _could_ do this - I don't really want to.
>>
>> Any solutions,ideas,tips,wraps on knuckles etc?
>> thanks
>> Glenn
>>
>>

Nov 13 '05 #7

P: n/a
Hi Terry - Thanks for all your help so far. I hadn't done this but, I have
now, but I still get the same error. bumma
thanks again
Glenn

Have you set the "Returns Records" property to No, if it's purely DDL then
you should do this.
--
Terry Kreft
MVP Microsoft Access
"Glenn Davy" <gS***********@tpg.com.au> wrote in message
news:pa****************************@tpg.com.au...

Ok - that makes sense of why it doesnt "go". However it also doesn't
function without the GO statements, breaking at a new ddl statements.
Multiple select or manipulation statments seem fine

thx
GLenn
n Mon, 05 Jul 2004 15:37:53 +0100, Terry Kreft wrote:
> It's SQL returning the error then.
>
> Try it without GO and see if that works for you.
>
>
> --
> Terry Kreft
> MVP Microsoft Access
>
>
> "Glenn Davy" <gS***********@tpg.com.au> wrote in message
> news:pa****************************@tpg.com.au...
>> Hi terry
>> I get the same problem with a passthrough query. I get the impression with >> adodb.commands access doesn't interpret either e.g.
>>
>> To impliment a script that executes this sql on the server:
>>
>> "ALTER PROCEDURE ThisProc() AS
>> SET NO COUNT OFF
>> EXEC dbo.someprocedure
>> SELECT something from somewhere
>>
>> GO
>>
>> DROP PROCEDURE dbo.DontWantThisProcanymore
>> GO
>>
>> ALTER FUNCTION dbo.FunctionToFix()
>> RETURNS INT AS
>> BEGIN
>> RETURN 10
>> END
>> GO"
>>
>> I've tried both making it the body of a passthrough query, and
>> I've tried using something like this (please ignore obvious errors, just >> pulling air code here)
>>
>> sub ApplyMyPatch
>> dim cmd as new adodb.command
>> dim DDLScript as string
>>
>> DDLScript = GetTheScriptContentFromSomewhere()
>> 'In this case the script is the code above
>>
>> set cmd.activeconnection=AppropriateConnection
>> cmd.commandtext=DDLScript
>> cmd.commandtype=acCmdText
>> cmd.execute
>>
>> In either case the I get the same error & that is that it chokes on the go >> statement. i.e. invalid syntax near go
>>
>> Any one of these statements works fine
>>
>> thx
>> Glenn
>>
>>
>>
>>
>>
>> On Mon, 05 Jul 2004 10:13:38 +0100, Terry Kreft wrote:
>>
>> >
>> > Do it as a Passthrough query. With a passthrough Access doen's interpret > the
>> > SQL it just passes it to the server to interpret and run.
>> >
>> >
>> > --
>> > Terry Kreft
>> > MVP Microsoft Access
>> >
>> >
>> > "Glenn Davy" <gS***********@tpg.com.au> wrote in message
>> > news:pa****************************@tpg.com.au...
>> >> Hidely hodley everyone
>> >>
>> >> I'd like to run a series of of sql ddl statements against an msde2000 >> >> server. Normally I just deploy cmd file that impliments as osql
> statement,
>> >> but I'd like to store the 'patch' in an mdb file and use say ado or
> even
>> >> a passthrough statement to execute it.
>> >>
>> >> The problem I've got Is I access (?) seems to require me to execute one >> >> ddl at a time, otherwise the script breaks at the 'go' statement. While > I
>> >> _could_ do this - I don't really want to.
>> >>
>> >> Any solutions,ideas,tips,wraps on knuckles etc?
>> >> thanks
>> >> Glenn
>> >>
>> >>
>>


Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.