开发者

Enclose sql result in [

I have a query which will return a set of dates . I want to enclose these values inside '[]'.

My query is

   SELECT distinct  convert(varchar, track_empHours_date, 103)
          as track_empHours_date
    FROM tbl_track_empHours
    WHERE tbl_track_empHours.track_empHours_main_usr_id_fk = '268'
      AND track_empHours_date BETWEEN '5/09/2011' AND '5/15/2011'

Any help is apprecia开发者_运维知识库ted


You can also use QUOTENAME for this.

SELECT 
   DISTINCT QUOTENAME(CONVERT(VARCHAR, track_empHours_date, 103)) 
                                                      AS track_empHours_date  ...


SELECT distinct '[' + convert(varchar, track_empHours_date, 103) + ']'
      as track_empHours_date
FROM tbl_track_empHours
WHERE tbl_track_empHours.track_empHours_main_usr_id_fk = '268'
  AND track_empHours_date BETWEEN '5/09/2011' AND '5/15/2011'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜