home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,646 of 19,505   
   Gene Wirchenko to All   
   Keyboard Input in Scripts   
   25 May 12 14:03:25   
   
   XPost: microsoft.public.sqlserver.programming   
   From: genew@ocis.net   
      
   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   
    bbs@darkrealms.ca