Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use table metadata for select statement in SQL Server?

Tags:

sql

sql-server

I have a large database and would like to select table names that have a certain column name. I have done something like this in MySQL, but can't find any info on SQL Server.

I want to do something like:

select [table] 
from [db] 
where table [has column 'classtypeid']

How can I do something like this?

like image 227
mmattax Avatar asked Sep 21 '26 00:09

mmattax


1 Answers

Use the ANSI information_schema views, this will also work in MySQL

select table_name 
from information_schema.columns 
where column_name = 'classtypeid'
like image 123
SQLMenace Avatar answered Sep 22 '26 14:09

SQLMenace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!