右边填充等价物 [英] right padding equivalent

查看:88
本文介绍了右边填充等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


如果之前有人询问或听起来有些暗淡,请原谅。

这是另一个论坛上提出的问题,但是提供的解决方案是专注于编程,而不是让数据库服务器完成工作,我不确定这是最有效的解决方案。

然而,我的忏悔是我不使用SQL服务器所以不能直接用语法帮助他们

。希望你能帮助我帮助他们并在这个过程中学习很多关于SQL Server的信息。


尝试右键填充名字字段,以便填充字符串为总共

的30个字符。它将输出与姓氏字段连接,

,每个字段用|分隔。因此,当输出时它会读取

类似于:


fname | mylastname

给出的语法是:


select id,

substring((last_name +'',''+ rtrim('' ''+ isnull(level,''))+''

''+ rtrim(isnull(first_name,''))+ space(30)),1,30)+''| ''作为student_name

来自学生


问题:看来这是填充正确但空格不是

渲染中浏览器。 (我无法检查这个,因为我不使用

sqlserver。但是,我可以理解多个空格不会在客户端浏览器中呈现
,如果查询确实填充了

空格。


问题:可以使用复制()而不是使用空格() >
unicode空间表示而不是实际使用的空间?或者,

是否有更好的方法可以确保填充在浏览器中显示为
?br />
我猜一个固定宽度的字体也需要使用,否则

30-char块可能会变成不同的宽度,这会打败

目的。


如果有什么我错过了,或者你有任何建议,我很乐意学习b $ b。


TYhanks提前,

失利

解决方案

lossed写道:

问题:看来这是paddin g正确但空格不在浏览器中呈现。 (我无法检查这个,因为我不使用
sqlserver。但是,我可以理解多个空格不会在客户端浏览器中呈现,如果确实查询是填充的
空格。




您可以使用浏览器查看来源。然后突出显示文本以查看

是否有空格或没有。


是但是查看内容?

我不使用sql server所以不能构建查询输出到

浏览器。

对不起,如果我说不够清楚。

Bucky写道:

lossed写道:

问题:看起来这是正确的填充,但空间不是在浏览器中渲染。(我无法检查这个,因为我不使用
sqlserver。但是,我可以理解多个空格不会在客户端浏览器中呈现,如果查询确实填充了
空格。

您可以使用浏览器查看源代码。然后突出显示文本以查看
是否存在空格。




HTML在渲染时会删除额外的空格。也许附上一堆

"& nbsp;"到最后的不间断空格会解决您的显示问题吗?


lossed <胡********* @ gmail.com>在消息中写道

news:11 ********************** @ x69g2000cwx.googlegr oups.com ...

大家好,

如果之前有人问过这个问题或者听起来有点暗淡,请原谅。
这是另一个论坛上提出的问题,但解决方案是
提供的是专注于编程而不是让数据库服务器完成工作,我不确定这是最有效的解决方案。
然而,我的忏悔是我不使用SQL服务器所以可以''用语法直接帮助他们。希望你可以帮助我帮助他们,并在此过程中学习一些关于SQL Server的内容。

尝试正确填充名字字段,以便填充字符串总数为
30个字符。它将与姓氏字段串联输出,
和每个字段用|分隔。所以在输出时它会读取如下内容:

fname | mylastname

给出的语法是:

select id,
substring((last_name +'',''+ rtrim(''''+ isnull(level,' '))+''
''+ rtrim(isnull(first_name,''))+ space(30)),1,30)+''| ''作为student_name
来自学生

问题:看起来这是填充正确但空间不是在浏览器中呈现。 (我无法检查这个,因为我不使用
sqlserver。但是,我可以理解多个空格不会在客户端浏览器中呈现,如果确实查询是填充的

问题:不是使用space(),而是可以使用replicate()并使用
unicode空间表示而不是实际空间?或者,我想还需要使用固定宽度的字体,否则
30-char块可能会结束不同的宽度,这会打败目的。

如果有什么我错过了,或者你有任何建议,我很热衷于学习。

TYhanks提前,

失去



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

解决方案

lossed wrote:

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.



You can view source with the browser. Then highlight the text to see
whether the spaces are there or not.


Yes but view what?
I do not use sql server so can''t build the query to output to the
browser.
Sorry if I did not make that clear enough.
Bucky wrote:

lossed wrote:

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.



You can view source with the browser. Then highlight the text to see
whether the spaces are there or not.




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" <hu*********@gmail.com> wrote in message
news:11**********************@x69g2000cwx.googlegr oups.com...

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



这篇关于右边填充等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆