Wednesday, October 10, 2012

Interaction with SQL Studio

This is actually not recommend since SQL is not for user interaction purpose.
and my stupid way which actually is IN PROCESSING when waiting for user to feedback.
Here you go. (the example)
You need 2 interface.

first screen:
create table T1(a varchar(1))

-- run this 1 as main
declare @answer varchar(250)
while @answer is null
print 'Enter Yes or No'
select @answer=a from T1
if (select a from T1)='N'  and (select a from T1) is not null
print 'You reject'
print 'You Accept'
waitfor delay '0:0:5'

-- get interaction in second screen
second screen:
when after run the main script.
every 5 second it will track the table T1.
So you can insert 'N' into T1 (start with empty table) as reject.
else insert other as accept.