olahallengren / sql-server-maintenance-solution

SQL Server Maintenance Solution
https://ola.hallengren.com
MIT License
2.91k stars 756 forks source link

CHECKTABLE integrity check fails if there is a single quote mark (') in table/schema name #470

Closed alexander-suprun closed 2 days ago

alexander-suprun commented 3 years ago

When you run DatabaseIntegrityCheck with @DatabaseIntegrityCheck = 'CHECKTABLE' and one of the table has a single quote mark (') in the name or schema then the generated DBCC CHECK command will be invalid and fail.

--// Version: 2019-04-28 16:40:00

olahallengren commented 2 years ago

I have tested this, but I am not able to reproduce it.

Could you post the complete output?

alexander-suprun commented 2 years ago

Sure.

CREATE DATABASE Test GO USE Test CREATE TABLE [Test'Table](id INT) GO Use master EXEC dbo.DatabaseIntegrityCheck @Databases = 'Test', @CheckCommands = 'CHECKTABLE'

Output: Date and time: 2022-01-07 09:36:16 Command: USE [Test]; DBCC CHECKTABLE ('[dbo].[Test'Table]') WITH NO_INFOMSGS, ALL_ERRORMSGS, DATA_PURITY Msg 156, Level 15, State 1, Line 7 Incorrect syntax near the keyword 'Table'. Msg 105, Level 15, State 1, Line 7 Unclosed quotation mark after the character string ') WITH NO_INFOMSGS, ALL_ERRORMSGS, DATA_PURITY'. Outcome: Failed Duration: 00:00:00 Date and time: 2022-01-07 09:36:16

olahallengren commented 2 days ago

This issue has been fixed. Thank you for reporting it.