October 22, 2007 at 6:01 pm
October 22, 2007 at 6:27 pm
October 22, 2007 at 9:13 pm
It's easier than that... lookup STUFF in Books Online...
--Jeff Moden
Change is inevitable... Change for the better is not.
October 24, 2007 at 10:04 am
Jeff Moden (10/22/2007)
It's easier than that... lookup STUFF in Books Online...
Cool! I hadn't encountered that function before. Thanks Jeff.
October 24, 2007 at 7:13 pm
You bet... thanks for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 26, 2007 at 10:16 am
Jeff Moden (10/22/2007)
It's easier than that... lookup STUFF in Books Online...
I was curious how you would do this with the STUFF function. I tried testing it with the following:
SELECT STUFF('123456', 2, 1, '-') = 1-3456
SELECT STUFF(1289356, 2, 1, '-') = 1-89356
But, STUFF deletes the characters and replaces it with the new characters. Wouldn't I have to use a SUBSTRING anyway to maintain the same characters and just add the hyphen? As follows:
SELECT STUFF('123456', 1, 1, SUBSTRING('123456',1,1) + '-') = 1-23456
SELECT STUFF('1289356', 1, 1, SUBSTRING('1289356',1,1) + '-') = 1-289356
I may be missing something here though, if you can help me understand the easier way that would be great. Thanks.
October 26, 2007 at 10:23 am
John Dempsey (10/26/2007)
I was curious how you would do this with the STUFF function. I tried testing it with the following:
SELECT STUFF('123456', 2, 1, '-') = 1-3456
SELECT STUFF(1289356, 2, 1, '-') = 1-89356
But, STUFF deletes the characters and replaces it with the new characters. Wouldn't I have to use a SUBSTRING anyway to maintain the same characters and just add the hyphen? As follows:
SELECT STUFF('123456', 1, 1, SUBSTRING('123456',1,1) + '-') = 1-23456
SELECT STUFF('1289356', 1, 1, SUBSTRING('1289356',1,1) + '-') = 1-289356
I may be missing something here though, if you can help me understand the easier way that would be great. Thanks.
SELECT STUFF('123456', 2, 0, '-') = 1-23456
SELECT STUFF(1289356, 2, 0, '-') = 1-289356
October 26, 2007 at 11:47 am
Nice! It is amazing what a 0 can do. Thanks for the quick response.
October 26, 2007 at 12:02 pm
You're welcome.
Julie
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply