sql-server-maintenance-solution icon indicating copy to clipboard operation
sql-server-maintenance-solution copied to clipboard

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

Open alexander-suprun opened this issue 5 years ago • 2 comments

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

alexander-suprun avatar Jan 05 '21 17:01 alexander-suprun

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

Could you post the complete output?

olahallengren avatar Dec 31 '21 16:12 olahallengren

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

alexander-suprun avatar Jan 07 '22 17:01 alexander-suprun