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
ahmed elbarbary
NA
1.6k
275.3k
How to select data based dynamically based on start and end of Affecte
Oct 5 2020 7:49 PM
I work on SQL server 2012 I need to get data from #partsdata table where part number matches
Affected Product both start and End
as Example where I have Affected Product as
APAMS-***G
then I will get Parts That have start APAMS- and End by G
start must be end with dash (-)
this roles applied to another rows on search data table .
I get part number that have matched with start f affected product and end with same charachter of affectedproduct
create
table
#searchdata
(
Id
int
,
AffectedProduct nvarchar(50)
)
insert
into
#searchdata(Id,AffectedProduct)
values
(1,
'APAMS-***G'
),
(2,
'APg-***F'
),
(3,
'Dom-***D'
)
create
table
#PartsData
(
PartId
int
,
PartNumber nvarchar(50)
)
insert
into
#PartsData(PartId,PartNumber)
values
(233,
'APAMS-234G'
),
(501,
'APAMS-901G'
),
(909,
'APAMS-901G'
),
(700,
'APg-670F'
),
(550,
'APg-G3DF'
),
(940,
'APg-321F'
),
(702,
'Dom-670D'
),
(710,
'Dom-G3DD'
),
(770,
'APg-321L'
),
(915,
'APAMS-901M'
),
(922,
'APg-325N'
)
Expected Result
PartId PartNumber
233 APAMS-234G
501 APAMS-901G
909 APAMS-901G
700 APg-670F
550 APg-G3DF
940 APg-321F
702 Dom-670D
710 Dom-G3DD
so How to do that please ?
Reply
Answers (
3
)
Multiple row s one columns all values y then Y else N
I need query for three table with join