ASP DOT NET

Saturday, June 9, 2018

Q.How to auto generate id with char and numeric?
Ans.

declare @Customer_No varchar(10)
set @Customer_No ='CU_'+cast((select ISNULL(max(cast(SUBSTRING(Customer_No ,4,6) as int)),0)+1 from Customer_Details) as varchar(10))

No comments:

Post a Comment

How to to select duplicate rows from sql server?

 SELECT * FROM Recruitment WHERE Email IN (SELECT Email FROM Recruitment GROUP BY Email HAVING COUNT(*) > 1); WITH CTE AS (     SELECT   ...