I'd like to perform an update on a database only when certain conditions are met. Hence, one of those conditions would be a positive answer from the user running the query. Basically, I'd like to display a message with a yes/no option for the user to choose from. If and only if the user user selects the YES option should we perform the update.
Inside a transact SQL "IF ... THEN", how can I achieve this?
Use a message box (assuming you are writing your application in VB)? You can't do it within Transact-SQL. That is as it should be, since user interaction is a client side issue, not a server side issue.
I understand that user interaction should be in the app, on the client side. However this code tidbit I'm trying to write will always be used directly in query analyzer for the manual triggering of modifications to the db. Problem is that I don't trust the people that will run it so I prefer to put as much "protection" in the code as possible to minimize chances of errors.
Although I was expecting a function directly in Transact SQL to do this, I guess I can live with calling a sp that references a VB script or another outside procedure.
i cant find that script anywhere!
it was cool, basically you ran the script in the QA and it prompted you (probably PRINT) for a value. you enter the value next to the name of the sp at the top of the script and it enters and then prompts you again
it did this about 3 or 4 times and then you get your output.
now this may have been a temp table and the sp asks for the next parameter based on an if statment and the config of the temp table.