Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Can a list of columns be used with this?

$
0
0

I'm curious if there is a way to pass in a list of column names and possibly table names too instead of just using one of each in the code below.  Thanks in advance for any help!

IF EXISTS(select * from sys.columns 
            where Name = N'myColumn' and Object_ID = Object_ID(N'myTable'))
begin
    -- Column Exists
	PRINT N'The column exists';
end

ELSE 
	-- Column doesn't exist
	PRINT N'The column doesn''t exist';

GO



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>