Kusto query could not be parsed at 'sys' - database

While executing this query on the log analytics tool of the azure database
SELECT * FROM sys.event_log
Got the error as
Query could not be parsed at 'sys' on line [1,14]
Token: sys Line: 1 Position: 14

Azure Data Explorer support SQL however you need to escape it like this:
select * from [sys.event_log]
Azure Log Analytics does not support the SQL language and you have to use the "Kusto Query Language". You first need to find the table that has the data you are looking for and then use the "Kusto Query Language" to find the relevant data. There are many sample queries when you begin to use Azure Log Analytics.

Related

Error in SQL Server when connecting to PowerBI Datamart [Unsupported sql function USER_NAME]

I have connected to a Datamart via SSMS. Behind the Datamart is an Azure SQL database.
I am trying to find out my username. I used the following query:
SELECT USER_NAME();
I get this error:
Unsupported sql function USER_NAME. Line:1, Position:8
I have combed the internet but I have not come across something that works yet.
in MS SQL SERVER you must use
SELECT CURRENT_USER;
The op wrote in the comment, that he needed to close the open query box and open a new one, after that it works, like a charme.
or to get the windows user mame of the logged in user
SELECT SUSER_NAME() LoggedInUser

Why this T-SQL query doesn't work in Synapse?

I am testing Synapse. I tried this query
SELECT
TOP 100 *
FROM
OPENROWSET(
BULK '<path to the parquet file>',
FORMAT='PARQUET'
) AS [result]
But I get the following error. How can I solve it?
Parse error at line: 4, column: 5: Incorrect syntax near 'OPENROWSET'.
That type of query would work in the serverless SQL pool, as per the documentation on OPENROWSET. It would not work in a dedicated SQL pool.
If you are in Synapse Studio, try changing the Connect to option to Built-in, which is the serverless engine. Optionally create a database to store objects like external data sources, external tables and views in:
Another easy way to generate a working OPENROWSET statement would be via Synapse Studio > Data hub (the little cylinder on the right), Linked > double-click your datalake to navigate to the parquet file you want to query > right-click it > SELECT TOP 100 ...

Azure - How to execute UDF from external data source in select statement

I have an external data source created in DB1 and its pointing to DB2 database in Azure.
I want to query a UDF defined in DB2 from DB1.
Following syntax works, from DB1:
EXEC sp_execute_remote
N'Ext_DB2',
N'SELECT Result'
But I want to use following syntax:
select C1, C2, < function_in_DB2 >
from t1
I tried searching web, this format is not mentioned anywhere, is it not supported? Any pointers will help.
Thanks !
Just per my experience, I think Azure SQL database doesn't support it. As we know, we can't do cross database query directly.
Since none document talk about this, I would suggest you ask Azure SQL support to get more support, ref: How to create an Azure support request.
Hope this helps.

DB Link from Oracle to MS Server

I am new to this forum and already searched for 45 minutes to find a solution for my problem. I hope you can help me.
A Gateway to a remote Microsoft SQL Database was installed on a Oracle Server (Oracle 12c). The tsnnames.ora file was appropiately set up.
For the connection, I created a database link (In the Oracle DB) as follows:
CREATE DATABASE LINK TEL CONNECT TO "fb_B2C" IDENTIFIED BY "passwort" USING 'dg1msql';
When I now execute the Select statement:
SELECT "name" FROM "sys"."databases"#TEL
it shows me the according databases. Among others, I can see the AB_Colors database.
Now, I want to select a view in the AB_Colors database.
Due to the fact I can connect to this database via Excel, I know that in the database AB_Colors, there are 10 Views(A,B,C,..). I would like to select the View C from the database AB_Colors via the DB LInk.
Owner of the View is b2b.
How do i need to formulate the select statement to do it?
I already tried different writings:
SELECT * FROM b2b.C#TEL;
SELECT * FROM "AB_colors"."b2b"."C"#TEL;
SELECT * FROM [AB_Colors].[b2b].[C]#TEL;
The common error message is: View/Table does not exist
I highly appreciate your help,
Fedja
This is the correct format
SELECT * FROM "b2b"."C"#TEL;
The issue maybe because the database you want to select from is not the one specified in the gateway for dg1msql. You can't add the database name to the query so you must specify it in the gateway connection.
This is defined in
$ORACLE_HOME/dg4msql/admin/initdg4msql.ora
where you should check HS_FDS_CONNECT_INFO

Oracle Database 12 c , SQL Server Translator Is not Translating query

I have installed SQLServer Translators as oracle document require to use 12 c jdbc jar so i replace this jar with jdbc jar.
I have created transport and created profile using sqldeveloper. I have followed steps given in oracle documentation
https://docs.oracle.com/database/121/DRDAA/sql_transl_install.htm#DRDAA29457
Now after completing installation my sqlserver profile has following parameters
Profile_name SQLSERVER_PROFILE
Translator "MON422_QA"."SQLSERVER_TSQL_TRANSLATOR"
Foreign_SQL_syntax True
Translate_new_sql True
Raise_translation_error false
Log_translationerro flase
Trace_translation false
I have installed for migration user and now when I am trying to use for different user I have given execute grant to target user.
But I am unable to translate sql query
Select top 1 * from dual;
Translator is not working as expected. If any additional information is required please let me know I will add the information.
EDIT Query I am trying to run
Select cast ( 5 to NVARCHAR2(50)) from dual;
Should be translated to
SELECT TO_CHAR(5) FROM DUAL:
But it says query terminated undesired parenthesis after NVARCHAR2;
We can see translated queries using sqldeveloper for translator profile being used. But my queries are not being translated at all.
Reference For Translator FrameWork
https://docs.oracle.com/database/121/DRDAA/sql_transl_install.htm#DRDAA29148
The SQL Server translator assumes it is receiving T-SQL or a SQL Server SQL statement in order to translate it.
If you want to use the translation framework to translate an oracle statement to another version of an oracle statement - you can totally do that. But you do not involve the SQL Server translator.
You simply add an entry in your translation profile, a 'template' of the SQL you want translated, and you also provide what you want to come out the other end.
Kerry wrote a very nice blog post demonstrating that here.

Resources