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.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 How to Split the string

Author  Topic 

R.Prabu
Starting Member

33 Posts

Posted - 2008-06-04 : 09:52:40
I am having City, State i need to split these two string with comma separated and to search based on the city and state how to write the select query

any one know help me

Regards,
Prabu R

Sep410
Posting Yak Master

117 Posts

Posted - 2008-06-04 : 17:55:54
Declare @ST as varchar(20)
Declare @City as varchar(20)
Declare @State as varchar(20)
Declare @i as int
Set @ST='Saskatoon,SK'
set @i =Patindex('%,%',@st)

set @City=left(@ST,@i-1)
set @State=Substring(@ST,@i+1,Len(@ST))
Select @City,@State

Does this help you?
Go to Top of Page
   

- Advertisement -