Leigh

None - It was only an example on how to use EXECUTE() to execute a statement
and also
it check for exisitence of a the table in the system catalogs (Sysobjects)

Regards
Neven


----- Original Message -----
From: Leigh Wanstead <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Sent: Tuesday, 20 June 2000 07:03
Subject: Re: [DUG]: How to drop database using delphi in MS SQL Server 7?


> Dear Neven,
>
> Thank you for your reply.
>
> I have a question for you. What is difference between your code and if I
> directly submit drop database sql statement if by ISQL?
>
> I look forward to hearing from you.
>
> Best Regards
> Leigh Wanstead
>
> ----- Original Message -----
> From: Neven MacEwan <[EMAIL PROTECTED]>
> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> Sent: Monday, June 19, 2000 1:04 PM
> Subject: Re: [DUG]: How to drop database using delphi in MS SQL Server 7?
>
>
> > Leigh
> >
> > Heres a stored proc I uses to clear out all databases
> >
> > CREATE PROC EmptyTables @TableName VARCHAR(255) = null
> > AS
> > BEGIN
> >   DECLARE
> >     @DoTable     VARCHAR(255),
> >     @SQL            VARCHAR(255)
> >
> >    DECLARE table_cursor CURSOR FOR
> >      SELECT name
> >      FROM sysobjects
> >      WHERE xtype = 'U' and (name = @TableName or @TableName is null)
> >   OPEN table_cursor
> >   FETCH NEXT FROM table_cursor INTO @DoTable
> >   WHILE @@FETCH_STATUS = 0
> >   BEGIN
> >     SET @SQL = 'DELETE FROM '+@DoTable
> >     EXECUTE(@SQL)
> >     FETCH NEXT FROM table_cursor INTO @DoTable
> >   END
> >   CLOSE table_cursor
> >   DEALLOCATE table_cursor
> > END
> >
> >
> > change delete from to drop and you got your baby
> > note the query
> >     SELECT name
> >      FROM sysobjects
> >      WHERE xtype = 'U'
> >
> > which gives you a list of user tables
> >
> > Regards Neven
> > N.K. MacEwan B.E. E&E
> > [EMAIL PROTECTED]
> >
> > ----- Original Message -----
> > From: Leigh Wanstead <[EMAIL PROTECTED]>
> > To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> > Sent: Monday, 19 June 2000 21:25
> > Subject: [DUG]: How to drop database using delphi in MS SQL Server 7?
> >
> >
> > > Happy day,
> > >
> > > I know how to use sql script to drop a database in MS SQL Server 7.
But
> I
> > > want to develop an application to make that procedure more user
> friendly.
> > I
> > > mean if database does not exist, tell user nothing to do. If got other
> > user
> > > using database, SQL server maybe return error message tell me I can
not
> > drop
> > > it, I want to transfer the message to user.
> > >
> > > I am using BDE 5.11.
> > > Delphi 5 Enterprise 5.01
> > > MS SQL Server 7
> > >
> > > I guess someone already did that. I am happy to not reinvent the wheel
> if
> > > someone would like to share their knowledge.
> > >
> > > Thanks in advance.
> > >
> > > I look forward to hearing from you.
> > >
> > > Best Regards
> > > Leigh Wanstead
> > >
________________________________________________________________________
> > > Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com
> > >
> >
>
> --------------------------------------------------------------------------
> > -
> > >     New Zealand Delphi Users group - Delphi List -
[EMAIL PROTECTED]
> > >                   Website: http://www.delphi.org.nz
> > >
> >
>
> --------------------------------------------------------------------------
> -
> >     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> >
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to