SQL 兩列字段,合併爲一個字符串,中間加符號

轉載地址:http://blog.sina.com.cn/s/blog_4bce1a290100g79f.html

數值型:
select cast(a as varchar(10))+'--'+cast(b as varchar(10)) from tablename
字符型:
select a+'--'+b from tablename
---------------------------------------------------------------

---------------------------------------------------------------

字符型:
varchar
select a+'--'+b from tablename
char
select rtrim(a)+'--'+rtrim(b) from tablename

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章