LiteSpeed using sp_MSforeachdb, get error "is too long. Maximum length is 128"
说明
Error displayed in Job History and/or Query Analyzer output when using LiteSpeed extended store procedures with the Microsoft xp_MSforeachdb procedure:
"[litespeed command] is too long. Maximum length is 128."
原因
The commands parsing into sp_MSforeachdb, allow up to 2000 characters. However, if QUOTED_IDENTIFIER is set on, it is restricted to 128 characters when surrounded with "double-quotes"
解决办法
In order to parse commands longer than 128 characters: 1) quote with single-quote only.
--OR--
2) Turn the QUOTED_IDENTIFIER off:
SET QUOTED_IDENTIFIER OFF
Example: Correct: SET QUOTED_IDENTIFIER OFF EXEC sp_MSforeachdb @command1="select grantee, grantee, grantee, grantee, grantee, grantee, grantee, grantee, grantee, grantee, grantee from ?.dbo.syspermissions"
Incorrect: SET QUOTED_IDENTIFIER ON EXEC sp_MSforeachdb @command1="select grantee, grantee, grantee, grantee, grantee, grantee, grantee, grantee, grantee, grantee, grantee from ?.dbo.syspermissions"
Refer to Microsoft Article SET QUOTED_IDENTIFIER, for more details on setting on and off the QUOTED_IDENTIFIER: http://msdn.microsoft.com/library/en-us/tsqlref/ts_set-set_9jxu.asp?frame=true