Solved

MsgBox in SQL?

Posted on 2007-03-27
3
5,873 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

734 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