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
What is user-defined scalar function?
Determine how to use the inserted and deleted pseudo tables?
What are the basic functions for master, msdb, model, tempdb databases?
what is a correlated sub-query? : Sql server database administration
Define normalisation?
Explain what is the use of custom fields in report?
How to create a new login name in ms sql server?
Write the syntax for stuff function in an sql server?
What is the simplest way to create a new database in ms sql server?
How to deploy the Report?
what are the basic functions for master, msdb, model, tempdb and resource system databases? : sql server database administration
What is buffer cash in sql server?
What is tcl in sql server?
What is a result set object returned by odbc_exec()?
What are the triggers in sql?