I am wondering if I add a column to my table using:
alter table Jobs
add Complete boolean
Will this erase all of the data that is currently in my table? I am using SQL Server Management Studio 2012
Not at all. This adds a column whose value is NULL, but it has no direct effect on the data already in the table.
As a note: boolean is not a data type in SQL Server, so that particular statement will not work. You can use bit, tinyint, smallint, or int instead. Or a char(1) to store 'T' and 'F'.
And a second note: If your table is very large, then adding a column can be take a while, because all the data may need to be rewritten. Although the values are NULL, each page in SQL Server contains a bit for the NULL values in all the columns. If this steps over a byte boundary, then data needs to be rearranged on the page -- and perhaps new pages allocated for the data. In any case, each page needs to be modified to include the NULL values. For this reason, it is recommended to add columns to empty tables, if possible.
No it will not erase your data. It will add a column and all the existing data will be assigned null values in this column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With