Center-Align Text

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 246
Write below query,using the Space function we can do. The Space string function returns a string of repeated spaces.
DECLARE @Header1 VARCHAR(25) = 'Dotnet funda dot com'
DECLARE @Header2 VARCHAR(25) = '123456789'
DECLARE @Header3 VARCHAR(25) = 'abcdefgh'
PRINT SPACE((50 - LEN(@Header1))/2) + @Header1
PRINT SPACE((50 - LEN(@Header2))/2) + @Header2
PRINT SPACE((50 - LEN(@Header3))/2) + @Header3



Output
------------
Dotnet funda dot com
123456789
abcdefgh

Comments or Responses

Login to post response