Reputation: 12712
This is a bit above my level. But am trying to learn. I don't want to seem like I'm just trying to get my homework done but would appreciate any help pointers.
I am trying to find a substring (postcode) in an address column and once found, copy to the post code column I have the following sql which finds columns that match a postcode pattern.
SELECT Address
FROM tb_member
WHERE (Address LIKE '%[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]%')
Next I presume I need to find the substring index...
This is where I start to get a little flummoxed - Am I heading in the right direction?
Upvotes: 1
Views: 661
Reputation: 332661
So you know you want to SUBSTRING a value - look at what the function requires to make it work:
In SQL Server/TSQL, PATINDEX will be better for this situation than CHARINDEX to get that starting point of the substring.
I gather you know how long the substring will always be?
Upvotes: 2