Usually, it's a typical problem we will face while executing the Dynamic SQL the length of the string is really huge when compared to the max length of the string. To overcome this major issue. Here is a small alternative. We can have part of the execution string in one variable and remaining part in the other string.
A small example
![11a.png]()
find columns having index?
sp_helpindex tblUserDetails
![11b.png]()
sp_help tblUserDetails
![11c.png]()
EXEC sp_msforeachtable @command1= "PRINT '?'
EXEC sp_helpindex @objname = '?'"
![11d.png]()
![11e.png]()