Answer Posted / dipak patil
Create Table emp
(
dbID int NOT NULL IDENTITY (1,1) PRIMARY KEY,
customerNumber NVARCHAR(100) ,
Name Varchar(100)
)
GO
----------------------------------------
Create Proc Usp_InsertRecord
@EmpName Varchar(10)
As
BEGIN
Declare @MAXValue Varchar(Max),@intValue Integer
SET @MAXValue='0'
SELECT TOP 1 @MAXValue=ISNULL(customerNumber,0) From emp Order by dbID DESC
Set @intValue=Convert(Integer,Replace(@MAXValue,'Gt',''))+1
SET @MAXValue='GT' + right('0000' + convert(varchar(10), @intValue), 4)
Insert Into Emp(customerNumber,Name) Values(@MAXValue,@EmpName)
END
----------------------------------------
-- Exec Usp_InsertRecord 'RAM'
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How extra digits are handled with numeric data type literals?
What are advantages of ssrs or why we should use ssrs?
What is the difference between row_number and dense_rank?
What are various limitations of the views?
What is the purpose of the model database?
What is a data source or ds? : sql server analysis services, ssas
How to search for a string in all stored procedure in sql server?
How to recreate an existing index in ms sql server?
You want to implement the one-to-many relationship while designing tables. How would you do it?
What is the purpose of the tempdb database?
What is use of except clause?
How to define output parameters in stored procedures?
What is Service Broker in sql server 2012?
What is Federation and Federation Member?
How to generate create view script on an existing view?