I have a situation where I need to extract tables from one SQL database into another SQL database. There are about 100+ tables.
I would like to create a parameterized script for the SELECT and FROM tables so that the one script can be used to loop through all the tables.
Is this possible? I would really appreciate any assistance.
Related
I would like to know how to make a select query in vb.net, with joins between tables contained in databases of two different instances of sql server.
thanks.
Lets say have multiple databases on hive, a table with same name exists in all the databases, is there a way to give wild characters ? for e.g in under ab1, ab2, ab3 databases a tables "t1" exists in all the 3 databases. can i run a extract query to get data from all the tables under all databases ?
I tried select * from ab*.t1; gives me an error
It's impossible to do with HIVE query!
Unless you want to do some scripting around.
You can use show databases like 'ab*' to retrieve list of databases and then manually build query, where you list all databases/tables.
I need to find the tables and views used in stored procedure in which the tables and views may be of different databases.
Is there any way to find?
Eg: if i have sp "dbo.a"
i have to find the tables and views used within this.
The tables and views may be from different databases.
You can use sys.dm_sql_referenced_entities, e.g.
SELECT *
FROM sys.dm_sql_referenced_entities(N'dbo.YourProcedure', N'OBJECT');
There is probably no simple way to do this. What you need to do is find the table in your database which contains the code for all the stored procedures or some other way to read them.
Then you need to write an SQL parser which for your database. The parser can then read the source for the stored procedure and produce some data structure (usually an Abstract Syntax Tree) that you can traverse to find all the tables which it references.
At my workplace we have a database with multiple schemas, and some table names may be repeated in different schemas. There are thousands of tables so it is not time-effective to wade through the entire list.
If I do a query where I want to find all the tables containing the word CUSTOMER in their names, for example:
select table_name from all_tables where table_name like '%CUSTOMER%' order by table_name
The results just look like this, with no clues of which schema the tables are located under.
TB_NEW_CUSTOMER
TB_NEW_CUSTOMER
TB_NEW_CUSTOMER
TB_VIP_CUSTOMER
TB_VIP_CUSTOMER
TB_VIP_CUSTOMER
Is there a way to query Oracle so that I know under which schemas the tables are located? We do not seem to have SQL+ because I got a 9000 error when trying the DESCRIBE command. I am tired of scrolling around the Objects tab in SQuirreL SQL!
Thank you very much.
Andy
Why wouldn't you also select the owner of those tables?
I have a database called MasterDatabase that has table MainIndex with columns Id, Database (nvarchar), Table(nvarchar)
and I have 2 other databases with tables and data.
Is there a way to substitute the FROM statement with results from the MasterDatabase.MainIndex?
Can this be done with LINQ?
Another alternative is to add the table you want to select from from the second database as a view in the master database. You will then be able to map the view as an entity.
:)
You need the Linq Dynamic Query library to accomplish this. It allows you to do string substitutions in your Linq queries.
More info at http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx
Or you can access tables from another database by prefixing the tables in your .dbml with either [DatabaseName].[SchemaName].[TableName] or if it's on a differenct server include the [ServerName] as well... Then you wouldn't have to use Dynamic linq