Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all columns of a certain type in all tables in a SQL Server database

How can I find all columns of a certain type (for example NTEXT) in all tables in a SQL Server database?

I am looking for a SQL query.

like image 387
SwissCoder Avatar asked Mar 13 '12 04:03

SwissCoder


People also ask

How do you check if a column exists in multiple tables?

The easiest and straightforward way to check for the column in a table is to use the information schema for column system view. Wright a select query for INFORMATION_SCHEMA. COLUMNS as shown below. If the query returns record, then the column is available in the table.


1 Answers

You can use following query to return fields

SELECT table_name [Table Name], column_name [Column Name] FROM information_schema.columns where data_type = 'NTEXT' 
like image 57
rs. Avatar answered Oct 13 '22 05:10

rs.