My general approach is:
1. If it is a coding problem, I try to come up with my own way so as not to just copy what someone else has done. I have found that makes me learn more about the problem and the different solutions. If I still can't figure it out, then I do some research.
2. If it is an emergency or bug, I first Google or otherwise research the issue, so that I err on the side of safety, i.e., not going down blind alleys that might waste time or make things worse.
In either case, I always compile the sources that helped me and reference them in the code that I change, to give proper credit.
"I love spending twice as long and working twice as hard to get half as much done!" – Nobody ever.
"Operator! Give me the number for 911!" - Homer Simpson
"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'"