本文介绍了在SQLServer上执行SQL脚本期间如何显示某些内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如。我有一个数据库升级脚本,用于向数据库表添加列。看起来有点像这样:
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, SysObjects so
WHERE sc.Name = 'dealer_number'
AND so.Name = 'collector'
AND so.Type= 'U'
AND so.id = sc.id)
BEGIN
-- SQL for creating column
END
ELSE
BEGIN
-- notify user that column already exists
END
如何通知用户该列已存在?
How do I notify the user that the column already exists?
推荐答案
RAISERROR ('column already exists',0,1) with nowait
或
print 'column already exists'
这篇关于在SQLServer上执行SQL脚本期间如何显示某些内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!