January 22, 2013 at 9:43 am
Hello
I need to to display blank value for 81 character length column.
means
for that column, I need blank and field length will be 81 char long.
I try select left('',81)
but it allows only the field not more then 81 char but i need the blank value that will be 81 char long.
Please help me
Thanks
January 22, 2013 at 9:46 am
SELECT SPACE(81)
or
SELECT CONVERT(CHAR(81),'')
if you are using a column, and you need to guarantee it's 81 spaces, it's similar:
SELECT CONVERT(CHAR(81),YourColumnName)
will both give you strings you are looking for...
THE LEN() property always returns the trimmed length, but the DATALENGTH() property will include spaces.
Lowell
January 22, 2013 at 9:49 am
Just for fun here is another way.
select replicate(' ', 81)
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply