Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
collie
Constraint Violating Yak Guru
400 Posts |
Posted - 2006-10-26 : 11:04:07
|
Hello,I have a sql server 2005 database with a table that has a field called MedNames. The field has values such as:sodium 6% medDEXTROSE 5% 150 MLI need to return the values before the % including the %. How can i do that?Thanks |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-26 : 11:08:04
|
Select Substring(1,charindex('%',Mednames,1)) from tableMadhivananFailing to plan is Planning to fail |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-10-26 : 11:09:56
|
[code]declare @test table (medname varchar(100))insert @testselect 'sodium 6% med' union allselect 'DEXTROSE 5% 150 ML'select left(medname, charindex('%', medname)) from @test[/code]Peter LarssonHelsingborg, Sweden |
 |
|
samuelclay
Yak Posting Veteran
71 Posts |
Posted - 2006-10-26 : 12:42:27
|
interesting... I read it to mean the : 6% and 5%... |
 |
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-10-26 : 14:18:26
|
You should redesign your model so you don't violate Codd's Information RuleJay White |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|