Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    84

    Unanswered: How do I implement ---prompt 'Enter 1 to continue or CTRL C to abort

    Hi Guys, I have a SQL block which I want to run based on some values in the DB
    -----------------
    I am implementing the check as follows..
    ---------------------
    PRINT 'Checking the DATABASE name and Schema Version '

    SET NOCOUNT ON
    CREATE TABLE chkversion (table_name VARCHAR(30), id INT, reason varchar(200))
    GO

    DECLARE @MSG CHAR(1)
    print @MSG
    GO

    /* Make sure user is running the right script and right db user */

    declare
    @ver varchar(100),
    @username varchar(100),
    @cnt int
    begin
    select @ver = value from propertytable where id = 33086
    select @cnt = count(*) from propertytable where parentid=5001 and propertyid = 726;
    select @username = db_name(dbid)from master.dbo.sysprocesses where status ='runnable'
    insert into chkversion (table_name, id, reason) values ('', -1, 'You are logging on Database - ' + @username)
    insert into error_report (table_name, id, reason) values ('', -1, 'Your agile database version is ' + @ver)
    if (@ver != '9.0.144'or @cnt !=0) begin
    insert into chkversion (table_name, id, reason) values ('', -1, 'STOP: Your Schema Version and/or database version are not at original 90SP2. Please abort!')
    end
    else
    insert into chkversion (table_name, id, reason) values ('', -1, 'PROCEED: You can run this script to upgrade your db schema from 9.0.144 to 9.0.178')
    end
    GO

    DECLARE @MSG CHAR(200)
    SELECT @MSG = convert(varchar(255), reason) from chkversion where id = -1
    print @MSG
    GO


    DECLARE @MSG CHAR(1)
    print @MSG
    GO
    SET NOCOUNT OFF
    ----------------------------------------------------------
    After this, I want user to press 1 to continue or CTRL +C to abort based on the output message from above.
    How Do I implement this feature?
    In Oracle, I use...
    Accept agproceed number prompt 'Enter 1 to continue or CTRL C to abort.';
    Kishore

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    If it's an unattended process, how can you expect a user input?


    For this type of situation I usually have a control table, and a job process table along with a job structure table that has empirical statistics collected on each step. Reaching a specific step may trigger an Operator notification, etc.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •