This question already has answers here:
Find a value anywhere in a database
(18 answers)
Closed 10 years ago.
is there a select query where I can find a column that has a data named 'Hello'. I'm not looking for a data on a single table, but am looking for a data on a whole database.
#aedz: here are some suggenstions/hints for you, basically this is easy to google:
MSSQL:
SQL Server: Search all tables for a particular GUID
http://gallery.technet.microsoft.com/scriptcenter/c0c57332-8624-48c0-b4c3-5b31fe641c58
http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm
Search for a string in all tables, rows and columns of a DB
http://justgeeks.blogspot.de/2006/10/search-ms-sql-server-for-any-text.html
http://www.sqlservercentral.com/Forums/Topic419243-8-1.aspx
http://www.mssqltips.com/sqlservertip/1522/searching-and-finding-a-string-value-in-all-columns-in-a-sql-server-table/
http://www.mssqltips.com/sqlservertip/1555/sql-server-find-and-replace-values-in-all-tables-and-all-text-columns/
MySql:
Search for all occurrences of a string in a mysql database
Search in all fields from every table of a MySQL database
MySQL tool that searches for a string in all fields, tables and databases
mySQL query to search all tables within a database for a string?
http://kedar.nitty-witty.com/blog/search-through-all-databases-tables-columns-in-mysql
Related
This question already has answers here:
Search All Fields In All Tables For A Specific Value (Oracle)
(17 answers)
Closed 5 years ago.
I want to be able to search through entire table without specifying each column. I want to be able to look for a record where each column may look LIKE '%QASHQAI%'. This table has about 100 different columns. Naming all of them like
SELECT * FROM vehicle WHERE ... LIKE '%QASHQAI%' OR ... LIKE '%QASHQAI%' OR ... LIKE '%QASHQAI%';
Is there a quicker way of searching through the table?
i think it s not possible with a simple query but you can solve this with a stored procedure.
see my comments here
This question already has answers here:
Exclude a column using SELECT * [except columnA] FROM tableA?
(47 answers)
Closed 5 years ago.
I was reading SQL queries and got stuck with a doubt. Is there any SQL query to exclude a single column while using select statement?
For example, I have a table which contains data about student (s_name, address, email_id, ..... many more).
I want to select all the columns except email_id.
I don't think there is a way to do it directly in a Select statement. But you can use this alternative:
How to select all the columns of a table except one column?
This question already has answers here:
Query to list number of records in each table in a database
(23 answers)
Closed 7 years ago.
I am working with SQL Server 2008 R2.
I have a table named punch with lot of rows. I want to know number of rows in this table but without doing a count. Is it possible? If yes then how?
Thanks
Sql have a function for that
sp_spaceused <Tablename>;
Here is one way.
select row_count
from sys.dm_db_partition_stats
where object_id = object_id('punch')
This question already has answers here:
Query to list number of records in each table in a database
(23 answers)
Closed 7 years ago.
I'm trying to add a WHERE clause to a SELECT statement that checks to see if there is data in the table or if it was a 0-row table.
Basically, I'm trying to get this to work but obviously tables.NAME isn't a valid object.
SELECT NAME
FROM sys.tables
WHERE (SELECT Count(*)
FROM tables.NAME) <> 0
I don't want to have to create a temp table, declare a cursor and checking a value row by row, but I'm having a hard time thinking a bout how to do this otherwise.
Using a cursor is a suitable solution to this problem. You can't dynamically interpret a column from one table as a table name and simultaneously select from that table to see if it's empty like you're attempting to do. In fact you can't even select from a dynamic table without using dynamic SQL. See the documentation for FROM. You can either iterate over each table and check each, or you can query system tables that hold storage statistics to see if tables are empty.
This question already has answers here:
Possible to perform cross-database queries with PostgreSQL?
(9 answers)
PostgreSQL cross server query? [closed]
(2 answers)
Closed 9 years ago.
I've one problem regarding manage information from two different Postgres servers.
In the one server I've one table a containing id bigserial and phone varchar(200)
On the other server I've table b that contains id bigserial and tell varchar(200)
Is there a way that I can compare witch rows from table a are present in the rows of table b, comparing by phone = tell?
You can use dblink to fetch data from remote server. Once you have a cursor open you can treat data from dblink_fetch as data returned from local table and just outer join it with the local table. If there are many rows in the remote table you might want to use pl/pgSQL to fetch it in parts.