Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

how to add spaces to the column value to make it up specifi length string please

$
0
0

Hello There,

Could you please guide me here to solve this issue,

in my column (named as State) contains values as below

California

Washington

Utah

Connecticut

Massachusets

in the output how can i add a spaces to make up every column values as 15 length (for ex, Utah is 4 length then need to add 11 spaces, California is 10 would like to add 5 spaces)

i tried below but no use in Sql 2008 R2

SELECT  distinct state

,

   state

+SPACE(35-len(state)),


len(state+SPACE(35-len(state)))


FROM dbo.ordersInfo

Thank you in advance

Milan


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>