1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【SQL Server】まだ追加されてい場合のみ、列の追加を行う

Posted at

追加したい列が、既に存在する場合でもエラーにならない方法を調べたのでメモ

SQL
/* まだ追加されてい場合のみ、列の追加を行う */
IF COL_LENGTH('table_name','column_name') IS NULL
    BEGIN
        ALTER TABLE table_name ADD column_name INT
    END;
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?