Check whether columns are present in a Table or not?

Rajesh_Kumar
Posted by Rajesh_Kumar under Sql Server category on | Points: 40 | Views : 3925
Declare @column_name varchar(50);
Set @column_name = N'Description';
If Exists(Select * From Sys.Columns Where Name = @column_name AND Object_Id = Object_Id(N'Employees'))
Begin
Print 'Column Name ' + @column_name + ' Exists';
End
Else
Print 'Column Name ' + @column_name + ' Does Not Exist';

Comments or Responses

Login to post response