March 30, 2012 at 9:58 am
Hi, i have a database having dash in the db name - MMG-Events, do I have to add double quote around the db name in command, but the following command fails in sql server scheduled job:
USE "MMG-Events";
Date3/30/2012 11:53:10 AM
LogJob History (test)
Step ID1
Serverxxx
Job Nametest
Step Namestep1
Duration00:00:00
Sql Severity15
Sql Message ID102
Operator Emailed
Operator Net sent
Operator Paged
Retries Attempted0
Message
Executed as user: abc. Incorrect syntax near 'MMG-Events'. [SQLSTATE 42000] (Error 102). The step failed.
March 30, 2012 at 10:01 am
USE [MMG-Events];
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 30, 2012 at 10:02 am
SET QUOTED_IDENTIFIER OFF
USE "SandBox";
select * from sys.tables
--above shows a syntax error
GO
SET QUOTED_IDENTIFIER ON
USE "SandBox";
select * from sys.tables
--above works just fine
Lowell
March 30, 2012 at 11:49 am
Using [MMG-Events] makes for better code portability than relying on quoted identifiers being on.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply