I have a query like this:
SELECT PID,surname,forenames,othername,date_of_birth FROM OPENQUERY(compact,'SELECT PID,surname,forenames,othername,date_of_birth FROM Order.PERSONS')
This is run from SQL Studio Manager. Order.Persons is an Oracle database. This query works as intended. Is it possible to do this:
SELECT PID,surname,forenames,othername,date_of_birth FROM OPENQUERY(compact.world,'SELECT PID,surname,forenames,othername,date_of_birth FROM Order.PERSONS')
i.e. the change the linked server name to compact.world.
Try using [compact.world] instead of compact.world.
Related
I would like to find out which version of DB2 we are running on our IBM i server using only SQL SELECT.
I am executing my queries via installed ODBC drivers for i Access. The places I am executing the queries are Excel-ODBC and Excel-Microsoft Query (simply because I am not a developer and therefore don't have/don't know of another place to run queries).
The following solutions do not work for me:
How to check db2 version
Get DB2 instance name using SQL
Basic reasons why I have failed to get the above solutions to work:
I do not have a SYSPROC table/have access to SYSPROC table
SYSIBMADM table does not contain a ENV_INST_INFO table.
I think these answers may be tailored to those using IBM z, but I use IBM i.
My end goal is to be able to execute a SQL SELECT and get the version of DB2 used on our server.
Try this:
SELECT RELEASE_LEVEL, TEXT_DESCRIPTION
FROM QSYS2.SOFTWARE_PRODUCT_INFO
WHERE PRODUCT_ID = '5770SS1'
AND PRODUCT_OPTION = '27'
--or this instead of the above line:
--AND LOAD_TYPE = 'CODE' AND PRODUCT_OPTION = '*BASE'
I have tried create new view using an IP address in the query syntax. But this resulted in an error.
Query in View Editor:
SELECT *
FROM IP-ADDRESS.DATABASE.dbo.TABLE
Error:
In Normal Query (Work it):
How may I correctly execute this query?
Thank!
Try using tsql instead of the UI. I tested in the UI and I see what you mean that it is not keeping brackets.
CREATE VIEW [YourViewName]
AS
SELECT
*
FROM [IP-ADDRESS].DATABASE.dbo.TABLE
WHERE Something
i am using new installed sql server 2008
i am trying to copy data from one table to another..i wrote query like this;
insert into Clr select * from Color_tbl
but this is showing error like this:
Invalid object name 'Clr'.
what i have to do? i have change any setting?
clr is not an existing table..i hop if i execute this query that will create clr table automatically...
I used to copy data from one table to another table like this: but i dont know what happend after installing new Sql server??
any help is very appriciable
Without knowing anything else about your database and schemas, you could try using fully qualified names, like so:
INSERT INTO [DBContainingClr].[SchemaContainingClr].Clr
SELECT * FROM [DBContainingColor_tbl].[SchemaContainingColor_tbl].Color_tbl
UPDATE: OP has clarified that he is in fact trying to CREATE the table Clr, and it doesn't exist at the moment. In which case the syntax should be:
SELECT * INTO Clr FROM Color_Tbl
I am trying to write a SQL query to setup a dynamic collection in Configuration Manager 2012. My current query is
select * from SMS_R_System where SMS_R_System.Name LIKE 'cmgr%'
This will grab any server name that starts with cmgr and put it in the specified collection.
My issue is that I need to add another statement in this query to exclude servers that contain the following entries qw, dw and tw. This will prevent my non production servers from being put into the Production collections.
My knowledge of SQL scripting is very limited, so I appreciate any feedback.
Can you use something like this?
select * from SMS_R_System
where SMS_R_System.Name LIKE 'cmgr%'
AND SMS_R_System.Name NOT LIKE '%qw%'
AND SMS_R_System.Name NOT LIKE '%dw%'
AND SMS_R_System.Name NOT LIKE '%tw%'
You might want to take a look at that previous answer, it speaks about using the NOT EXISTS command as part of your query.
How do I query the database name in Oracle SQL Developer? I have tried the following and they all fail:
SELECT DB_NAME();
SELECT DATABASE();
Why do these basic MySQL queries fail in SQL Developer? Even this one fails too:
show tables;
EDIT: I can connect to the database and run queries such as:
select * from table_name_here;
EDIT 2: The database type is Oracle, this is why MySQL queries are failing. I thought it was related to the database client not the database itself. I was wrong. I'll leave the question as is for other as lost as I was.
Once I realized I was running an Oracle database, not MySQL, I found the answer
select * from v$database;
or
select ora_database_name from dual;
Try both. Credit and source goes to: http://www.perlmonks.org/?node_id=520376.
try this:
select * from global_name;
You can use the following command to know just the name of the database without the extra columns shown.
select name from v$database;
If you need any other information about the db then first know which are the columns names available using
describe v$database;
and select the columns that you want to see;
I know this is an old thread but you can also get some useful info from the V$INSTANCE view as well. the V$DATABASE displays info from the control file, the V$INSTANCE view displays state of the current instance.
Edit: Whoops, didn't check your question tags before answering.
Check that you can actually connect to DB (have the driver placed? tested the conn when creating it?).
If so, try runnung those queries with F5
To see database name,
startup;
then type
show parameter db_name;
DESCRIBE DATABASE NAME; you need to specify the name of the database and the results will include the data type of each attribute.