'Syntax error: Expected ")"' in BigQuery - sql

I want to execute the following SQL statement on BigQuery:
create table TMSPCBTDZOP000(
ART_ID VARCHAR(18),
LND_ID VARCHAR(3),
ART__BEZ VARCHAR(60),
ART_ANZ_ID VARCHAR(18))
I got the following error message:
Error: Syntax error: Expected ")" or "," but got "(" at [2:24]
I tried both legacy and standard SQL.
We are currently trying to use BigQuery as a data source for our reporting software (MicroStrategy) and it fails with the error shown above. The same error appears if I directly fire this SQL statement in bq. How can I fix this?

VARCHAR is not a supported data type; see the data types documentation. Use STRING instead:
create table TMSPCBTDZOP000 (
ART_ID STRING,
LND_ID STRING,
ART__BEZ STRING,
ART_ANZ_ID STRING
)
You need to use standard SQL for this, and you probably need to qualify TMSPCBTDZOP000 with the name of the dataset, e.g. dataset.TMSPCBTDZOP000.

I think you are looking something like mentioned in old thread here
Create table SQL syntax in Google Bigquery
I found it useful and this may help you how to create a table in bigquery.
Cheers,

Related

Amazon Athena - Error Create Iceberg table

I used this as a reference to create a Create statement that creates an Apache Iceberg table in Amazon Athena's Query Editor. Below.
CREATE TABLE iceberg_table (id int, data string, category string)
PARTITIONED BY (category, bucket(16, id))
LOCATION 's3://xxxxxxxx/iceberg_table/'
TBLPROPERTIES (
'table_type' = 'ICEBERG',
'format' = 'parquet',
'write_target_data_file_size_bytes' = '536870912'
)
When I ran this, I got the following error.
Iceberg cannot found the requested entity
Also, when I ran Explain, I got the following message
line 2:1: mismatched input 'PARTITIONED'. Expecting: 'COMMENT', 'WITH', <EOF>
So, I think there is a problem with the Create statement I created.
I checked to see if extra spaces had been removed or if the quotes were incorrect, but could not find the cause.
I would appreciate your help.
Thanks.
The code works fine for me. I'm using Athena with Engine v3, maybe that's the cause?

SQL (DB2) Creating table by selecting from other table

I´ve read several discussions and websites about creating a SQL query to create a table by selecting data from other table, but none of them solved my issue. I don´t know what else to do.
I am working on a SQL script to run a sequence of selects and creates do resume some data. I´ve been using this SQL queries on a SaS server using DB2 data. Now I need to migrate to Dbeaver to using other sources.
I just want to create a table by selecting some columns and data from other table, for this simple example :
"CREATE TABLE DB2XXXX.PaidResume AS
(SELECT HistoricalPaid.AccountNumber AS CONTA
FROM DB2XXX.HistPaid HistoricalPaid
WHERE HistoricalPaid.AccountNumber = 'XXXXX');
All I got it this error
Error occurred during SQL query execution
SQL Error [42601]: ILLEGAL SYMBOL "<END-OF-STATEMENT>". SOME SYMBOLS THAT MIGHT BE LEGAL ARE:. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.19.26
If I just exclude the "CREATE TABLE DB2XXXX.PaidResume AS" and run the select only, it works.
You must include WITH DATA or WITH NO DATA at the end of the SQL statement. For example:
create table u as (select a from t) with data;
See example at db<>fiddle.

exporting the data gives error when the type is 'smalldatetime' and value is null

In SQL server, I have a table with 'smalldatetime' data type for one of the column. When I am trying to export the data using Microsoft SQL server import/export wizard, it is giving me conversion error because the field contains NULL value in Date field. Can you please help me in resolving this error.
What steps need to be followed in order to resolve the conversion error.
Are you trying to copy "table to table" or "query to table"?
Cause if your problem is only with null values you can write a query and use ISNULL() function.
Can you post the error here? I´m asking cause maybe your problem isn´t it. Maybe you´re trying to convert a type into another that is not compatible.

Create an external table Informix

I am trying to create an external table in Informix.
create external table test_table(cols varchar(10))
using ( datafiles('C:/sample.txt'), format 'delimited', deluxe);
But it gives me an error :
[Error Code: -26174, SQL State: IX000] Incorrect DATAFILE entry C:/sample.txt.
Can anyone suggest me the right syntax for path entry...
I have also tried.
load from "C:\sample.txt" insert into test_table;
Which gives me a syntax error. Any help is greatly appreciated!!
About the create external table
Did you check the correct syntax at the manual? (here)
At datafiles keyword, you don't use the correct syntax.
This probably will work.
create external table test_table(cols varchar(10))
using ( datafiles('DISK:C:\sample.txt'), format 'delimited', deluxe);
About the load
It isn't a native command from the engine, is a specific command of dbaccess utility.
So, if you aren't using dbaccess, it will not work.
BTW, the syntax of your load is correct...

Simple question on a SQL create table

I was actually in process of creating a sample table in my test database when somehow I missed out on proper syntax and came up with this statement for create table -
CREATE TABLE A (id as INT, column1 as nvarchar(10))
and when I tried to execute this statement, I got the error below -
'nvarchar' is not a recognized built-in function name.
Altough, I found that I should not have used "as" in the column declaration and corrected it, I am now curious on why I got this error for only nvarchar and not for INT.
Also why this error instead of a incorrect syntax or something like that.
Thanks in advance.
AS is used to define computed columns. Therefore SQL Server expects an expression here, and this "looks" like a function call.
Computed columns info on MSDN for SQl Server 2005