From: http://haacked.com/
IF NOT EXISTS ( SELECT * FROM [information_schema].[columns] WHERE table_name = 'Customer' AND table_schema = 'dbo' AND column_name = 'FavoriteColorId' ) BEGIN ALTER TABLE [dbo].[Customer] ADD FavoriteColorId int
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
IF NOT EXISTS ( SELECT * FROM [information_schema].[columns] WHERE table_name = 'Customer' AND table_schema = 'dbo' AND column_name = 'FavoriteColorId' ) BEGIN ALTER TABLE [dbo].[Customer] ADD FavoriteColorId int
You need to create an account or log in to post comments to this site.
» Retrieve MSSQL table informa... in sql server tsql mssql table microsoft column information properties sysproperties systables data type types length columns
» Case sensitivity in PostgreSQL in databases sql select database tables table column columns query postgresql postgre psql rdbm names name lower upper case lowercase uppercase statement
» Selecting different parts of... in time date sql timestamp mssql language query transact structured datetime parts part stamp only sub
» Fix orphaned users in MSSQL in users sql mssql microsoft data transact orphan orphaned user restore restoration restoring
» iSQL sucks, so make it work ... in sql unix linux tsql language query transact structured odbc isql unixodbc
» Randomly ordered results in ... in sql tsql
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails
Thanks in advance!