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 ?