Showing posts with label syntax. Show all posts
Showing posts with label syntax. Show all posts

Friday, March 9, 2012

job failed to start - access denied

Hi,
the SQL Server Agent job that runs a backup to a network
drive wont start.The syntax is as follows :
BACKUP DATABASE Mydb
TO
DISK='\\ServerName\BACKUP\MyDB.BAK'
WITH INIT
In the error log and in the event viewer I can see the
following error message :operating system error 5 ( access
is denied). I can not figure it out why I can not run this
job since the SQL Server Agent startup account use the
domain user account that has sufficient permissions across
the domain and the job itself is owned by the same account.
Is there something else that I should pay attention to ?
Any view is apreciatedThe backup command runs under the security context of the SQL Server service
account. Ensure that account has the needed permissions.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Mirko" <anonymous@.discussions.microsoft.com> wrote in message
news:023c01c3b978$a2a45a80$a001280a@.phx.gbl...
> Hi,
> the SQL Server Agent job that runs a backup to a network
> drive wont start.The syntax is as follows :
> BACKUP DATABASE Mydb
> TO
> DISK='\\ServerName\BACKUP\MyDB.BAK'
> WITH INIT
> In the error log and in the event viewer I can see the
> following error message :operating system error 5 ( access
> is denied). I can not figure it out why I can not run this
> job since the SQL Server Agent startup account use the
> domain user account that has sufficient permissions across
> the domain and the job itself is owned by the same account.
> Is there something else that I should pay attention to ?
> Any view is apreciated
>

Wednesday, March 7, 2012

Job Agent - Syntax Errors

Hi All,
I'm having a problem with a job on an SQL 2000 Server that is linked to pull
data from an SQL 2005 server. When I enter my infromation into the Job Step
properties and parse the SQL, the system tells me it is fine. When I run
the code through query analyzer, it also works fine as well. However, when
the job is run, I am getting a syntax error on the file name because (I
think) it is in double quotes.
Here is the SQL I am trying to parse:
insert into starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging"
(vin,productionDateDT,plantcode,UnitReferenceNo,ProductionLotNo,
KDLotNo,LotPosition,MTOC,ModelGrade,Returned,Completed,GhostBody)
select a.vin, (CONVERT(varchar(10), a.pdate ,101) + ' '
+ CONVERT(varchar(10), a.ptime ,108)), a.plantcode, a.lrnum, a.prod_lot,
a.kd_lot, a.lot_position, a.mtoc, 'N/A', 'N/A', 'N/A','N/A'
from bos_data a
where vin COLLATE DATABASE_DEFAULT not in
(select vin from starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging")
Again, it fails with a syntax error on the "SPS 4_0$AFON DTS Import Staging"
in both areas of the SQL.
Any ideas would be most appreciated.
Thanks!
Brian.My guess is that Agent is executing your code with below setting:
SET QUOTED_IDENTIFIER OFF
Above will interpret double-quotes as string delimiters instead of identifier delimiters. IMO, the
setting should be ON which is ANSI SQL compliant, what QA etc has and apparently even the "parse"
functionality seem to have it set differently.
Anyhow, you can try to use [square brackets] instead of double-quotes. Or add below in beginning of
your TSQL code:
SET QUOTED_IDENTIFIER ON
GO
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Brian Piotrowski" <n0spam-bpiotrowski@.simcoeparts.com> wrote in message
news:A83BACC9-B41F-470F-8F29-8B2B9A6BAB2B@.microsoft.com...
> Hi All,
> I'm having a problem with a job on an SQL 2000 Server that is linked to pull
> data from an SQL 2005 server. When I enter my infromation into the Job Step
> properties and parse the SQL, the system tells me it is fine. When I run
> the code through query analyzer, it also works fine as well. However, when
> the job is run, I am getting a syntax error on the file name because (I
> think) it is in double quotes.
> Here is the SQL I am trying to parse:
> insert into starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging"
> (vin,productionDateDT,plantcode,UnitReferenceNo,ProductionLotNo,
> KDLotNo,LotPosition,MTOC,ModelGrade,Returned,Completed,GhostBody)
> select a.vin, (CONVERT(varchar(10), a.pdate ,101) + ' '
> + CONVERT(varchar(10), a.ptime ,108)), a.plantcode, a.lrnum, a.prod_lot,
> a.kd_lot, a.lot_position, a.mtoc, 'N/A', 'N/A', 'N/A','N/A'
> from bos_data a
> where vin COLLATE DATABASE_DEFAULT not in
> (select vin from starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging")
> Again, it fails with a syntax error on the "SPS 4_0$AFON DTS Import Staging"
> in both areas of the SQL.
> Any ideas would be most appreciated.
> Thanks!
> Brian.|||That worked.
Thank you very much, Tibor!
/b;
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:OoRcLb8nIHA.1036@.TK2MSFTNGP03.phx.gbl...
> My guess is that Agent is executing your code with below setting:
> SET QUOTED_IDENTIFIER OFF
> Above will interpret double-quotes as string delimiters instead of
> identifier delimiters. IMO, the setting should be ON which is ANSI SQL
> compliant, what QA etc has and apparently even the "parse" functionality
> seem to have it set differently.
> Anyhow, you can try to use [square brackets] instead of double-quotes. Or
> add below in beginning of your TSQL code:
> SET QUOTED_IDENTIFIER ON
> GO
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Brian Piotrowski" <n0spam-bpiotrowski@.simcoeparts.com> wrote in message
> news:A83BACC9-B41F-470F-8F29-8B2B9A6BAB2B@.microsoft.com...
>> Hi All,
>> I'm having a problem with a job on an SQL 2000 Server that is linked to
>> pull
>> data from an SQL 2005 server. When I enter my infromation into the Job
>> Step
>> properties and parse the SQL, the system tells me it is fine. When I run
>> the code through query analyzer, it also works fine as well. However,
>> when
>> the job is run, I am getting a syntax error on the file name because (I
>> think) it is in double quotes.
>> Here is the SQL I am trying to parse:
>> insert into starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging"
>> (vin,productionDateDT,plantcode,UnitReferenceNo,ProductionLotNo,
>> KDLotNo,LotPosition,MTOC,ModelGrade,Returned,Completed,GhostBody)
>> select a.vin, (CONVERT(varchar(10), a.pdate ,101) + ' '
>> + CONVERT(varchar(10), a.ptime ,108)), a.plantcode, a.lrnum, a.prod_lot,
>> a.kd_lot, a.lot_position, a.mtoc, 'N/A', 'N/A', 'N/A','N/A'
>> from bos_data a
>> where vin COLLATE DATABASE_DEFAULT not in
>> (select vin from starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import
>> Staging")
>> Again, it fails with a syntax error on the "SPS 4_0$AFON DTS Import
>> Staging"
>> in both areas of the SQL.
>> Any ideas would be most appreciated.
>> Thanks!
>> Brian.
>

Job Agent - Syntax Errors

Hi All,
I'm having a problem with a job on an SQL 2000 Server that is linked to pull
data from an SQL 2005 server. When I enter my infromation into the Job Step
properties and parse the SQL, the system tells me it is fine. When I run
the code through query analyzer, it also works fine as well. However, when
the job is run, I am getting a syntax error on the file name because (I
think) it is in double quotes.
Here is the SQL I am trying to parse:
insert into starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging"
(vin,productionDateDT,plantcode,UnitReferenceNo,Pr oductionLotNo,
KDLotNo,LotPosition,MTOC,ModelGrade,Returned,Compl eted,GhostBody)
select a.vin, (CONVERT(varchar(10), a.pdate ,101) + ' '
+ CONVERT(varchar(10), a.ptime ,108)), a.plantcode, a.lrnum, a.prod_lot,
a.kd_lot, a.lot_position, a.mtoc, 'N/A', 'N/A', 'N/A','N/A'
from bos_data a
where vin COLLATE DATABASE_DEFAULT not in
(select vin from starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging")
Again, it fails with a syntax error on the "SPS 4_0$AFON DTS Import Staging"
in both areas of the SQL.
Any ideas would be most appreciated.
Thanks!
Brian.
My guess is that Agent is executing your code with below setting:
SET QUOTED_IDENTIFIER OFF
Above will interpret double-quotes as string delimiters instead of identifier delimiters. IMO, the
setting should be ON which is ANSI SQL compliant, what QA etc has and apparently even the "parse"
functionality seem to have it set differently.
Anyhow, you can try to use [square brackets] instead of double-quotes. Or add below in beginning of
your TSQL code:
SET QUOTED_IDENTIFIER ON
GO
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Brian Piotrowski" <n0spam-bpiotrowski@.simcoeparts.com> wrote in message
news:A83BACC9-B41F-470F-8F29-8B2B9A6BAB2B@.microsoft.com...
> Hi All,
> I'm having a problem with a job on an SQL 2000 Server that is linked to pull
> data from an SQL 2005 server. When I enter my infromation into the Job Step
> properties and parse the SQL, the system tells me it is fine. When I run
> the code through query analyzer, it also works fine as well. However, when
> the job is run, I am getting a syntax error on the file name because (I
> think) it is in double quotes.
> Here is the SQL I am trying to parse:
> insert into starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging"
> (vin,productionDateDT,plantcode,UnitReferenceNo,Pr oductionLotNo,
> KDLotNo,LotPosition,MTOC,ModelGrade,Returned,Compl eted,GhostBody)
> select a.vin, (CONVERT(varchar(10), a.pdate ,101) + ' '
> + CONVERT(varchar(10), a.ptime ,108)), a.plantcode, a.lrnum, a.prod_lot,
> a.kd_lot, a.lot_position, a.mtoc, 'N/A', 'N/A', 'N/A','N/A'
> from bos_data a
> where vin COLLATE DATABASE_DEFAULT not in
> (select vin from starscream.NAPROD_40.dbo."SPS 4_0$AFON DTS Import Staging")
> Again, it fails with a syntax error on the "SPS 4_0$AFON DTS Import Staging"
> in both areas of the SQL.
> Any ideas would be most appreciated.
> Thanks!
> Brian.
|||That worked.
Thank you very much, Tibor!
/b;
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:OoRcLb8nIHA.1036@.TK2MSFTNGP03.phx.gbl...
> My guess is that Agent is executing your code with below setting:
> SET QUOTED_IDENTIFIER OFF
> Above will interpret double-quotes as string delimiters instead of
> identifier delimiters. IMO, the setting should be ON which is ANSI SQL
> compliant, what QA etc has and apparently even the "parse" functionality
> seem to have it set differently.
> Anyhow, you can try to use [square brackets] instead of double-quotes. Or
> add below in beginning of your TSQL code:
> SET QUOTED_IDENTIFIER ON
> GO
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Brian Piotrowski" <n0spam-bpiotrowski@.simcoeparts.com> wrote in message
> news:A83BACC9-B41F-470F-8F29-8B2B9A6BAB2B@.microsoft.com...
>

Monday, February 20, 2012

JDBC Error Incorrect syntax near ''-''.

Hi I am using JDBC driver version "1.0.809.102". In the ms sqlserver 2000 database I am acessing there is a table named as "CDR_DATA_2007-09-12". When I run the following query "select * from CDR_DATA_2007-09-12" i get the following exception. Please help me out to solve this problem.

com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: Incorrect syntax near '-'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(Unknown Source)
at Test.mssqldb(Test.java:80)
at Test.main(Test.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)

Thanks,
Gavin

Hi Gavin,

Looks like SQL Server is thinking "CDR_DATA_2007-09-12" is a numeric operation of "CDR_DATA_2007" - 09 - 12.

Try escaping the table name with '[]'. So the SELECT statement will look like:

"select * from [CDR_DATA_2007-09-12]"

HTH,

Jimmy

|||Hi Jimmy,

Thanks it worked.

Cheers,
Gavin

JDBC Error Incorrect syntax near ''-''.

Hi I am using JDBC driver version "1.0.809.102". In the ms sqlserver 2000 database I am acessing there is a table named as "CDR_DATA_2007-09-12". When I run the following query "select * from CDR_DATA_2007-09-12" i get the following exception. Please help me out to solve this problem.

com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: Incorrect syntax near '-'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(Unknown Source)
at Test.mssqldb(Test.java:80)
at Test.main(Test.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)

Thanks,
Gavin

Hi Gavin,

Looks like SQL Server is thinking "CDR_DATA_2007-09-12" is a numeric operation of "CDR_DATA_2007" - 09 - 12.

Try escaping the table name with '[]'. So the SELECT statement will look like:

"select * from [CDR_DATA_2007-09-12]"

HTH,

Jimmy

|||Hi Jimmy,

Thanks it worked.

Cheers,
Gavin

JDBC Error Incorrect syntax near ''-''.

Hi I am using JDBC driver version "1.0.809.102". In the ms sqlserver 2000 database I am acessing there is a table named as "CDR_DATA_2007-09-12". When I run the following query "select * from CDR_DATA_2007-09-12" i get the following exception. Please help me out to solve this problem.

com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: Incorrect syntax near '-'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(Unknown Source)
at Test.mssqldb(Test.java:80)
at Test.main(Test.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)

Thanks,
Gavin

Hi Gavin,

Looks like SQL Server is thinking "CDR_DATA_2007-09-12" is a numeric operation of "CDR_DATA_2007" - 09 - 12.

Try escaping the table name with '[]'. So the SELECT statement will look like:

"select * from [CDR_DATA_2007-09-12]"

HTH,

Jimmy

|||Hi Jimmy,

Thanks it worked.

Cheers,
Gavin