Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Index optimization failed for User databases Expand / Collapse
Author
Message
Posted Wednesday, January 2, 2013 2:36 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 7:01 AM
Points: 208, Visits: 776

Hi ,


Index optimization job is failing with the below error ::

Message
Executed as user: XXXXXXXXX. Incorrect syntax near '-'. [SQLSTATE 42000] (Error 102). The step failed.


Thanks,
lavanya
Post #1401710
Posted Wednesday, January 2, 2013 2:43 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 10:48 AM
Points: 20,857, Visits: 32,877
Check the code used in the job step. Not enough info to really say much more.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1401712
Posted Wednesday, January 2, 2013 2:44 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 9:13 AM
Points: 40,609, Visits: 37,070
You have a table or index with a - in the name and your code doesn't wrap table and index names in []. You're just going to have to go through the job, see where the incorrect line of code is and fix it.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1401713
Posted Wednesday, January 2, 2013 3:27 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 7:01 AM
Points: 208, Visits: 776
hi ,

we are using the same script in all servers ,but wea re not seeing any issues on other servers expect this server ..
Post #1401735
Posted Wednesday, January 2, 2013 3:31 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 8, 2014 1:45 AM
Points: 5,221, Visits: 5,120
You have index(s) with a - in their name. If the script does not put the index name in [] brackets when rebuilding/reorganising, then the script will fail.

Either change the index(s) name, or change the script to wrap [] around the index(s).




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1401736
Posted Wednesday, January 2, 2013 3:51 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 7:01 AM
Points: 208, Visits: 776
i need to change the script in the below lines

IF @frag < 30.0
SET @command = N''ALTER INDEX '' + @indexname + N'' ON '' +@DBname+ N''.''+ @schemaname + N''.'' + @objectname + N'' REORGANIZE'';
IF @frag >= 30.0
SET @command = N''ALTER INDEX '' + @indexname + N'' ON '' +@DBname+ N''.'' + @schemaname + N''.'' + @objectname + N'' REBUILD'';
IF @partitioncount > 1
SET @command = @command + N'' PARTITION='' + CAST(@partitionnum AS nvarchar(10));
EXEC (@command);
-- PRINT N''Executed: '' + @command;
END;

how can i find the index starts with '-'??


Post #1401743
Posted Wednesday, January 2, 2013 3:54 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 8, 2014 1:45 AM
Points: 5,221, Visits: 5,120
Check sys.indexes in every database where the name has -

IF @frag < 30.0
SET @command = N''ALTER INDEX ['' + @indexname + N''] ON ['' +@DBname+ N''].[''+ @schemaname + N''].['' + @objectname + N''] REORGANIZE'';
IF @frag >= 30.0
SET @command = N''ALTER INDEX ['' + @indexname + N''] ON ['' +@DBname+ N''].['' + @schemaname + N''].['' + @objectname + N''] REBUILD'';
IF @partitioncount > 1
SET @command = @command + N'' PARTITION='' + CAST(@partitionnum AS nvarchar(10));
EXEC (@command);
-- PRINT N''Executed: '' + @command;
END;

Added extra [] around the db schema object in case anything else has special characters in the name.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1401746
Posted Wednesday, January 2, 2013 4:05 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 7:11 AM
Points: 277, Visits: 699
Hi Lavanya,

Did the above mention code solved your Problem or are you still facing it?
Post #1401755
Posted Wednesday, January 2, 2013 4:15 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 7:01 AM
Points: 208, Visits: 776
hi Thanks for the quick response ..


I searched alldatabases with the below script , but i didnt find any indexes names with -

select * from sys.indexes where name like '%-%'

i have a doubt you are saying about underscore' _' or ' - ' ???
Post #1401762
Posted Wednesday, January 2, 2013 4:24 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 8, 2014 1:45 AM
Points: 5,221, Visits: 5,120
If no indexes with a - then do you have a database or a schema or an object which has - in its name?



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1401763
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse