SQL facing error while running bcp - sql

i am facing error wile running this in sql server 2000
bcp "select dmedocno ,dmename,dmeauthor,dmekeywords from document
where repositoryid=4 and dmedocno between 1 and 60000 order by
dmedocno" queryout c:\LR_Query29_cutover_19_August.csv -Swsapp0772 -T -c -t","
Error is:
Server: Msg 103, Level 15, State 7, Line 1
The identifier that starts with 'select dmedocno ,dmename,dmeauthor,dmekeywords from document where repositoryid=4 and dmedocno between 1 and 60000 order by dmed' is too long. Maximum length is 128.
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'queryout'.

why your sql server treats the query as identifier? hm...
Check default QUOTED_IDENTIFIER option for the server, try to set it to OFF

Related

Cannot continue the execution because the session is in the kill state

I try to execute a update query in SQL Server 2016 (v13.0.5026.0) and get these error messages:
Msg 596, Level 21, State 1, Line 0
Cannot continue the execution because the session is in the kill state.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Checked for corrupted index or anything
DBCC CheckDB (DBNAME) WITH NO_INFOMSGS, ALL_ERRORMSGS
--Returns no error
As Microsoft suggested update with the below link:
https://support.microsoft.com/en-us/help/4163478/fix-access-violation-when-incremental-statistics-automatically-updated
I tried an update to Cummulative Update(CU6) and changed to 13.0.5292.0
It says CU1 update has to fix it but doesn't solve the issue.
The query is:
UPDATE tableName
SET fieldName1 = 'a long query with some html tags and all it has 3600 chars'
WHERE fieldName2 = 12345
It doesn't have any special characters that SQL can't handle.
Any help would be great.

How to solve the error_syntax error near '< '

Msg 102, Level 15, State 1, Line 3 Incorrect syntax near '<'.
I got the above error message every time I tried to execute the below query.
UPDATE [dbo].[FM1]
SET [Datum] = <Datum, smalldatetime,>
,[Gesamtzeit] = <Gesamtzeit, nvarchar(5),>
You can try this no need to specify datatype here.
UPDATE [dbo].[FM1]
SET [Datum] = 'YourValue'
,[Gesamtzeit] = 'YourValue'
where ...

Msg 102, Level 15, State 1, Line 5 Incorrect syntax near '‌'. insert statement SQL Server

Hi i am getting this error Msg 102, Level 15, State 1, Line 5 Incorrect syntax near '‌' and i dont know from where is the problem. That is the code and also i attached a screenshot.
USE CobornSalesDB;
GO
INSERT INTO SalesActivity
VALUES ('AC00001','05-12-2016','AG16170','C000001',
'P0001','S00002'‌​,1,200000.00,NULL,‌1.2220,20,100000.00,
'12-25-2016','12-30-2016','12-31-2016','A000001','PR00001');
GO
![SCREENSHOT][1]
You have a hidden character
If I convert to ANSI in NotePad++
INSERT INTO
SalesActivity
VALUES
(
'AC00001',
'05-12-2016',
'AG16170',
'C000001',
'P0001',
'S00002'‌​, --this bad boy
1 ,
200000.00,
NULL,
1.2220,
20 ,
100000.00,
'12-25-2016',
'12-30-2016',
'12-31-2016',
'A000001',
'PR00001');
GO

SQL Error near the word 'go'

Why does SQL Server report that this statement isn't correct?
use DIGITECH
go
select *
from kunde as k
left join adresse as a on k.FK_AdID = a.AdID
where Name = 'Dirk'
go
SQL displays this error (in German):
Meldung 102, Ebene 15, Status 1, Zeile 14
Falsche Syntax in der Nähe von 'go'.
Meldung 102, Ebene 15, Status 1, Zeile 14
Falsche Syntax in der Nähe von 'go'.
Translated to english:
Msg 102 , Level 15 , State 1, Line 14
Incorrect syntax near 'go' .
Msg 102 , Level 15 , State 1, Line 14
Incorrect syntax near 'go' .
As other have pointed out, GO is the default batch delimiter for tools like Management Studio or sqlcmd. SQL Server does not understand GO, the tools use it to separate batches and send individual batches to SQL Server. You probably took an entire .sql file and executed in your app.
You can use a library like DbUtilSqlCmd which understands the sqlcmd delimiters (GO), and other sqlcmd specific syntax like :setvar, and execute your .sql file through it.
Can you specify the database in the query and avoid the go statements? For example:
select * from DIGITECH.dbo.kunde as k
left join DIGITECH.dbo.adresse as a
on k.FK_AdID = a.AdID
where Name = 'Dirk'

How do I create an eventlog event upon a SQL connectivity issue? Here's my concrete example:

I need to connect to an external database and the connectivity may sometimes fail. However, I am seeing that if the SELECT statement below fails, the IF statement after that does not execute at all:
SELECT COUNT(*) FROM [DB].[View]
IF ##ERROR <> 0
BEGIN
EXEC xp_logevent 63000, 'Issue!', error
END
Here's the error message:
Msg 8180, Level 16, State 1, Line 32
Statement(s) could not be prepared.
Msg 4413, Level 16, State 1, Line 32
Could not use view or function 'DB.view' because of binding errors.
Msg 208, Level 16, State 1, Procedure Servers2Switchs, Line 60
Invalid object name xxx.