How to make select Dense Rank over max of TechnologyId Based on FeatureString For new Inserted Data?

ahmed salah 3,126 Reputation points

I work on sql server 2017 i have table have dense rank over FeatureString and column store rank increment is technology id
as below

  create table #partsfeature  
 PartId int,  
 FeatureName varchar(300),  
 FeatureValue varchar(300),  
 FeatureString varchar(300),  
 TechnologyId int  
  insert into #partsfeature(PartId,FeatureName,FeatureValue,FeatureString,TechnologyId)  

Now max technology id on table part feature is 3

I need New Inserted data will be 4,5 for technology id

New Inserted Data as below


so how to make select query over Feature String for column Technology Id as 4,5 for New inserted Data

expected result i need is


SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
8,502 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ahmed salah 3,126 Reputation points

    I solved my issue

     DECLARE @MaxTechnologyID AS BIGINT =   
       ( SELECT MAX(TechnologyId)  
                                               FROM   #partsfeature  
            SELECT  *,CAST (DENSE_RANK() OVER ( ORDER BY FeatureString)  
                    + @MaxTechnologyID AS BIGINT) AS NewTechnologyId   
     from #partsfeature