-
tsql: how to concatenate 2#'s--not add?
trying to concatenate a varchar field containing numbers with the number 1. i tried casting to text and received an error. and if I simply use '1' + fieldname --sql adds the numbers together.
update phonebook_patient_rooms
set extension = cast('1' as text) + cast(extension as text)
--set extension = '1' + extension
where len(extension) < 5
and extension like '[0-9]%'
and extension = '4967'
-
cast to char instead of text. if the number is fixed width then use char(n) otherwise you need to RTRIM to remove blank space between two expressions.
update phonebook_patient_rooms
set extension = cast('1' as char) + cast(extension as char)
--set extension = '1' + extension
where len(extension) < 5
and extension like '[0-9]%'
and extension = '4967'
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|