Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1077

Keyboard Input in Scripts

From Gene Wirchenko <genew@ocis.net>
Newsgroups comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming
Subject Keyboard Input in Scripts
Date 2012-05-25 14:03 -0700
Organization A noiseless patient Spider
Message-ID <8nrvr79atdr001tg6g60sds609mktkhnm6@4ax.com> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


Dear SQLers:

     Is there a way to get keyboard input while executing a script?

     I have done a bit of looking and can not find it.  I do not know
what to call it.  Does it exist?

     If nothing else, I would like to be able to have a warning for
some scripts, say
          This script drops the CBS3 database and recreates it empty.
          All existing data in the CBS3 database will be lost.
          Are you quite sure that you wish to do this? _

     It is useful to have a testing script to blow away a database. It
is not so useful to have it run by accident!

     I could also write some useful little utilities if keyboard input
is available.  (This could be much more flexible than templates.)

     Failing this, what sorts of kludges are available?

     One that I thought of is checking if a certain database exists
and proceeding only if it does and then deleting it.  Is this safe?
Reliable?  (Yes, I know the multi-user issues, but on a development
box used by only one person?)

***** Start of P-code *****
if ReallyDoIt database does not exist
   begin
   print 'This script drops the CBS3 database and recreates it empty.'
   print 'All existing data in the CBS3 database will be lost.'
   print 'If you really want to do this, create database ReallyDoIt,'
   print 'and rerun this script.'
   print 'Aborting script.'
   set noexec on
   end
drop database ReallyDoIt
if drop failed
   begin
   print 'drop database ReallyDoIt failed.'
   print 'Aborting script.'
   set noexec on
   end
<script actions>
set noexec off
***** End of P-code *****

Sincerely,

Gene Wirchenko

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

Keyboard Input in Scripts Gene Wirchenko <genew@ocis.net> - 2012-05-25 14:03 -0700
  Re: Keyboard Input in Scripts Erland Sommarskog <esquel@sommarskog.se> - 2012-05-25 23:24 +0200
    Re: Keyboard Input in Scripts Gene Wirchenko <genew@ocis.net> - 2012-05-27 18:57 -0700
      Re: Keyboard Input in Scripts Erland Sommarskog <esquel@sommarskog.se> - 2012-05-28 07:40 +0000

csiph-web