Re: Why can't I execute this script in ADO?

From: Martijn Tonies (m.tonies_at_upscene!nospam!.com)
Date: 01/26/04


Date: Mon, 26 Jan 2004 22:53:19 +0100

Hi Petar,

> > > Thanks man. However, it would be nice to find a way to execute a
script
> > > files generated for/by SQL Server.
> > > I understand that "GO" has nothing to do with SQL standard, but
still...
> >
> > Even more, it has nothing to do with MS SQL Server. Read the
> > "books online" about "GO" -> it explicitly states that GO is a client
> > tool thing.
>
> Hmm, yes, this sucks... BTW, if it is of no secret, how did you (if you
did)
> solve those problems in Database Workbench?
> I checked your great tool, though I saw that you have two ways of SQL
> statements executing...

The "SQL" tab is to execute a single statement and it checks
for parameters (: in the sql statement, like with Delphi) and
can return a dataset, while the "Script" tab accepts a script
with "GO" items in it. For each "GO", Database Workbench
executes the lines it has collected from the script so far.

Basically:

script := '';
n := 0;
while n < lines.Count
do begin
  if UpperCase(lines[n]) <> 'GO'
  then script := script + lines[n] + #10#13
  else begin
     execute_the_statement(script);
      script := '';
    end;
  Inc(n);
end;

(although a bit more complex). So I'm handling the "GO" at
the client side as well :-)

--
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com


Relevant Pages

  • Re: ActiveX script works in DTS but not in job, why?
    ... Peter DeBetta, MVP - SQL Server ... As another test I saved the script as a .vbs file and tried running it, ... Microsoft OLE DB Provider for SQL Server ... 2000 databases including DTS packages. ...
    (microsoft.public.sqlserver.dts)
  • Re: Maintain production DB with changes from development DB
    ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. ... Or will I have to write a script to update all 4 servers? ...
    (microsoft.public.sqlserver.dts)
  • Re: Vista hosting XPe tools/db
    ... Are you running this script on the machine that actually has the SQL server ... machine hosting the database. ... i don't know if you can install a second instance of SQL ...
    (microsoft.public.windowsxp.embedded)
  • Re: ActiveX script works in DTS but not in job, why?
    ... Account that SQL Agent runs under and it is a Local Admin on the box. ... As another test I saved the script as a .vbs file and tried running it, ... Microsoft OLE DB Provider for SQL Server ... that would be since I need to be able to load DTS packages from either a SQL ...
    (microsoft.public.sqlserver.dts)
  • Re: Enterprise Manager Newbie Question
    ... a SQL backup is not a simple copy of the database files. ... Is it possible to write a script that one could run from a workstation and ...
    (microsoft.public.sqlserver.tools)

Loading