Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql alter table add column if exists

IF NOT EXISTS (
  SELECT
    *
  FROM
    INFORMATION_SCHEMA.COLUMNS
  WHERE
    TABLE_NAME = 'table_name' AND COLUMN_NAME = 'col_name')
BEGIN
  ALTER TABLE table_name
    ADD col_name data_type NULL
END;
Source by tableplus.com #
 
PREVIOUS NEXT
Tagged: #sql #alter #table #add #column #exists
ADD COMMENT
Topic
Name
7+9 =