Skip to content

Instantly share code, notes, and snippets.

@EmpeRoar
Last active July 15, 2022 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EmpeRoar/93cd245ef73fc37d417f550c67253ba4 to your computer and use it in GitHub Desktop.
Save EmpeRoar/93cd245ef73fc37d417f550c67253ba4 to your computer and use it in GitHub Desktop.
if not exists (SELECT * FROM sysobjects INNER JOIN syscolumns ON
sysobjects.id = syscolumns.id
WHERE sysobjects.name = N'Test' AND syscolumns.name = N'xxx')
ALTER TABLE [dbo].[Test] ADD xxx NVARCHAR(MAX)
ALTER TABLE [dbo].[Test]
DROP COLUMN xxx;
----------------------
IF COL_LENGTH('dbo.Test', 'xxx') IS NULL
BEGIN
ALTER TABLE [dbo].[Test] ADD xxx NVARCHAR(MAX)
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment