Sometimes the Cache of SSMS gets “corrupted” or fails to update, this can lead to Red squiggles under column namnes, table names, basiacally anything (Also SSMS will claim the name does not exist with for instance the error message invalid column namn).
When this error lies in SSMS, then refreshing the cache is the solution, and this is done with “Ctrl-Shitf-R“
Tag Archives: SQLServer
SQLServer Adding a column to a table
Adding a column to existing table is not that hard. One thing to keep in mind, if the column is not nullable then a default value is mandatory.
ALTER TABLE {TABLENAME} ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL} CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE} |
Looking at the database structure (in MSSQL)
This query will show how the current database looks (what columns exists in what tables etc), the select might be a * instead but this is the info I find interesting.
select TABLE_NAME, COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH
from INFORMATION_SCHEMA.COLUMNS
order by TABLE_NAME, ORDINAL_POSITION