This question already has an answer here:
How to use SQL Query with hyphen in Collection name?
(1 answer)
Closed last year.
In my database I have a container named "freedom-fighters".
Doing SELECT * FROM [freedom-fighters] does not work. Neither does SELECT * FROM "freedom-fighters", nor SELECT * FROM ["freedom-fighters"], nor anything else I have tried.
I am working in the web gui.
When you query via Core/SQL API, you don't need to specify the exact collection name. In the Portal you can use a simple alias to query. For example,
SELECT * FROM c
Cosmos DB will know which one you are targeting already and c will be something like an alias.
Related
Say I have an InfluxDB query where the user supplies a measurement. In this case the user supplies the value "foo". Then I would construct the query:
SELECT * from "foo"
WHERE time > "2022-06-21T18:27:16.041Z"
What's the best way to prevent injection attacks here? I know InfluxDB supports bind parameters, but apparently that feature only works for the WHERE clause, so it wouldn't help me.
I was thinking of trying this:
const query = `
SELECT "value" FROM "${Influx.escape.measurement(key)}"
WHERE time > "2022-06-21T18:27:16.041Z"
`
...but based on my testing that function doesn't escape quotation marks, only spaces.
I'm using InfluxDB 1.x in Node.js via the influx npm package.
Before sending the value to the query try filtering chars like single and double quotes
Looking into docs, articles I can see that every subquery is in brackets, like:
select * from (select "value" from "measurement") <where_caluse>
So filtering for brackets beetwen "FROM" and "WHERE" should be enough.
Based on:
#1 https://www.influxdata.com/blog/tldr-influxdb-tech-tips-january-26-2017/
#2 https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#subqueries
in snowflake it searches data with case sensitiveness while in sql server it used to search with case insensitiveness i changed database level collation with below command
ALTER DATABASE IF EXISTS powerdb SET COLLATION = 'en-ci'
but it did not help is there any other way to achive case insensitiveness
There's a number of ways really.
one of them is using ILIKE for your string comparison: https://docs.snowflake.net/manuals/sql-reference/functions/ilike.html
another one is setting up collation at column level:
https://docs.snowflake.net/manuals/sql-reference/collation.html
- but please note that not all of the string functions are supported on collated columns
also you can use COLLATION functions (also described in the link below) or set it on database level with account-level parameter of DEFAULT_DDL_COLLATION = 'en-ci'
everything depends on what you want to achieve really...
The below question and answer is perfect for answering this question for almost any database except for Sybase ASE (SAP ASE):
Efficient SQL test query or validation query that will work across all (or most) databases
What is a suitable setting for ASE ? I'm using ASE 16 with driver:
spring.datasource.driver-class-name=com.sybase.jdbc4.jdbc.SybDriver
pom:
<dependency>
<groupId>com.sybase</groupId>
<artifactId>jconn4</artifactId>
<version>16</version>
</dependency>
From the error below it appears to be expecting a stored procedure, however when I try an existing sproc (as appose to "SELECT 1") it doesn't work either
HikariPool-1 - Failed to execute connection test query (Stored procedure '"SELECT 1"' not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
app properties:
spring.datasource.hikari.connection-test-query="SELECT 1"
In Sybase ASE select can be without where or from clause
A simple select statement contains only the select clause; the from clause is almost always included, but is necessary only in select statements that retrieve data from tables. All other clauses, including the where clause, are optional.
So you can just use Select 1 removing the double quotes as in example
connection-test-query: SELECT 1
I am creating an SSIS Execute SQL Task that will use variables but it is giving me an error when I try to use it. When I try to run the below, it gives me an error and when I try to build the query, it gives me an error SQL Sytnax Errors encountered and unable to parse query. I am using an OLEDB connection. Am I not able to use variables to specify the tables?
You can't parameterize a table name.
Use the Expressions editor in your Execute SQL Task to Select a SqlStatementSource property.
Try "SELECT * FROM " + #[User::TableName]
After clicking OK twice (to exit the Task editor), you should be able to reopen the editor and find your table name in the SQL statement.
Add a string cast in a case where it might be a simple Object - (DT_WSTR,100)
You are using only single parameter(?) in the query and assigning 3 inputs to that parameters which is not fair put only single input and assign some variable as input as shown in image and change the value of variable respectively.
the parameter name should be incremented by 1 start with 0 because they are the indexes representing the "?" in the query which was written the query window.
I installed Rocket Software for accessing an Unidata Db through SQL Server 2008. The idea is to write SQL Procedures for populating SQL Tables, but the problem I am getting is retrieving wrong filenames i. e. Select * from MyDb_Members. I got the field names as Member{Name, Phone{number. In my unidata core these fields are named as Member Name, Phone Number.
Do you know if there is way to run sql queries with those field names without getting sql query errors. It looks sql server does not like to use that name convention:
Select Member{Name from MyDb_Members
Error near '{'
Thanks for your help
Try formatting the query using NATIVE keyword. I don't use Unidata, but in UniVerse this works well. I have a lot of columns that contain periods and those are illegal column names in standard SQL.
{ NATIVE "Select * from MyDb_Members" }