Can I locate tables based on a column value? [duplicate] - sql

This question already has answers here:
Find a value anywhere in a database
(18 answers)
Closed 5 years ago.
I am working without documentation we have a dental system that displays the status of an appointment.
I have to report on who scheduled the appt. and who confirmed. The systems displays this as 'FIRM' and 'FIXED. I have located how they store the person who scheduled the appt. but not who has confirmed it.
But since they use 'FIRM" is there a way I can locate which tables have this value? we are running sql server 2008.

you can find out the table name which have column name like FIRM by using below query -
select * from information_schema.columns where column_name like '%FIRM%'
if you want to know where this column is referred (like in SP , trigger or view) or a or hard coded value is used to display, you can use below query-
select distinct object_name(id) from syscomments where text like '%FIRM%'

Related

How to check, find and see the values of a specific column inside of a big database with many tables, if the column actually exists [duplicate]

This question already has answers here:
Find a string by searching all tables in SQL Server
(12 answers)
Closed 1 year ago.
I have a lot of tables inside some database of SQL Server and I think that some of those tables have some specific column that, I want to check if it exists and also see the values inside, if it actually exists.
I guess that the column was named like: ‘’Status’’
Please, consider that I don't have any idea about what are the values that maybe exist inside of this supposed column or even the kind of it.
Database name: PrincipalGroup
I won't say the name of the tables, because I don’t think it's feasible to write all the tables in this query, because there are many.
So, the point is: how can I query this by the easiest and simplest way?
You can try the following query that will produce a list of SQL statements you can then execute to "see the values inside" each table that contains the column named Status, and obviously tweak to your specific requirements.
select Concat('select distinct ', QUOTENAME(table_name, ''''), ' , [Status] from ', QuoteName(table_name))
from INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME = 'Status'

To see whether a column of a table is been used somewhere in the database [duplicate]

This question already has answers here:
How can we figure out that a column in my oracle table is being populated/updated by a trigger of another table?
(3 answers)
Closed 5 years ago.
How to check whether a particular column of a table is used in any other object or not in Oracle? For example I have a table EMPLOYEE which has a column BONUS. I need to check whether this column of this table is been used by any other objects like View, Package etc in the database.
You can try the following SQL to check for the table and column used within the object definition
SELECT 1
FROM all_source
WHERE type IN ('PROCEDURE','PACKAGE BODY','FUNCTION')
AND text LIKE '%EMPLOYEE%'
AND text LIKE '%BONUS%';

creating an TSQL Makro for daily usage [duplicate]

This question already has answers here:
Is there a way to expand the column list in a SELECT * from #Temp_Table in SSMS?
(5 answers)
Closed 6 years ago.
I want to create a Makro for myself that Converts a Star into a list of Columns.
My Question here is: Is there any way to Access the Tool tip that my SQL Server 2014 gives me when I hover over the said Star.
My intention here ist that if i have a Statement like
Select * from #TempTab
join Tab1 on Temp_ID=Tab_ID
join Tab2 on Tab1_ID = Tab2_Tab1_ID
...
the only thing i have to do is pressing a 'Makro' and my Star gets replaced by the current list of Columns
Use SSMS built in option.
Right click your table name in the object explorer then select top 1000 rows.
It gives you all columns with top 1000 records.

Displaying the name and data type of every column in a table [duplicate]

This question already has answers here:
How To Find Datatypes information in oracle schema?
(2 answers)
Closed 9 years ago.
I am working on a Database Management Systems assignment and have been unable to find a way to display the name and datatype of every column in a specific table. I don't know if this is needed but here is the link to the schema I am using for this assignment.
http://mym.cdn.laureate-media.com/2dett4d/Walden/ITEC/ITEC2060/documents/Schema.sql
The employee table is what I am trying to display from.
To list all columns for a specific table:
select column_name, data_type
from all_tab_columns
where table_name = 'EMPLOYEES';
More details in the manual: http://docs.oracle.com/cd/E11882_01/server.112/e25513/statviews_2103.htm#I1020277
If you are using SQL*Plus you can simply run
desc EMPLOYEES
instead.
Most other SQL clients have a similar feature.

How do I return a list of all column titles in a table in SQLite? [duplicate]

This question already has answers here:
How can I get the list of a columns in a table for a SQLite database?
(9 answers)
Closed 9 years ago.
I have a 20-or-so column table 'Contacts' in a Contacts.sqlite file. I use the Mac Terminal to interact with it, and am writing a program that will perform certain actions based on the number of columns in the table, as well as the name of each column.
Thus, I need to perform some sort of query that will return a list of all my column titles.
I have found various recommendations that look like some version of this:
SELECT column_name
FROM information_schema.columns
WHERE table_schema = 'Schema' AND table_name = 'Table_Name'
but it almost always returns an error saying there is "no such table: information_scheme.columns".
Looks like SQLite does not support information_schema. You can retrieve the list of table names from sqlite_master. But there is no table with columns.
Instead, SQLite supports the proprietary pragma table_info():
pragma table_info(table_name);