About 776,000 results
Open links in new tab
  1. Add column to SQL Server - Stack Overflow

    Dec 19, 2022 · ALTER TABLE YourTable ADD Bar INT NOT NULL DEFAULT(0) /*Adds a new int column existing rows will be given the value zero*/ In SQL Server 2008 the first one is a …

  2. sql server - Altering SQL table to add column - Stack Overflow

    I currently have a table with four columns - i wanted to add a fifth column but having some trouble. I open the table in sql server studio management 2008 and i added the column info like so: C...

  3. How to add a column with a default value to an existing table in …

    Jun 21, 2016 · ALTER TABLE [dbo.table_name] ADD [Column_Name] BIT NOT NULL Default ( 0 ) Here is another way to add a column to an existing database table with a default value. A …

  4. sql - Alter Table Add Column Syntax - Stack Overflow

    I'm trying to programmatically add an identity column to a table Employees. Not sure what I'm doing wrong with my syntax. ALTER TABLE Employees ADD COLUMN EmployeeID int NOT …

  5. Add a column to a table with a default value equal to the value of …

    Apr 21, 2017 · The Instead Of Insert trigger is exactly the correct answer unless the column you want to use for the default value is an identity column, as mentioned above, since Instead Of …

  6. Add a column to a table, if it does not already exist

    Jan 15, 2012 · IF COLUMNPROPERTY(OBJECT_ID('dbo.Person'), 'ColumnName', 'ColumnId') IS NULL BEGIN ALTER TABLE Person ADD ColumnName VARCHAR(MAX) NOT NULL …

  7. Adding multiple columns AFTER a specific column in MySQL

    I need to add multiple columns to a table but position the columns after a column called lastname. I have tried this: ALTER TABLE `users` ADD COLUMN ( `count` smallint(6) NOT NULL, `log`

  8. insert a NOT NULL column to an existing table - Stack Overflow

    As an option you can initially create Null-able column, then update your table column with valid not null values and finally ALTER column to set NOT NULL constraint:

  9. How to add column if not exists on PostgreSQL? - Stack Overflow

    Sep 26, 2012 · DO $$ BEGIN BEGIN ALTER TABLE <table_name> ADD COLUMN <column_name> <column_type>; EXCEPTION WHEN duplicate_column THEN RAISE …

  10. SQL Server add auto increment primary key to existing table

    As the title, I have an existing table which is already populated with 150000 records. I have added an Id column (which is currently null). I'm assuming I can run a query to fill this column with …