SQL选择将文本组合到选定的项目?

时间:2013-08-30 09:11:39

标签: sql tsql select

您好我正在尝试从数据库中选择两个ID,第二个我希望将文本添加到结果中。

SELECT
   A.PractitionerId,
   'http://www.icuro.co.za/WebForms/Members/Appointments/AppointmentView.aspx?id=' + CAST(A.AppointmentId)
FROM
   Appointment AS A WITH (NOLOCK)

我将如何实现这一目标?

提前致谢。

1 个答案:

答案 0 :(得分:4)

你几乎就在那里,你需要告诉Cast投射什么:

SELECT
   A.PractitionerId,
   'http://www.icuro.co.za/WebForms/Members/Appointments/AppointmentView.aspx?id=' + CAST(A.AppointmentId as varchar(50))
FROM
   Appointment AS A WITH (NOLOCK)