Tuesday, February 24, 2015

of checking to see if a table already has a column in T-SQL and also of writing stuff to the console

IF EXISTS(SELECT * FROM sys.columns WHERE [name] = N'IsHairband' AND
      [object_id] = OBJECT_ID(N'Groups'))
   BEGIN
      PRINT 'Yes, there is a column.'
   END
ELSE
   BEGIN
      PRINT 'No, there is not a column.'
   END

No comments:

Post a Comment