Importing external data to a SQL table to request a result - sql-server

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.

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.

Copy one table data into another db by using INTO Select

I am getting this error :
Msg 156, Level 15, State 1, Line 39
Incorrect syntax near the keyword 'in'
My code:
SELECT *
INTO EmployeesBackup IN 'DB2.mbd'
FROM Employee
Your syntax is off, and perhaps you intended to do an INSERT INTO ... SELECT:
INSERT INTO DB2.EmployeesBackup
SELECT *
FROM DB1.Employee;
This would work assuming that both databases are on the same server, and that your backup table EmployeesBackup has the same definition as the Employee table.
Try this:
INSERT INTO [DBName].dbo.EmployeesBackup
SELECT * FROM [DBName].dbo.Employee
Please note that, Either both database should be available on the same SQL Server OR if one of them is available on the different server then it should be Linked

Microsoft SQL server 2016, cannot create sequence

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'

Could not delete database in SQL Server Management Studio

I have a database aspnet-Ebuy-20151210093351. I use the command:
drop database aspnet-Ebuy-20151210093351
to delete it, but I cannot do it, I get an error message:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.
You need to escape the database name with brackets, without which SQL Server will interpret the dashes - as being subtraction symbols.
drop database [aspnet-Ebuy-20151210093351]
Have you tried wrapping the table name in Brackets []?
drop database [aspnet-Ebuy-20151210093351]

SQL Server 2005 Alter table column not being recognized

This is on a replicated table in SQL Server 2005
I used the following command:
ALter table dbo.apds alter column docket nvarchar(12) null
and it executed with no errors, everything looks clean.
Column spec shows it now has 12 (was previously set to 6) on both tables, publisher
and subscriber.
But when I try to put more than 6 characters in that column, I get the error:
Msg 8152 lefel 16, state 13, procedure trgapdsupdate, line 5
String or binary data would be truncated.
I can still only write 6 characters of data to that column even though it shows 12 as the
column specification..
Any ideas?
Thank you in advance..
You say
I get the error: msg 8152 lefel 16, state 13, procedure trgapdsupdate,
line 5 string or binary data would be truncated. The statement has
been terminated
So what is trgapdsupdate?
From the name it looks like an update trigger on the table apds?
Does that need to be updated to deal with the new column value? For example writing to an audit table whose definition needs to be updated.

Resources