July 23, 2014 at 9:57 am
I was trying to see if there is any documentation regarding the backslash symbol "\" as a escape or continuation character and have not found anything yet.
Here is an example:
DECLARE @Statement varchar(MAX), @Statement1 varchar(MAX);
SET @Statement = 'SELECT top 10 * from dbo.MyTable -- This is a test \
WHERE MyValue is not null';
SET @Statement1 = 'SELECT top 10 * from dbo.MyTable -- This is a test
WHERE MyValue is not null';
PRINT @Statement;
PRINT @Statement1;
The results:
SELECT top 10 * from dbo.MyTable -- This is a test WHERE MyValue is not null
SELECT top 10 * from dbo.MyTable -- This is a test
WHERE MyValue is not null
You can imagine my surprise then this type of statement was "executed", i.e.,
EXEC (@Statement);
EXEC (@Statement1);
I can only assume that I "fat fingered" the \ symbol when trying to hit the ENTER button... while this is a simple example, my actual code was 2000 lines long.
Has anyone seen this before? Any documentation out there?
Thanks! 🙂
Argue for your limitations, and sure enough they're yours (Richard Bach, Illusions)
July 24, 2014 at 4:51 am
http://msdn.microsoft.com/en-us/library/dd207007(v=sql.105).aspx
If you have BOL installed, just lookup '\' in the index.
July 24, 2014 at 5:07 am
I had never trippeed over this before either; it's good to know.
Lowell
July 24, 2014 at 5:56 am
Peter Brinkhaus (7/24/2014)
http://msdn.microsoft.com/en-us/library/dd207007(v=sql.105).aspxIf you have BOL installed, just lookup '\' in the index.
Peter, thanks for the link. Honestly, this is one case I never would have thought about checking BOL (and I was in BOL twice yesterday)... I figured it was a bug or some weird anomaly! LOL
Argue for your limitations, and sure enough they're yours (Richard Bach, Illusions)
July 24, 2014 at 5:59 am
According to the 2014 documentation (http://msdn.microsoft.com/en-us/library/dd207007.aspx) this feature was added in SQL 2008. I didn't know of this feature either.
July 24, 2014 at 10:17 am
add me to the 'newly' informed list as well !
(I guess Microsoft took the hint from Unix kind of like the 'more' command)
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply