April 8, 2009 at 1:22 pm
This:
select SUBSTRING(Field1,PATINDEX('%[^0]%',Field1),10)
FROM (
SELECT '05380101010000' AS Field1 UNION ALL
SELECT '05380101020000' UNION ALL
SELECT '05380101101000' UNION ALL
SELECT '05380011103000'
) TestData
does not return the result set you indicated you required.
April 8, 2009 at 1:30 pm
Mind readers we are not. If you needed the results of your query then that is what you should have told us up front instead of indicating that you wanted the values in positions 8 - 11 expect without the trailing 0. You would have gotten a better answer from the start.
Perhaps you should read my blog http://www.sqlservercentral.com/blogs/lynnpettis/archive/2009/04/05/dealing-with-difficult-forum-users-the-flip-side.aspx.
April 8, 2009 at 1:37 pm
Thanks for you help....I guess I was having trouble telling you guys what I really needed. I could see it in my mind but hard to convey in words. Sorry
April 8, 2009 at 1:46 pm
cm62597 (4/8/2009)
Thanks for you help....I guess I was having trouble telling you guys what I really needed. I could see it in my mind but hard to convey in words. Sorry
Okay, then why did you give this to us when I asked you to show what you wanted:
05380101010000
05380101020000
05380101101000
05380011103000
When it is obvious now that what you wanted was:
05380101010000
05380101020000
05380101101000
05380011103000
And, based on your sample data, this would work:
select SUBSTRING(Field1,2,10)
FROM (
SELECT '05380101010000' AS Field1 UNION ALL
SELECT '05380101020000' UNION ALL
SELECT '05380101101000' UNION ALL
SELECT '05380011103000'
) TestData
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply