Sonntag, 9. Mai 2010

About the use of SQL-Server Print Statement

In the old days, when I did my ad-hoc SQL using T-SQL in the Query-Analyzer, it was natural to use print statements, when to give back some feedback to the user.

Today using SQL-Server Management Studio, half the time I display the results in grid and as long as it looks reasonable, I won't switch to the message tab.

With SQL-Server the use  print in T-SQL is rather easy. While in former days you could only emit one string or variable, with todays versions you can use expressions.

I'm not going to speak about Orcales DBMS_OUTPUT package in length here. Remember SET server output on. And OK with 10 g they even got SET SERVEROUTPUT ON SIZE UNLIMITED, i.e. it became an option to use.

But acessing your database from applications or a PowerShell module like SQLPSX,it becomes more difficult to collect the print output.
For SQL-Server it would be possible, that means I know code to get the output.
While with Oracle I have only some vague ideas, how to do it (requiring to use connections) .

Conculsion: I'm starting to rewrite my scripts, using select @msg msg instead of print @msg.

Bernd

Keine Kommentare:

Kommentar veröffentlichen