Special character in Schema name in Snowflake - snowflake-cloud-data-platform

I accidently created a schema in snowflake as {"target_db.target_schema"}. When I tried to drop this schema using
drop schema "{"target_db.target_schema"}":
I am getting error as,
SQL compilation error: syntax error line 1 at position 15 unexpected 'target_db'.
Is there any way to drop the schema.

You can double the double quotes:
drop schema "{""target_db.target_schema""}";

In such scenario the Snowsight UI is helpful:
Under ellipsis there is an option "Place name in SQL":
Which returns properly quoted name: TEST."{""target_db.target_schema""}"

Related

Snowflake Error: SQL compilation error: error line 3 at position 6 invalid identifier 'INTERNAL_ID'

I am running into an issue when I try to query a view. I can successfully pull the data without a WHERE clause, but when I add a WHERE clause it fails.
Good Query:
SELECT *
FROM V_WMS_STG_BI_DMLABOR
Failed Query:
SELECT *
FROM V_WMS_STG_BI_DMLABOR
WHERE Internal_ID = 5587640
I tried to add single and/or double quotes to the Internal_ID and value without any success. I added single quotes to the Internal_ID ('Internal_ID') but the query didn't return any data. I also added single quotes to both the identifier and value, it removed error but no data was returned.
Here is sample data that should be returned.
Sample Data Set
Here is the schema for the view Schema
Thank you for your help in advance.
you schema shows the column as Internal_ID which implies you need to use double quotes to tell snowflake to not auto uppercase the column name, thus "Internal_ID". The trick is you have to have the case 100% correct when you put it inside double quotes.
You can double click the column name in the UI editor to have it past it into the SQL editor with the correct quotes/casing.
The value should not need quotes as it's a number, and single quotes is for strings.
thus:
SELECT *
FROM V_WMS_STG_BI_DMLABOR
WHERE "Internal_ID" = 5587640
should work.

Snowflake DROP TABLE table_name(...)

Why the below syntax does not error out:
CREATE TABLE a1 AS SELECT 1 a;
TRUNCATE TABLE a1(sth);
-- SQL compilation error: syntax error line 1 at position 17 unexpected '('.
DROP TABLE a1(sth);
-- A1 successfully dropped.
-- here I would expect an error
Both TRUNCATE TABLE and DROP TABLE take parameter <name>
Specifies the identifier for the table to drop. If the identifier contains spaces, special characters, or mixed-case characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive (e.g. "My Object").
Is there a special behaviour for table_name(...)?
In "drop table", the table name does not accept any parameters so it should not accept any parentheses. Please open a ticket and report this bug to Snowflake.

Incorrect syntax near 'FK_dbo.SalesOrderLineTasks_dbo.Events_Event_ID'

When I try and run
alter table salesorderlinetasks drop constraint
'FK_dbo.SalesOrderLineTasks_dbo.Events_Event_ID'
this command in Sql Server Management Studio, I get an error.
Incorrect syntax near 'FK_dbo.SalesOrderLineTasks_dbo.Events_Event_ID'.
What should I do?
It should contain double quotes instead of single quotes.
Use no quotes:
alter table salesorderlinetasks drop constraint
FK_dbo.SalesOrderLineTasks_dbo.Events_Event_ID
Quotes delimit literal text, but alter requires an entity (which is not a text string but a plain entity name).

Microsoft SQL Server Management 2012 and Stored Procedures

My RDMS is the above. I have a stored procedure that takes 13 parameters. I have a table that holds those input values. I am pasting what I have done. Please help because its not executing. I am getting the following error: Incorrect syntax near '.'.
Please look at the attachment to see the location of the table I am trying to use.enter image description here
use ssisconfiguration.dbo.BalladHealthDayOneStats;
exec Clarity.ssis.sp_BalladDayOneMaster
[StatisticStartDate],[StatisticEndDate],[CostCenterList],[ProcedureCodeList],[Statistic],[StatisticDescription],[PatientTypeIndicator],
--[RVThreshold],[FiscalYear],
1,2017,
[PatientServiceList],[PatientClassList],[PatientStatusList]
The purpose of USE is to select the database.
i would suggest modify to
use ssisconfiguration
exec Clarity.ssis.sp_BalladDayOneMaster
([StatisticStartDate],[StatisticEndDate],[CostCenterList],[ProcedureCodeList],[Statistic],[StatisticDescription],[PatientTypeIndicator],
--[RVThreshold],[FiscalYear],
1,2017,
[PatientServiceList],[PatientClassList],[PatientStatusList])
replace the column name with values in the []

How to change timezone of Oracle 9i Database

How to change Oracle 9i database timezone,
I have a user schema with name 'HR_NU', its timezone is -07:00, I want to change it using alter query
alter database set time_zone='+05:00';
but getting errors
Error starting at line 10 in command:
alter database set time_zone='+05:00'
Error report:
SQL Error: ORA-02231: missing or invalid option to ALTER DATABASE
02231. 00000 - "missing or invalid option to ALTER DATABASE"
*Cause: An option other than ADD, DROP, RENAME, ARCHIVELOG, NOARCHIVELOG,
MOUNT, DISMOUNT, OPEN, or CLOSE is specified in the statement.
*Action: Specify only legal options.
I google same issue, and came to know that if I have a table containing a field of datatype timestamp with localtimezone then I will get above error, the solution suggested is change datatype of each column having datatype timestamp, but I have more than 300 tables, and about 200 columns of timestamp datatype.
Any help please.
[SET TIME_ZONE [time_zone_region]]
can be also achieved like this " set time_zone = 'America/New_York' "
have you tried that?

Resources