Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Setup / September 2005

Tip: Looking for answers? Try searching our database.

How to give User the option to cancel a script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Lionheart - 27 Sep 2005 05:02 GMT
Hi All,

I wrote a simple demo script to create and populate a SQL Server database.
However,  I need to test whether the database already exists and,  if so,
whether the user want to permit its deletion and recreation.  I want to
create and OK/Cancel msgbox from within the script.

Is this feasible.  If so,  what is/are the command(s)?

Below is the simple script.

TIA,
Richard

=========== Test.sql =============
CREATE DATABASE MyDB

GO

USE MyDB

GO

CREATE TABLE MyTable (

Fld1 varchar (64) NOT NULL,

Fld2 smallint NOT NULL,

Fld3 decimal (3, 1) NOT NULL,

Fld4 bit NOT NULL,

)

INSERT INTO MyTable (Fld1, Fld2, Fld3, Fld4)

VALUES ('Stuff', 1, 23.4, 255)

INSERT INTO MyTable (Fld1, Fld2, Fld3, Fld4)

VALUES ('More', 9, 87.6, 0)

GO
Hari Prasad - 27 Sep 2005 05:56 GMT
Hi,

In SQL Server you can not directly define a GUI to show a message box. For
displaying message bob you can use some programming tools
like .NET, VB, ... to do so.

THanks
Hari
SQL Server MVP

> Hi All,
>
[quoted text clipped - 40 lines]
>
> GO
Richard Lionheart - 28 Sep 2005 21:51 GMT
Hi Hari,

Thanks for the response.

> In SQL Server you can not directly define a GUI to
> show a message box. For displaying message boxes,
>  you can use some programming tools like
> .NET, VB, ... to do so.

OK.  I'd like to figure out what approach is easiest  to implement.  I'm
trying to give some level of protection to users so that don't step on their
own data.  How's this idea?:

I don't document the name of the database.  Then give the user an sql script
for populating the database, but with no USE stmt so they can't execute it
directly.  Instead, I tell the user to invoke a program I'll write that will
check for the existence of the database,  warn the user of potential
deletion if appropriate,  and update the database appropriately unless the
user objects.

With VB or C#,  I can easily create a temporary file that tests for the
existence of the data base,   prepends delete/go/create/go statements if
necessary,  followed by a prepended USE stmt.  The only question I have is
whether it's easy to get SQL Server to run this temporary script using VB/C#
commands.

Another alternative that might be easier,  it seems to me,  is Windows
Scripting Host.

I'm equally facile [ and equally inexperienced :-) ] in all of them.

Your opinion?

Thanks again,
Richard
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.