March 14, 2012 at 1:45 am
Hello ,
In my database i have collegename column in that the format is as follow,
Rizvi Institute of Management Studies And Research, Mumbai - Management
G.H. Raisoni Institute of Engineering And Technology, Pune - Engineering
Centum Learning Limited, Pune - Engineering
i want to fetch the collegename before the dash(-)
Means collegename will remain as it is as i listed above but at fetching time it should display like "Centum Learning Limited, Pune "
i used charindex substring but it is not usefull 🙁
Thanks & Regards,
Pallavi
March 14, 2012 at 2:13 am
please take a moment to read the first link in my signature block on posting T-SQL
as this is fairly a small task i have knocked this up
create table #temp (col1 nvarchar(max))
insert into #temp (col1) values
('Rizvi Institute of Management Studies And Research, Mumbai - Management'),
('G.H. Raisoni Institute of Engineering And Technology, Pune - Engineering'),
('Centum Learning Limited, Pune - Engineering')
and this should do the trick
select LEFT(col1,CHARINDEX(' - ',col1)) from #temp
March 14, 2012 at 7:18 am
Yes i tried it before asking you this doubt but
it is returning collegename
Rizvi Institute of Management Studies And Research, Mumbai -
i don't want dash(-) also
Thanks & Regards,
Pallavi
March 14, 2012 at 7:19 am
did you try my script?
March 14, 2012 at 7:25 am
Yes i tried it
Thanks & Regards,
Pallavi
March 14, 2012 at 7:31 am
It's working 🙂 i forgot to give a front and back space
Thanks & Regards,
Pallavi
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply