Reputation:
In SQL Server 2005, I want to print out a blank line with the PRINT statement, however, when I run
PRINT ''
it actually prints a line with a single space.
Does anyone know if it's possible to just print a blank line without the space?
If I print a new line character, it doesn't print a space, but I end up with two new lines.
Upvotes: 6
Views: 18521
Reputation:
-- Search the web for: SQL PRINT NewLine
-- What you'll end up finding:
DECLARE @CR AS CHAR(1) -- Carriage Return (CR)
DECLARE @LF AS CHAR(1) -- Line Feed (LF)
DECLARE @CrLf AS CHAR(2) -- Carriage Return / Line Feed
SET @CR = CHAR(10)
SET @LF = CHAR(13)
SET @CrLf = @CR + @LF
PRINT '--==--==--==--==--=='
PRINT @CrLf + 'Use variables as you see fit' + @CrLf
PRINT '--==--==--==--==--=='
-- AntGut
Upvotes: 4
Reputation: 2426
Very similar to the other suggestion here, this seems to work:
print '
'
Upvotes: 5
Reputation:
This suggests that you want to print a blank message. Are you sure that this is your intention? The Print statement actually sends a message to the error/message-handling mechanism that then transfers it to the calling application.
Upvotes: 0
Reputation: 45761
Can you encode the BACKSPACE character and PRINT that out?
UPDATE: PRINT '' + CHAR(8) doesn't seem to go down particularly well :(
Upvotes: 1
Reputation: 1992
You could just add a newline on your previous print statement, if you have one.
Instead of:
PRINT 'BLABLABLA'
PRINT ''
You could write:
PRINT 'BLABLABLA
' <- the string finishes here!
Upvotes: 8
Reputation: 63126
AFAIK there is no way around this, it is the way the print statement works
Upvotes: 0