Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 517365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:49:35+00:00 2026-05-13T07:49:35+00:00

I want to query a set of tables based on the column name, type,

  • 0

I want to query a set of tables based on the column name, type, etc. Basically without knowing the name of a table I want to query the database for all tables capable of storing the data into.

I have this query but I’m not sure if it’s very efficient. I was wondering if there is a better way.

 SELECT O.TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS AS O
    INNER JOIN INFORMATION_SCHEMA.COLUMNS AS R1
        ON R1.TABLE_NAME = O.TABLE_NAME and R1.COLUMN_NAME = 'Id' and R1.DATA_TYPE = 'uniqueidentifier'
    INNER JOIN INFORMATION_SCHEMA.COLUMNS as R2
        ON R2.TABLE_NAME = O.TABLE_NAME and R2.COLUMN_NAME = 'Message' and R2.DATA_TYPE = 'nvarchar'
    INNER JOIN INFORMATION_SCHEMA.COLUMNS AS R3
        ON R3.TABLE_NAME = O.TABLE_NAME and R3.COLUMN_NAME = 'EnteredOn' and R3.DATA_TYPE = 'datetime'
    GROUP BY O.TABLE_NAME

This query currently works but I feel there must be a better way. Basically I don’t want other tables showing up that may have a column with the name Id but not the columns Message and EnteredOn.

Here is the CREATE TABLE query for the table.

CREATE TABLE [dbo].[Log](
    [Id] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
    [Message] [nvarchar](2048) NULL,
    [EnteredOn] [datetime] NOT NULL,
 CONSTRAINT [PK_Log] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:49:35+00:00Added an answer on May 13, 2026 at 7:49 am
    SELECT table_schema, table_name
    FROM   information_schema.columns
    WHERE  COLUMN_NAME = 'Id'        AND DATA_TYPE = 'uniqueidentifier'
    OR     COLUMN_NAME = 'Message'   AND DATA_TYPE = 'nvarchar'
    OR     COLUMN_NAME = 'EnteredOn' AND DATA_TYPE = 'datetime'
    GROUP BY table_schema, table_name
    HAVING COUNT(COLUMN_NAME) = 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to accomplish this (mysql) query: UPDATE table SET field = field +
I'm using EF for a set of objects and want to query one type
So, I want to insert this query into the database file: UPDATE contas SET
In my Select query I just want to to set the alias name of
Normally when I want to query large result set using Mysql I write this
i want to set the value to a insert query from select query ,how
I want to be able to query or embed the version string set by
i want query a file xml with linq, i want get all descendat of
Bit confused with this one. Basically, I have a column in a table, and
I am having two tables student table it contains (Student_id,school_code,name,year,...) school table it contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.