Solved

MsgBox in SQL?

Posted on 2007-03-27
3
5,635 Views
Last Modified: 2012-08-13
Is there a way to print out message like with VBScript's MsgBox() but in SQL?  This would be for debugging my SQL code; as an example I'd like to do something like this (but I need the SQL equivalent):

IF TRUE
msgBox 'This is true!'
ELSE
msgBox 'This is false!"
END IF

I've tried the PRINT command in SQL but nothing happens or at least I'm not sure where it gets printed to?  I'd prefer something like a message box.  Any ideas?
0
Comment
Question by:irishm20
3 Comments
 
LVL 42

Assisted Solution

by:dqmq
dqmq earned 20 total points
ID: 18801629
There is no message box.   You can  use SELECT 'This is true'
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 30 total points
ID: 18801635
MS SQL Server?

No, there is no msgBox -- primarily b/c the SQL Server runs its own process, likely under a different user context, likely on a different machine.

If you're testing your code in Query Analyzer, Print should work for you.

Otherwise, you may need to SELECT something to debug by.
0
 

Author Comment

by:irishm20
ID: 18801700
DanielWilson...

Thanks for the explanation... I will use Query Analyzer to debug.  I was trying to debug inside of a DTS package workspace but I think I limit myself to just scripts if I want to debug in that screen.  Thanks again.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
LTrim & Double Space Correction 5 40
SQL Select in Access 2003 3 23
SQL Quer 4 21
SQL Availablity Groups Shared Path 2 14
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question