October 22, 2011 at 7:24 am
begin
declare @tempian int;
SELECT top 1 ID, secondaryemailaddress,
ltrim(rtrim(SUBSTRING(secondaryemailaddress,3,3))) as '@tempian'
--CAST ((select top 1 ltrim(rtrim(SUBSTRING(secondaryemailaddress,3,3))) from Profiles) as int) as @tempian
FROM profiles
where secondaryemailaddress like '%years%'
end
begin
update Profiles
set Experience = @tempian
--CAST (select top 1 ltrim(rtrim(SUBSTRING(secondaryemailaddress,3,3))) from Profiles where secondaryemailaddress like '%years%' as int
where secondaryemailaddress like '%years%'
end
October 22, 2011 at 10:23 am
What exactly are you trying to do?
If there's a conversion error you might use a different data type than int for @tempian.
Other than that it looks like there's a general syntax issue:
you can't use
CAST ((select top 1 ltrim(rtrim(SUBSTRING(secondaryemailaddress,3,3))) from Profiles) as int) as @tempian
Instead, use
SELECT @tempian = CAST ((select top 1 ltrim(rtrim(SUBSTRING(secondaryemailaddress,3,3))) from Profiles) as int)
October 22, 2011 at 10:28 am
Yes... it simply means that you're selecting data for conversion that cannot be converted. Put another way, you're selecting data for conversion that doesn't look like an INT value.
Please see the following article for how to detect and filter such values...
http://www.sqlservercentral.com/articles/IsNumeric/71512/
--Jeff Moden
Change is inevitable... Change for the better is not.
October 22, 2011 at 1:11 pm
": 8 years" This is the data in my generic field secondaryemail address - nvarchar(100)
I want to pull out the number and update the Experience column, whch is an integer.
I managed to get it working in SSIS but it takes 20 seconds to process one record!
Based on the actual execution plan, the time is being used up by updating the index. How can i leave the index update until after i have processed ALL my 4 Million records?
Is my best option to delete the index and rebuild after i have done my updates?
Regex reg = new Regex(@"(?<=Total years experience.*?)\b\S{1,}\b(?=.*?Job Categories)"); This is my original Regex code, which extracted # of years and the word years into 2 seperate columns, and i had no update issues, but it was slow!
100k records in 2 hours!
Regex reg = new Regex(@"(?<=Total years experience)\b.*\b(?=Job Categories)"); This is my current Regex code, which is MUCH faster, 100k records in 3 minutes but places the data in the following format ": 8 years" so i must parse out the full colon, spaces, and the word years, then convert to integer.
Both partially work, but are not quite what i want!
I have attached the execution plan from my SQL code.
October 22, 2011 at 2:55 pm
Fixed 🙂
Thanks for the assistance!
October 23, 2011 at 9:09 am
Cool! Two way street here, though... please tell us what you did to fix it?
Also, where did all that Regex stuff come from? It wasn't in your original post.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 26, 2011 at 5:23 pm
The trim was not working because the first character was a tab.
select ASCII(substring(IanVarchar,1,1)) from profiles
Once i determined the trim was not working, i substringed the values i needed and the conversion worked fine 🙂
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply