All the data I feed my DB with is UPPERCASE. I need to convert this to Proper case but here's the trick
I'm in Quebec, Canada and some cities have names like "Saint-Anne-de-Bellevue". My question is, would it be better to use vba code for this or SQL could do it?
I have tried SQL and it doesn't simply do what I need
1-SELECT TLowerCase.Numéro,
2-UCase$(Left$([N],1))+Mid$([N],2) AS LastName,
3-IIf(InStr(1,[P],"-",1)<>0,
4- (UCase(Left([P],1))
5- +Mid([P],2,(InStr(1,[P],"-",1)-1))
6- +(IIf(InStr(InStr(1,[P],"-",1),[P],"-",1)<>0,
7- UCase(Mid([P],(InStr(1,[P],"-",1)+1),1))
8- +Mid([P],(InStr(1,[P],"-",1)+2),(InStr(InStr(1,[P],"-",1),[P],"-",1))+3)
9- +(IIf(InStr(InStr(1,[P],"-",1),[P],"-",1)<>0,
10- "There's more",
11- UCase(Mid([P],(InStr(1,[P],"-",1)+1),1))+Mid([P],(InStr(1,[P],"-",1)+2))))))),
12- UCase(Left([P],1))+Mid([P],2)) AS Name
13-FROM TLowerCase;
The output of this example is --> "Jean-François-There's more" if the value in the table is "Jean-François-Pierre"
Of course, the output sould be "Jean-François-Pierre". Somehow, the second "InStr" as the length in my mid fonction (line 8) doesn't return the intended value so I have to add 3 so it works for this example particularly.
The next step after that will be when you input --> "SAINT-ANNE-DE-BELLEVUE" to somehow figure out a way of having the output be "Saint-Anne-de-Bellevue"
The weirdest looking city name I saw is 7 word long with dash, so it would have to work for this name also.
I hope it will challenge some of you...
Thanks in advance
J-F
I'm in Quebec, Canada and some cities have names like "Saint-Anne-de-Bellevue". My question is, would it be better to use vba code for this or SQL could do it?
I have tried SQL and it doesn't simply do what I need
1-SELECT TLowerCase.Numéro,
2-UCase$(Left$([N],1))+Mid$([N],2) AS LastName,
3-IIf(InStr(1,[P],"-",1)<>0,
4- (UCase(Left([P],1))
5- +Mid([P],2,(InStr(1,[P],"-",1)-1))
6- +(IIf(InStr(InStr(1,[P],"-",1),[P],"-",1)<>0,
7- UCase(Mid([P],(InStr(1,[P],"-",1)+1),1))
8- +Mid([P],(InStr(1,[P],"-",1)+2),(InStr(InStr(1,[P],"-",1),[P],"-",1))+3)
9- +(IIf(InStr(InStr(1,[P],"-",1),[P],"-",1)<>0,
10- "There's more",
11- UCase(Mid([P],(InStr(1,[P],"-",1)+1),1))+Mid([P],(InStr(1,[P],"-",1)+2))))))),
12- UCase(Left([P],1))+Mid([P],2)) AS Name
13-FROM TLowerCase;
The output of this example is --> "Jean-François-There's more" if the value in the table is "Jean-François-Pierre"
Of course, the output sould be "Jean-François-Pierre". Somehow, the second "InStr" as the length in my mid fonction (line 8) doesn't return the intended value so I have to add 3 so it works for this example particularly.
The next step after that will be when you input --> "SAINT-ANNE-DE-BELLEVUE" to somehow figure out a way of having the output be "Saint-Anne-de-Bellevue"
The weirdest looking city name I saw is 7 word long with dash, so it would have to work for this name also.
I hope it will challenge some of you...
Thanks in advance
J-F