How can I display something during the execution of a SQL script on SQLServer?

前端 未结 4 1863
天涯浪人
天涯浪人 2021-01-05 04:09

For example. I have a database upgrade script for adding a column to a database table. It looks a little like this:

IF NOT Exists(SELECT * FROM SysColumns sc         


        
相关标签:
4条回答
  • 2021-01-05 04:44

    Use PRINT - it works from most SQL client applications. SELECT also works e.g

    PRINT 'column already exists or something'
    

    or

    SELECT 'column already exists or something'
    
    0 讨论(0)
  • 2021-01-05 04:47

    RAISERROR seems appropriate here. See here.

    0 讨论(0)
  • 2021-01-05 04:48

    you can use PRINT statement in SQL

    0 讨论(0)
  • 2021-01-05 04:49
    RAISERROR ('column already exists',0,1)  with nowait
    

    or

    print 'column already exists'
    
    0 讨论(0)
提交回复
热议问题