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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-01-31 : 09:01:13
|
| Rajaraman S writes "Hi,I have a field in a table which contains strings in the form of AAQG.DE,AAQG.MU/AAQG.RE, DYKG_p.DE..like this. I want to extract the portion of the string upto dot. The length of the string upto the dot may vary, it is not fixed. The length after the dot also vary. So can I extract the portion of the string using an SQL query? If so, how? Any kind of help is great. Thanks in advance.RegardsRajaram" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-31 : 09:10:07
|
| declare @str varchar(100)set @str='AAQG.DE,AAQG.MU/AAQG.RE, DYKG_p.D'select substring(@str,1,charindex('.',@str,1)-1)set @str='AAQGDE,AAQG.MU/AAQG.RE, DYKG_p.D'select substring(@str,1,charindex('.',@str,1)-1)MadhivananFailing to plan is Planning to fail |
 |
|
|
Norwich
Posting Yak Master
158 Posts |
Posted - 2006-01-31 : 09:12:10
|
| [code]Declare @var varchar(50), @pos int, @newVar varchar(50)Set @var = 'AAQG.DE'Select @pos = charindex('.',@var)Select @newvar = left(@var,@pos - 1)Print @newVar[/code]RegardsNThe revolution won't be televised! |
 |
|
|
Norwich
Posting Yak Master
158 Posts |
Posted - 2006-01-31 : 09:14:04
|
| I guess Madhivanan beat me to it!NThe revolution won't be televised! |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-01-31 : 10:34:52
|
| Do you want to extract the other parts of the string too?Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-01 : 09:36:57
|
But we rarely get response from Temporary members MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|