Today’s post is actually a quick tip about something I learnt over the week-end. We may often have a long line of text that needs to be embedded into our T-SQL code for inserting static data. Depending upon the IDE settings on the client workstation, the long line of text would either automatically wrap-around to a new line or continue in a single line forever, affecting the readability of the entire T-SQL query.
The easiest way to split a long line of text into multiple lines for readability purposes is to use the back-slash character as shown in the script below:
USE tempdb;
GO
DECLARE @stringOperationsTest TABLE (strVale VARCHAR(100));INSERT INTO @stringOperationsTest (strVale)
VALUES
(‘Microsoft SQL Server’);SELECT strVale
FROM @stringOperationsTest;
GO/**********************
RESULTS
**********************/
/*
strVale
———————
Microsoft SQL Server
*/
Until we meet next time,