讯息102,第15级

时间:2019-03-14 07:42:00

标签: sql-server tsql stored-procedures

create procedure sp_AD_CAREOF_COL
(
    @tablename as varchar(200), 
    @column as varchar(200), 
    @column2 as varchar(200)
)

As
    if col_length(@tablename, @column) is null
    begin
        alter table auto
        add careof varchar(200)
        print ('the care of column is added')
    end
    else if COL_LENGTH(@tablename,@column2) is null
    begin
        alter table auto
        add ACCTG_CAREof varchar(200)
        print 'the ACCTG_CAREOF column are added'
    end
    else
    begin
        print'BOTH COLUMN ARE PRESENT'
    end

exec sp_AD_CAREOF_COL ('auto','careof','acctg_careof');

使用此代码时,我收到了msg 102错误,任何人都可以帮助我解决此问题。

1 个答案:

答案 0 :(得分:2)

您的EXEC command is wrong,请改用以下内容(删除()):

EXEC sp_AD_CAREOF_COL 'auto', 'careof', 'acctg_careof';

您还可以使用以下内容:

EXEC sp_AD_CAREOF_COL @tablename = 'auto', @column = 'careof', @column2 = 'acctg_careof'