import data from table named "document" in odbc database with powerbi - sql

I'm connected to a database that contains a table named "document", this term is also an sql term at the same time so when I query it, it doesn't recognize it.
I'm used to just add some quotation marks to query it in dbeaver and it works well.
select * from "document"`
But when I want to write my query in PowerBi to import this table, it doesn't work with the quotation marks.
I also tried it in this format:
select * from public.document
Or I tried to don't write any sql query and just select it when I connect to the odbc database, but at the moment of update, the process starts and doesn't stop.

If the table really has double quotes in its name, one of these should work:
Using backtick
select * from `"document"`
Using double quote as escape:
select * from ""document""

Related

SQL server select query with parenthesis

I created a table in sql server
called user,
but when i tried to query the table
it only works like this approch (with parenthesis):
Select * from [user]
when i try:
select * from user
it dosent seems to work 'incorrect synax near the keyword 'user'
why i need to add those parenthesis i know i need to add Parenthesis if there is a space between like colum name "first name"
why it is not working?
You can write SELECT statement without square brackets for database tables, columns. When you use square brackets, then you explicitly says to SQL Server engine to select data from table user:
Select * from [user]
But when you write select * from user, then SQL engine thinks not about table user, but about reserved keyword user. The correct query to see database user name looks like this:
select user

Asp Classic & Firbird Sql without quotation marks

I have a script in ASP Classic that uses a Firebird database. I would like to execute a query without "quotation marks"
Now I must write this:
SQL = "SELECT ""TArticoli"".""IDArticolo"",""TArticoli"".""Desc"" FROM ""TArticoli"";"
I would write this:
SQL = "SELECT TArticles.IDArticle, TArticles.Desc FROM TArticles;"
The first one is accepted the second not, how can I do this?
You can't. DESC is a reserved word in Firebird, so to be able to use it as a column name (or any other object name for that matter), you will need to enclose it in quotes.
A second problem is that you are currently using
SELECT "TArticoli"."IDArticolo","TArticoli"."Desc" FROM "TArticoli"
And this means both your table name and the column names are case sensitive, and in that case, quoting those object names is mandatory. Unquoted object names are case insensitive, but are mapped to object names in upper case. This means that select * from TArticoli will select from a table called TARTICOLI, while select * from "TArticoli", selects from a table called TArticoli.
So unless you are going to rename or recreate all your tables or columns, you will not be able to get rid of quotes. The only thing you can do to reduce the number of quotes, is by not prefixing the columns with the table names (in the query shown it isn't necessary), or otherwise use a case insensitive alias for the table, eg
SELECT "IDArticolo", "Desc" FROM "TArticoli"
or
SELECT a."IDArticolo", a."Desc" FROM "TArticoli" AS a

SAS read a table from a SQL Server connection with name containing special characters

I have a connection in SAS to a sql server table where the table name is 'Additions_to_Aggregate$'. The quotes are part of the name. So in my SAS editor when I try to run the below in part of my code, I'm returned errors because SAS is reading it as string rather than as the table name.
proc sql;
Create Table Name_Compare as
SELECT DISTINCT a.Insured_Name, agg.Policy_Holder_Name, a.Segment
FROM MySQLLib.ADV_Portfolio_Split as a
LEFT JOIN MySQLLib.'Additions_to_Aggregate$'n.data as agg
on a.Insured_Name = agg.Policy_Holder_Name;
quit;
Is there any way to force SAS to read the table name as a literal string, or do you have any other solution ideas? I already tried renaming the table in SAS explorer but I get this error and don't know how to interpret it.
You're looking for a name literal. Either:
LEFT JOIN MySQL.'Additions_to_Aggregate$'n
or
LEFT JOIN MySQL."'Additions_to_Aggregate$'"n
depending on how SAS handles the quotes in the DBMS connection; it may or may not require the second, outside pair of quotes. If for some reason you need single quotes around it (SAS doesn't have any special meaning for single/double outside of macro resolution), you can double them up:
LEFT JOIN MySQL.'''Additions_to_Aggregate$'''n

Data management-SQL

I'm trying to work on my data management project for my class but I am having trouble importing data on the server.
P.S.: I'm using H2 Console
CREATE TABLE SERVES AS SELECT * FROM CSVREAD ('C:/Users/H/Downloads/SERVES.csv’);
Error:
CREATE TABLE SERVES AS SELECT * FROM CSVREAD
('C:/Users/H/Downloads/SERVES.csv’);; Syntax error in SQL statement
"CREATE TABLE SERVES AS SELECT * FROM CSVREAD
([*]'C:/Users/H/Downloads/SERVES.csv’);"; SQL statement: CREATE TABLE
SERVES AS SELECT * FROM CSVREAD ('C:/Users/H/Downloads/SERVES.csv’);
[42000-181] 42000/42000 (Help)
You have used the wrong kind of quote character to end the string literal. You have used ’ instead of '. So instead of:
'C:/Users/H/Downloads/SERVES.csv’
use
'C:/Users/H/Downloads/SERVES.csv'
The very last character is slightly different.

Oracle Query in Excel works, but not in SQL

I'm currently trying to query an Oracle server and pull in data into a SQL server.
Now what I've got is this query:
select * from openquery(databasename, 'SELECT * FROM RICALM.REQUEST_TIMESTAMP_EXT DueDate
WHERE DueDate.NAME = "com.ibm.team.apt.attribute.constraintdate"')
If I toss just the query:
SELECT * FROM RICALM.REQUEST_TIMESTAMP_EXT DueDate
WHERE DueDate.NAME = 'com.ibm.team.apt.attribute.constraintdate'
into excel, where I've created an oracle link, I can pull the data just fine.
However, when I pull the data in SQL, I can pull the whole table if I just do "SELECT * FROM RICALM.REQUEST_TIMESTAMP.EXT" but when I add in the WHERE clause I get an error message:
OLE DB provider "OraOLEDB.Oracle" for linked server "databasename" returned message "ORA-00972: identifier is too long".
Any workaround for this? I'd like to just schedule a query like this to run each night so I don't have to deal with refreshing an excel table.
Thanks!
Try this for the openquery you are using:
select * from openquery(databasename, 'SELECT * FROM RICALM.REQUEST_TIMESTAMP_EXT DueDate WHERE DueDate.NAME = ''com.ibm.team.apt.attribute.constraintdate''')
Difference #1 being replacing the double quotes:
"
with two single quotes, which should resolve to a single quote:
''
Difference #2 being putting it as one line.