Microsoft SQL server 2016, cannot create sequence - sql-server

I have Microsoft SQL server 2016, I am using SSMS to do my DB work. I am trying to create sequences and I keep getting this error
CREATE SEQUENCE dbo.seq_changeid As int START WITH 1 INCREMENT BY 1;
Error
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'SEQUENCE'.
Msg 319, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.
I have tried it in SQLCMD and it does not work there as well. This is local database that i am using for some testing. I login using SQL Server Authentication.
I even tried select * from sys.sequences and it errors
Msg 208, Level 16, State 1, Line 10
Invalid object name 'sys.sequences'

Related

Synapse SQL: Error in Inserting url link into Synapse Table

I am facing issues while INSERTing a URL into Synapse Table.
DECLARE #today datetime;
SET #today = CURRENT_TIMESTAMP
INSERT INTO table_url([APITag]
,[AuthAPIUrl]
,[DataFetchUrl]
,[CreatedOn]
,[CreatedBy])
VALUES
('Indent',
'https://beta-url.<url_name>.com',
'https://beta-url.<url_name>.com',
#today,
'Abcd')
But the above statement is giving error:
Msg 104455, Level 16, State 1, Line 1
USE statement is not supported to switch between databases. Use a new connection to
connect to a different Database.
Msg 103010, Level 16, State 1, Line 3
Parse error at line: 11, column: 12: Incorrect syntax near ','.
Don't know what I am missing here. Is there any way to convert the URL into string?
After reproducing in my environment, I have received the same error.
As per the error, you are receiving this because the USE Database Statement is not supported in Azure synapse. Alternatively, you can connect to your database by directly opting from the drop down as mentioned below from your dedicated pool.

Importing external data to a SQL table to request a result

Salutations,
I am currently trying to pull tag data (ASCII string) from a transaction managing software (softing 56eATManager) to an SQL table (SQL Server 2014) I currently have created. I need the data that I import to SQL to then export a ZPL (zebra printing language) back to the transaction manger and subsequently back to the PLC that the string originated from. The transaction manager is current mapped to the same server that the database is in.
This is in the SQL currently with errors on a few different lines:
use [DATABASE]
declare #workorderID varchar(max)
declare #ZPLcallup varchar(max)
CREATE EXTERNAL DATA SOURCE <Softing tManager>
WITH
( LOCATION = <172.16.0.213>
, PUSHDOWN = ON
, TYPE = BLOB_STORAGE
);
This is the list of errors I am getting:
Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword
'EXTERNAL'.
Msg 319, Level 15, State 1, Line 3 Incorrect syntax near the keyword
'with'. If this statement is a common table expression, an
xmlnamespaces clause or a change tracking context clause, the previous
statement must be terminated with a semicolon.

Quotation mark in column name - Invalid column name

I am using SQL server 2017 and having a problem with the double quotation marks in columns' names
The query I used is like this:
insert into torque_value.value_table("ID","value","timestamp") values ('111','1111',convert(datetime,'2017-12-12T00:34:00.000'))
which worked well in SQL Server management studio but did not work at all in sqlcmd and it returned error
Msg 207, Level 16, State 1, Server USER\SQLEXPRESS, Line 1
Invalid column name 'ID'.
Msg 207, Level 16, State 1, Server USER\SQLEXPRESS, Line 1
Invalid column name 'value'.
Msg 207, Level 16, State 1, Server USER\SQLEXPRESS, Line 1
Invalid column name 'timestamp'.
Is the syntax in the sqlcmd different from in SSMS ? How should I handle this kind of error ?

insert into select, working with two tables from different servers error

My code:
INSERT INTO lclTabla
SELECT *
FROM openquery([LD_DB_A0FCCD_ALDOLANCHO],
'SELECT *
FROM [DB_A0FCCD_aldolancho].[dbo].[servTable]')
WHERE
lclTabla.dni = [LD_DB_A0FCCD_ALDOLANCHO].[DB_A0FCCD_aldolancho].[dbo].[servTable].[dni]
is causing an error:
Msg 4104, Level 16, State 1, Line 17
The multi-part identifier "lclTabla.dni" could not be bound.
Msg 4104, Level 16, State 1, Line 17
The multi-part identifier "LD_DB_A0FCCD_ALDOLANCHO.DB_A0FCCD_aldolancho.dbo.servTable.dni" could not be bound.
I want to insert where the id from local table is the same in the server table
Please help!!! In T-SQL
Whenever you run cross server query, You must follow proper naming convention
i.e. [server name].[database name].[schema name].[table name]
In your query, I can see wrong naming convention in -
"[LD_DB_A0FCCD_ALDOLANCHO].[DB_A0FCCD_aldolancho].[dbo].[servTable].[dni]"

How to execute table valued function in SQL Server

I'm getting syntax error when trying to execute table valued function.
select * from fn_security(select R.rk from dbo.LINK R)
Error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'select'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'.
What am I doing wrong? how to execute this?
You can't pass whole table,like the way,you are trying now..you can use cross apply to get all
you can try below
select * from dbo.LINK r
cross apply
dbo. fn_security(r.rk)

Resources