Feb 19, 2009 #1 bmacbmac IS-IT--Management Joined Jan 26, 2006 Messages 392 Location US Hi I have data in the following format: 1111x222 33x4444 222x1111 4444x33 Is there a script I can run to remove all data to the left of the x? Sometimes I might have to remove to the right of the x too. Thanks! Brian
Hi I have data in the following format: 1111x222 33x4444 222x1111 4444x33 Is there a script I can run to remove all data to the left of the x? Sometimes I might have to remove to the right of the x too. Thanks! Brian
Feb 19, 2009 #2 gmmastros Programmer Joined Feb 15, 2005 Messages 14,912 Location US Take a look here. http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/extracting-numbers-with-sql-server It's not exactly what you are looking for, but everything you need is explained. -George "The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom Upvote 0 Downvote
Take a look here. http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/extracting-numbers-with-sql-server It's not exactly what you are looking for, but everything you need is explained. -George "The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
Feb 19, 2009 #3 jdemmi MIS Joined Jun 6, 2001 Messages 1,106 Location US left of the x select substr('table.field',1,instr('table.field','x',1)-1) from table right of the x select substr('table.field',instr('table.field','x',1)+1,length('table.field')) from table -- Jason "It's Just Ones and Zeros Upvote 0 Downvote
left of the x select substr('table.field',1,instr('table.field','x',1)-1) from table right of the x select substr('table.field',instr('table.field','x',1)+1,length('table.field')) from table -- Jason "It's Just Ones and Zeros
Feb 19, 2009 Thread starter #4 bmacbmac IS-IT--Management Joined Jan 26, 2006 Messages 392 Location US That's what I'm talking about. I am using SQL 2000 so I had to make a few adjustments: For Left: Code: select substring (table.field,1,charindex('x', table.field,1)-1) from table For Right: Code: select substring(table.field,charindex('x', table.field,1)+1,len(table.field)) from table So far it looks good. Upvote 0 Downvote
That's what I'm talking about. I am using SQL 2000 so I had to make a few adjustments: For Left: Code: select substring (table.field,1,charindex('x', table.field,1)-1) from table For Right: Code: select substring(table.field,charindex('x', table.field,1)+1,len(table.field)) from table So far it looks good.