To Get List of Tables from Database which has the data 'AAAA' - T-SQL Query
Hi,
I have a database "Adventureworks", I need to get list of tables, which has the data 'AAAA' in their rows.
Is there any optimised or simple way to do this task?
Any T-SQL Query Available
--- Thanks in advance..
You can refer the same below URL provided by Praveen:
https://gallery.technet.microsoft.com/scriptcenter/c0c57332-8624-48c0-b4c3-5b31fe641c58
It has the SQL SP - "SP_SearchTables". You can pass parameters the way you want and get the expected output.
-- Search for 'bike' instead of 'AAAA'
Use AdventureWorks2012
EXEC SP_SearchTables @Tablenames = '%', @SearchStr = '%bike%'
-Vaibhav Chaudhari
Similar Messages
-
Need tool/utility to get list of tables from sql query
Hi,
I often have to analyze huge queries without having access to database. Is there any tool where I can submit the a sql query and it gives me list of tables used in the query. I also need similar thing for documentation.
Let me know if anybody uses anything like this.
Thanks.
liquidloop[at]live[dot]co[dot]ukYou can find the size of each table, and thus list the tables in the process.
SET NOCOUNT ON
DBCC UPDATEUSAGE(0)
-- DB size.
EXEC sp_spaceused
-- Table row counts and sizes.
CREATE TABLE #t
[name] NVARCHAR(128),
[rows] CHAR(11),
reserved VARCHAR(18),
data VARCHAR(18),
index_size VARCHAR(18),
unused VARCHAR(18)
INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?'''
SELECT *
FROM #t
-- # of rows.
SELECT SUM(CAST([rows] AS int)) AS [rows]
FROM #t
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
WHERE
t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.Name, p.Rows
ORDER BY
t.Name
--- SQL2005
select o.name
, reservedpages = sum(a.total_pages)
, usedpages = sum(a.used_pages)
, pages = sum(case when a.type <> 1 then a.used_pages
when p.index_id < 2 then a.data_pages else 0 end)
, SUM(a.used_pages)*8096 AS 'Size(B)'
, rows = sum(case when (p.index_id < 2) and (a.type = 1) then p.rows else 0 end)
from sys.objects o
join sys.partitions p on p.object_id = o.object_id
join sys.allocation_units a on p.partition_id = a.container_id
where o.type = 'U'
group by o.name
order by 3 desc --biggest tables first
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
How to insert a record in to oracle table from Java which has a oracle LONG Field?
The problem is only 80 char's inserted in to the LONG FIELD which happend to me when i run the same insert statement from SQL plus.
Here is the code....
java.io.File inputFile = new java.io.File("input.txt");
int inputFileLen = (int) inputFile.length();
java.io.InputStream ipStream = new java.io.FileInputStream(inputFile);
System.out.println(inputFileLen);
PreparedStatement myStmt = conn.prepareStatement("insert into LONG_EXAMPLE (notes,name)values(?,?)");
myStmt.setAsciiStream(1, ipStream, inputFileLen);
myStmt.setString(2,"Steve");
int res = myStmt.executeUpdate();
myStmt.close();
Note : Here the size of the input.txt 250 bytes , 1KB.
Thanks in advance......:-)
Cheers,
Vetri !Hien
I had a similar requirement to you and put the code on a push button. In my case the reports are being run interactively to the screen and then printed, and I have no way to know whether the report had actually been printed, so we rely on the user pressing the button. Of course there is a danger that the user forgets to press the button, but in our situation that would not be disasterous. Whatever method is used, I don't think there is any way to be sure that it has actually come out of the printer. -
Query OR Stored Proc to get data from Tables from All Schemas in the d/base
Hello Experts, (I appologize if i am not using the right way to ask questions)
I have a database, and it has around 400 schemas in it. I have designed a query which will fetch the data from three different table's from Schema1.
But it will be a tedious process of entering the 400 schemas names and pulling the information.
I would like to know as to what would be the best possible way to;
1) Look for all the schemas in the database
2) Look for those specific tables in the schema, which has the data in the tables.
3) If the tables are not present, than Ignore that schema and proceed further.
4) Load the data into a table
Any help, would appreciate it.
Thanks!
The query that i am using is as follows;
-- Query to select all the Schemas from the database
select username from all_users
order by username;
-- Sample Query to see if Tables exsist in the schema
SELECT DISTINCT OWNER, OBJECT_NAME
FROM ALL_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
AND OBJECT_NAME IN ('ENROLLMENT', 'PRDCT', 'L_P_L')
AND OWNER in ('Schema_1', 'Schema_2', Schema_3', Schema_4',Schema_5', Schema_6')
ORDER BY OWNER;
--Query to get the data from the tables in a Schema
select 'Schema_1@DATABASE_NAME' AS SCHEMA,
(SELECT MAX(LOAD_DT) FROM Schema_1.LOAD_STATUS) AS MAX_LOAD,
L_PROD_LINE.PROD_LINE,
COUNT(DISTINCT ENROLLMENT.MEM_NBR) AS MEMBERSHIP
FROM
Schema_1.ENROLLMENT,
Schema_1.PRDCT,
Schema_1.L_P_L
WHERE
ENROLLMENT.PRODUCT_ID = PRDCT.PRODUCT_ID AND
PRODUCT.PROD_LINE_ID = L_P_L.ID
GROUP BY
L_P_L.PROD_LINE;Hi,
999355 wrote:
Hello Experts, (I appologize if i am not using the right way to ask questions)See the froum FAQ {message:id=9360002}
I have a database, and it has around 400 schemas in it. I have designed a query which will fetch the data from three different table's from Schema1.
But it will be a tedious process of entering the 400 schemas names and pulling the information.
I would like to know as to what would be the best possible way to;
1) Look for all the schemas in the database
2) Look for those specific tables in the schema, which has the data in the tables.
3) If the tables are not present, than Ignore that schema and proceed further.
4) Load the data into a table
Any help, would appreciate it.
Thanks!
The query that i am using is as follows;
-- Query to select all the Schemas from the database
select username from all_users
order by username;
-- Sample Query to see if Tables exsist in the schema
SELECT DISTINCT OWNER, OBJECT_NAME
FROM ALL_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
AND OBJECT_NAME IN ('ENROLLMENT', 'PRDCT', 'L_P_L')
AND OWNER in ('Schema_1', 'Schema_2', Schema_3', Schema_4',Schema_5', Schema_6')
ORDER BY OWNER; Do you want to give a list of possible schemas (like the 6 above), or do you want to consider all schemas, however many and whatever they are called?
You can get the right information for ALL_OBJECTS, but, since you known all the objects of interest are tables, ALL_TABLES will be faster and simpler.
--Query to get the data from the tables in a Schema
select 'Schema_1@DATABASE_NAME' AS SCHEMA,
(SELECT MAX(LOAD_DT) FROM Schema_1.LOAD_STATUS) AS MAX_LOAD,
L_PROD_LINE.PROD_LINE,
COUNT(DISTINCT ENROLLMENT.MEM_NBR) AS MEMBERSHIP
FROM
Schema_1.ENROLLMENT,
Schema_1.PRDCT,
Schema_1.L_P_L
WHERE
ENROLLMENT.PRODUCT_ID = PRDCT.PRODUCT_ID AND
PRODUCT.PROD_LINE_ID = L_P_L.ID
GROUP BY
L_P_L.PROD_LINE;I take it that the tables in question are ENROLLMENT, PRDCT and L_P_L; they won't have different names in different schemas.
You can start this way:
BEGIN
FOR c IN (
SELECT owner
FROM all_tables
WHERE table_name IN ( 'ENROLLMENT'
, 'PRDCT'
, 'L_P_L'
GROUP BY owner
HAVING COUNT (*) = 3
LOOP
... -- Now get the results for tables in the c.owner schema
END LOOP;
END;
/This will find the schemas that have all 3 of those tables.
Inside the loop, write another dynamic query. All that will change is the value of c.owner
Sorry, I'm running out of time now. I hope this helps. -
List of values from Database Adapter - BPM Forms
Hi all,
Can anyone tell me how to get list of values from Database adapter and a ServiceTask.
As example lets say a table has Employee and Department columns.
I want to list down all the Employees in BPM form (Select One List Box) once i provide the department to the Database Adapter.
Is it possible from the DB Adapter?? What will be the variable type?
Thanks,
NirHi DanielAtwood,
Thanks for your reply...
Actually when i send the variable in 'WHERE Clause' in Db Adapter query it will retrieve more than one record as the output.
I want to put that values to a 'SelectOneChoice' component and list down all the values..
First I tried with data control. But i couldn't find the way to pass the value to the variable(in WHERE clause) to the query in data control view.
Thanks,
Nir -
Getting list of tables the user has access to across different schemas.
Hi,
I have to get the list of tables that an User has access to. I tried the below code. It takes a very long time. Is there any way in which I can specify the user name and get all the tables that he has access to? I know that we can use dbMetadata.getTables api. But this returns the list of tables under the said schema. But I want the list of tables that the user has access including tables in other schema.
In the below code, I am trying to get the tables for which USER_MICHAEL has access to.
DatabaseMetaData dbMetadata = connection.getMetaData(); String userName = null; dbrs = dbMetadata.getTables(null,userName , "%", new String[] { "TABLE" }); dbrs=dbMetadata.getTablePrivileges("",userName,"%"); while (dbrs.next()) { String tableName = dbrs.getString("TABLE_NAME"); String schema = dbrs.getString("TABLE_SCHEM"); String privilege = dbrs.getString("PRIVILEGE"); String grantee = dbrs.getString("GRANTEE"); if(grantee!=null && grantee.equals("USER_MICHAEL")){ System.out.println("Schema---"+schema+" Table---"+tableName+" Privilege----"+privilege+" grantee---- "+grantee); } }That would be database dependent.
Some engines have some system tables that together may be used to extract such information, others may not make it available at all outside closed APIs. -
OBIEE Error while importing table from database
Hi
I am getting the following error when i am trying to import table from database.
[nQSError: 16001]ODBC error state: IM004 code:0 message:
[Microsoft][ODBC Driver Manager] Driver`s SQLAllocHandle on SQL_HANDLE_ENV failed.
Any idea y such error.
Thanks and Regards,
AndyLooks like an error in the ODBC driver, not OBIEE as such.
Have you tried googling it?
Can you post details about your OS and DB. -
How to get list of tables used in packages
Dear All
Can you pls tell me how to get list of tables used in packages
Regardsselect referenced_name
from user_dependencies
where name = 'your_package'
and referenced_type = 'TABLE'Regards,
Rob. -
Web application security. Getting username and password from database
Hi!
I need to write the following web application (I write it using java server faces):
1) User enters his username/password on the login page
2) Program goes to database where there are tens of thousands of usernames/passwords, and verifies it.
3) If user and password exist in DB, user gets access to the other pages of the application
Maybe I don't understand some point. I tried to use j_security_check(it's very easy to configure secured pages in web.xmp). The problem is that it works(as far as I understand) only with roles defined on server before the application runs. I can't add ALL these usernames to the roles on server. The best way, as I see it, is to go to DB, check username/password, create new role for the time of session, go to j_security_check where the j_username and j_password get the values from db and get the access to secured pages(as far as the roles have been dinamically added).
Am I right and this should be the algorithm?
How can I implement it?
I've read about JAAS. How can it help to solve the problem? Do I need j_security_check if I use JAAS? How should I configure my application if I use it?
Could you please give me some code example?
All this must work on IIS (for now, I develope it in Netbeans and run it on Java Application Server)
Please help.
Edited by: nemaria on Jul 7, 2008 2:39 AMHi,
Any security constrained url pattern which calls the action j_security_check passes the parameter to the realm mentioned in the server.xml.If the realm is set as JAAS,then the authenticate method of the jaasrealm does the basic validation like non empty field value from the input form.The appname set as the realm parameter points to the one or more loginmodules which has the life cycle methods like initialize(...),login(),commit(),abort() and logout().Once the basic validation is done in the JaasRealm class of the webcontainer,the LoginContext is created and user is autheticated (against DB username/password) via the login().Then the user is authourised in the commit().Then Jaasrealm takes care of creating the LoginContext,calling login(),creating Subject with principals,credentials added and setting that in the session.
I have a big trouble in accessing the HttpServletRequest object in the LoginModules.i.e getting the j_username and j_password in the LoginModules or in the CallBackHandlers.PolicyContext doesn't work for me.Is there any other way?
Regards,
Ganesh -
Labview 2013 are closing when I try read table from database.
Labview 2013 are closing when I try read table from database.
I don't get error message, Labview just crashes. I'm use Labview x32 and Database Connectivity Toolkit connective on Windows 7 x64. I connect to PostgreSQL with ODBC driver, connection is stable.
In my database I have many tables, I can read all them without one.
When I try read bad table I get data and then labview crash. When I restart Labview I don't have any message about error.
Also I try use LabSQL-1.1a. But it has same result.
Solved!
Go to Solution.
Attachments:
DBT.png 104 KB
LabSQL.png 67 KBTry connecting using UDL file. What operation you are doing with database
You can create the same.. Do this Tools --> Create Data link..
Then go to http://www.ni.com/pdf/manuals/371525a.pdf link and see page 3-5. It will help
Kudos are always welcome if you got solution to some extent.
I need my difficulties because they are necessary to enjoy my success.
--Ranjeet -
Getting list of cert from browser
Hello,
I would like to get the list of certificate in the different stores of my web browser (internet explorer, firefox, ...). I know how to get the list of certs from a java keystore, but I have no idea about getting list of cert from browser.
Please help!
ThanksA little tough.
On Windows, you can use Windows-MY and Windows-Root storetypes to access those 2 stores in IE.
For Firefox keystores, you can use the PKCS11 storetype to access the NSS keystore.
Google yourself for details. -
How to get name of table from front end
Hi,
How to get name of table from front end in EBS 11i?
thanx
AshishHi
Sandeep is correct. The "Help"/"Record History" will give you the table/view name, but sometimes this particular menu function give me a "Record History is not available here." error message.
I then use the following menu functions (this will also give you additional information, like column details).
1) Open Forms
2) Click on Help/Diagnostics/Examine (*you might have to enter the APPS password at this point)
3) Change "Block" to "System"
4) Change "Field" to "Last_query"
The system will populate the "Value" field with the query that was executed in order to populate the form.
Regards
Frank -
[nQSError: 46115] - Admin Tools: can't import table from database .
hi all,
Need your help, i am using Bi Administration Tool, and i try to import tables from database,but encounter issue:
(1)."File->import->from database...",select connection type as OCI 10g/11g, type TNS Name,User Name and Password,then click "OK".
(2).select table "BI_DATA",and then click button "import",it show prompt:"Failed to perform requested action".
(3).i try to click the symbol "+" on the left of table "BI_DATA", it show below prompt:
[nQSError: 46115] No Unicode translation is available for some of the input characters for MultiByteWideChar().
is there anyone can help me? thanks.
the BI version is:
Build: 10.1.3.4.1.090414.1900
Release Version: Oracle Business Intelligence 10.1.3.4.1
Package: 090414.1900I meet the problem, too! I can't solve it. Is anyone who can help me.
My email is [email protected]
thanks in avdvanced! -
How to display multiple tables from database using netbeans swing gui
plz reply asap on how to display multiple tables from database using netbeans swing gui into the same project
Layered Pane with JTables or you can easily to it with a little scripting and HTML.
plzzzzzzzzzzzzzzzzz, do not use SMS speak when posting. -
Can i get my iPhone replaced from Singapore which was bought from USA ?
I bought an Iphone 4 from US which has an extended applecare coverage.... I believe that there is a hardware problem in my iphone....
Can it be replaced in singapore ?
As i will be visiting singapore this week......
If NO then what are the options for me...
And if YES then where can i get it done ??Dr.Adil wrote:
Can you please ask this on my behalf... ??? coz i am in pakistan.... and this would be a difficult job for me to do :S
You're just as capable as anyone else here of asking and finding out the answer yourself.
Contact Apple in your country, or whomever provides support.
Maybe you are looking for
-
How can I get the e-mail address (reply addr.) once connected to a server
My application ask the user to enter the POP3 server host name (+ port) more the POP3 server userId and password .... I can get the e-mails and show the to the user .... Now, the user want to send a message from that "account" and what I need is to k
-
OSB business services slow after upgrade
Hi all! After upgrading development environment to wls 10.3.6 + OSB 11.1.1.6 I noticed, that proxy services are executing notably slower (instead of 100ms, it is now about 4-5 seconds). After some investigation, I found out that all this time is taki
-
Hi, by assigning cost center in po, we created qm order automatically. after rr and ud, the quantity in mmbe is not increasing. it is not showing as stock in mmbe for that qty. please advise whether we can take it in stock even for auto generated ind
-
Hi gang, I experienced some unusual behavior lately when I import pictures in Canon - Raw (.cs2) format and this behavior seems to affect the original file... Camera is a Canon Rebel T3i and I shoot in Raw-mode. What happens is that the preview thumb
-
Msmgdsrv - cannot find the file
I have a report that talks to SQL Server Analysis Services 2008 64-bit. On one query, it keeps coughing up this error msg, but the other queries are okay. TITLE: Microsoft Visual Studio Query preparation failed. ADDITIONAL INFORMATION: Could not loa