PRINT statement in T-SQL

后端 未结 6 751
有刺的猬
有刺的猬 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:33

    Query Analyzer buffers messages. The PRINT and RAISERROR statements both use this buffer, but the RAISERROR statement has a WITH NOWAIT option. To print a message immediately use the following:

    RAISERROR ('Your message', 0, 1) WITH NOWAIT
    

    RAISERROR will only display 400 characters of your message and uses a syntax similar to the C printf function for formatting text.

    Please note that the use of RAISERROR with the WITH NOWAIT option will flush the message buffer, so all previously buffered information will be output also.

提交回复
热议问题