Re: right padding equivalent



you can also surround it with <pre> tags

save this in a file and open it up in a browser, you will see that the
spaces are preserved
<pre> b b </pre>

Denis the SQL Menace
http://sqlservercode.blogspot.com/

lossed wrote:
Tks Mike,

Do you know what would be the query syntax that will concatenate the
first_name field with the required number of no breaking spaces?

Mike C# wrote:
HTML strips extra whitespace out when rendering. Maybe appending a bunch of
"&nbsp;" non-breaking spaces to the end would resolve your display issue?

"lossed" <hundyhunter@xxxxxxxxx> wrote in message
news:1151445410.988182.165360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi everyone,

Please excuse me if this has been asked before or sounds a bit dim.
This is a question asked on another forum but the solutions being
offered are focussing on programming rather than letting the DB server
do the work, which I'm not sure is the most efficient solution.
However, my confession is I dont use SQL server so can't help them
directly with the syntax. Hopefully you can help me help them and learn
a little about SQL Server in the process.

Trying to right pad a first name field so the padded string is a total
of 30 chars. It will be output concatenated with the last name field,
and each field separated with a "|". So that when output it reads
something like:

fname | mylastname


Syntax given was:

select id,
substring((last_name+','+rtrim(' '+isnull(level,'))+'
'+rtrim(isnull(first_name,'))+space(30)),1,30)+ ' | ' as student_name
from student

Issue: It appears this is padding correctly but the spaces are not
rendering in the browser. (I have no way to check this as I don't use
sqlserver. However, I can understand that multiple spaces are not going
to render in the client browser, if indeed the query is padding with
spaces.

Question: Instead of using space(), can replicate() be used and a
unicode space representation rather than an actual space be used? Or,
is there a better way that will ensure
the padding shows in browser?
I guess a fixed width font would also need to be used otherwise the
30-char blocks could wind up being different widths, which would defeat
the purpose.

If there is something I've missed, or you have any suggestions, I'm
keen to learn.

TYhanks in advance,

Lossed


.



Relevant Pages

  • right padding equivalent
    ... my confession is I dont use SQL server so can't help them ... It appears this is padding correctly but the spaces are not ... rendering in the browser. ...
    (comp.databases.ms-sqlserver)
  • RE: MS to stop allowing passwords in URLs
    ... released yesterday, MS04-040. ... This is also the first time they broke their ... now yields an "invalid syntax error". ... Click the applet and it opens a browser window with the ...
    (Bugtraq)
  • Re: FAQ Update 9.85 Dated 2007-08-31
    ... It results in implementations that branch, add a branch for each browser added to the 'supported' set, and fail to handle any browser encountered that are not known to the programmer. ... So JavaScripthas a syntax extension that recognises that a trailing comma in an object literal is not problematic and can be disregarded as a correctable mistake. ... It is unlikely that they would use that knowledge to declare for-in loops "broken" or attribute any consequences to "a faulty implementation of DontEnum. ...
    (comp.lang.javascript)
  • Re: MS to stop allowing passwords in URLs
    ... instance of IE as a browser object and use that format to login to a web site. ... >I personally use this syntax in only one production application, ... >relatively safe given the convenience it provides. ... Network Engineer ...
    (Bugtraq)
  • Re: right padding equivalent
    ... HTML strips extra whitespace out when rendering. ... my confession is I dont use SQL server so can't help them ... It appears this is padding correctly but the spaces are not ... rendering in the browser. ...
    (comp.databases.ms-sqlserver)