PRINT statement in T-SQL

后端 未结 6 773
有刺的猬
有刺的猬 2020-11-30 22:57

Why does the PRINT statement in T-SQL seem to only sometimes work? What are the constraints on using it? It seems sometimes if a result set is generated, it becomes a null

6条回答
  •  情话喂你
    2020-11-30 23:27

    So, if you have a statement something like the following, you're saying that you get no 'print' result?

    select * from sysobjects
    PRINT 'Just selected * from sysobjects'

    If you're using SQL Query Analyzer, you'll see that there are two tabs down at the bottom, one of which is "Messages" and that's where the 'print' statements will show up.
    If you're concerned about the timing of seeing the print statements, you may want to try using something like

    raiserror ('My Print Statement', 10,1) with nowait

    This will give you the message immediately as the statement is reached, rather than buffering the output, as the Query Analyzer will do under most conditions.

提交回复
热议问题