How to get table schema from Progress database via odbc - schema

I have a linked server set up between sql 2008 and a Progress OpenEdge 10.1b server.
How do I get the table schemas?

You can get all available tables:
select * from sysprogress.SYSTABLES;
or
select * from sysprogress.SYSTABLES_FULL;
You can get all columns of specified table:
select * from sysprogress.SYSCOLUMNS where TBL = 'table_name';
or
select * from sysprogress.SYSCOLUMNS_FULL where TBL = 'table_name';
It works only with DBA privileged user.
More detail in OpenEdge Product Documentation: https://community.progress.com/community_groups/openedge_general/w/openedgegeneral/1329.openedge-product-documentation-overview
Document title: SQL Reference
Chapter: OpenEdge SQL System Catalog Tables

You can do a statement like
SELECT * FROM LinkedProgressOpenedgeServer.YourDatabase.Owner.TableName WHERE 1=2
That should return just the schema without any data.

Normally the default schema name is PUB. You can try using PUB schema.

Related

Passthrough Query from one SQL Server to another that drops a table on the source

I have a SQL Server in Spain and one in the US and there is a domain trust between the two with linked servers on each for access to the other.
I would like to be able to run the below query on the US SQL Server without having to maintain a stored proc on the US Server in order to run it. Is there a way to create a passthrough query from the SQL Server in Spain? I've already tried using OPENQUERY and OPENROWSET and it's just not working as they only seem to work with select statements that return results:
DROP TABLE IF EXISTS [Global].[dbo].[WW_Customer_Receivables]
SELECT *
INTO [global].[dbo].[ww_customer_receivables]
FROM
[LinkedServerObject-Spain].[global].dbo.ww_customer_receivables
If you want to execute DDL statement on your linked server with openquery you can with the following trick:
SELECT *
FROM OPENQUERY(linkedserver, '
DROP TABLE IF EXISTS [Global].[dbo].[WW_Customer_Receivables]
SELECT ##RowCount')
The SELECT ##RowCount returns a result set. So OPENQUERY works.
This trick works for all DDL operations like create, alter, drop. Or if you want to perform inserts/updates/deletes that don't return a result set.
Same trick is applied here Where they have a dummy select foobar.
If you want to execute the into statement from the openquery you can do it like this:
DROP TABLE IF EXISTS [Global].[dbo].[WW_Customer_Receivables]
SELECT *
INTO [global].[dbo].[ww_customer_receivables]
FROM OPENQUERY([LinkerServerObject-US], '
SELECT *
FROM [global].dbo.ww_customer_receivables')

Oracle system information query - Database instance level

I am writing a performance/system monitoring tool to augment load testing for my team's product and I am trying to store database system information with the results bundle but do not know how to write the query to capture this in Oracle (I'm a developer not a DBA).
I have this all working the way I want for SQL Server, but I need to do the same for Oracle. Below is a query I found online for this is SQL Server:
SELECT CONVERT(varchar(128),SERVERPROPERTY('ComputerNamePhysicalNetBIOS')) AS 'computerNamePhysicalNetBIOS',
CONVERT(varchar(128),SERVERPROPERTY('MachineName')) AS 'machineName',
CONVERT(varchar(128),SERVERPROPERTY('Edition')) AS 'edition',
CONVERT(varchar(128),SERVERPROPERTY('ProductLevel')) AS 'productLevel',
CONVERT(varchar(128),SERVERPROPERTY('ProductVersion')) AS 'productVersion',
CONVERT(varchar(128),SERVERPROPERTY('BuildClrVersion')) AS 'buildClrVersion',
CONVERT(INT,SERVERPROPERTY('ProcessID')) AS 'processID',
CONVERT(INT,SERVERPROPERTY('EngineEdition')) AS 'engineEdition',
CONVERT(INT,SERVERPROPERTY('HadrManagerStatus')) AS 'hadrManagerStatus',
CONVERT(INT,SERVERPROPERTY('IsHadrEnabled')) AS 'hadrEnabled',
CONVERT(INT,SERVERPROPERTY('IsAdvancedAnalyticsInstalled')) AS 'advancedAnalyticsInstalled',
CONVERT(INT,SERVERPROPERTY('IsClustered')) AS 'clustered',
CONVERT(INT,SERVERPROPERTY('IsPolybaseInstalled')) AS 'polybaseInstalled',
CONVERT(INT,SERVERPROPERTY('IsXTPSupported')) AS 'xtpSupported',
CONVERT(INT,SERVERPROPERTY('LCID')) AS 'lcid',
CONVERT(varchar(128),SERVERPROPERTY('ResourceVersion')) AS 'resourceVersion',
CONVERT(varchar(128),SERVERPROPERTY('ServerName')) AS 'serverName',
CONVERT(varchar(128),APP_NAME() )AS 'appName',
CONVERT(INT,DB_ID()) AS 'dbId',
CONVERT(varchar(128),DB_NAME()) AS 'dbName'
I don't really expect a one-to-one column match between the above query and Oracle's version, but in general, how can I get very similar information from Oracle?
I don't really expect a one-to-one column match between the above
query and Oracle's version, but in general, how can I get very similar
information from Oracle?
Most of that stuff, if it exists at all in the Oracle database, will be accessible through V$ views in the Oracle database. To get you started, here are some that are going to be most relevant to answering your question:
select * from v$instance;
select * from v$version;
select * from v$sql_feature;
select * from v$license;
select * from v$option;
If you want to get a complete list of V$ views to look around better,
select * from dict where table_name like 'V$%';
Some of those things are specific to MSSQL and have no meaning in Oracle. But you can get many of them with sys_context() using the userenv namespace.
For instance, to get the database name:
select sys_context('userenv', 'DB_NAME') as db_name
from dual;

How to create a table using the INSERT INTO clause using linked servers in SQL Server Management Studio

I have a server called GreatPlains and I would like to create a new table (not already defined) using the INSERT INTO clause onto my local server's reporting database. We have a linked server set up for the GreatPlains server and our main production server.
Simplified version of current query:
SELECT *
INTO [local].[Reporting].[dbo].[NewTable]
FROM [linked].[Main].[dbo].[Orders]
I'm also getting the error:
The object name 'local.Reporting.dbo.NewTable' contains more than the
maximum number of prefixes. The maximum is 2.
There are two mistakes in your query
1.INTO clause support maximum of 2 prefixes. You cannot include SERVER NAME
DATABASE_NAME.SCHEMA_NAME.TABLE_NAME
2.Unwanted INSERT ketword
So your query should be
SELECT *
INTO [Reporting].[dbo].[NewTable]
FROM [linked].[Main].[dbo].[Orders];
I think you have an extra insert:
SELECT *
INTO [local].[Reporting].[dbo].[NewTable]
FROM [linked].[Main].[dbo].[Orders];
If the table is already defined and has the same columns in the same order, then you can do:
INSERT INTO [local].[Reporting].[dbo].[NewTable]
SELECT *
FROM [linked].[Main].[dbo].[Orders];
If you are running the script in your local server and table already exists in the database,Use the below script.
USE [Reporting]
GO
INSERT INTO [dbo].[NewTable]
SELECT *
FROM [linked].[Main].[dbo].[Orders]
If you don't have the table in your database,use the below script.
USE [Reporting]
GO
SELECT *
INTO dbo.[NewTable]
FROM [linked].[Main].[dbo].[Orders]

In SQL Server, why there are duplicated DMVs in all database? Such as sys.databases

In SQL Server, there are some DMVs that appear in all databases and have the same content in it. What's the purpose of this approach? For example, the following 2 query will give the same result.
select *
from master.sys.databases
select *
from tempdb.sys.databases
Thanks.
sys.databases only exists once (actually in the hidden resource database)
All you are doing above is switching db context temporarily by using a 3 part object name

SQL Server: How to get a subitem of sp_helplanguage?

Question: I can get the SQL Server database language by querying:
SELECT ##language
And I can get further info via
EXEC sp_helplanguage
How can I query for a column of sp_helplanguage where name= ##language
I do SELECT * FROM sp_helplanguage WHERE name='DEUTSCH'
but that obviously doesn't work.
What's the correct way to query it ?
You need to query the underlying system catalog table directlry:
SELECT * FROM sys.syslanguages WHERE name='DEUTSCH'