TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kumar AU
1.4k
320
63k
Help Required on SQL search the the fields till space/-
Jun 28 2016 11:03 AM
Dear All,
Could you please help me with the below query :-
Create Table #Users1
(
UniQueNumber Varchar(50),
FName varchar (50),
LName Varchar (50),
Number varchar(10),
CreateDate Datetime
)
INSERT INTO #Users1 Values ('44354','Kumar','Shruthi-hh','11111','05-25-2016 00:10:000')
INSERT INTO #Users1 Values ('44254','Shankar','Raj','22222','05-25-2016 01:18:000')
INSERT INTO #Users1 Values ('34154','Babu','Swamy k','33333','05-25-2016 06:10:000')
INSERT INTO #Users1 Values ('35054','Mani','Kanta H','44444','06-25-2016 06:10:000')
I need My Result should be :- Here I am not understaning how to get the 'UniQueNumber' column values AS shows below
UniQueNumber Fname LName
44354-KShruthi Kumar Shruthi-hh
44254-SRaj Shankar Raj
34154-BSwamy Babu Swamy k
35054-MKanta Mani Kanta H
My Query :-
SELECT (UniQueNumber + '-' + SUBSTRING(FName,1,1) + CASE WHEN PATINDEX('%-%',LName) > 0 THEN SUBSTRING(LName,0,PATINDEX('%-%',LName)) ELSE LName END) as UniQueNumber
,FName
,LName
,Number
,CreateDate
FROM #Users2
Here I am not understanding how to manage the space as well in the above query
Reply
Answers (
4
)
Need Help on Sql Query - how to get the recently deleted rec
Help required on Complex Query in SQL