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 the sql case statement used for? Explain with an example?
Are semicolons required at the end of sql statements in sql server 2005?
What is @@rowcount in sql?
Do you know the different ddl commands in sql?
What is logon trigger?
How many types of cursor type are there?
What is the meaning of sql server?
What do you think of this implementation? Can this be implemented better?
Does sql server 2000 clustering support load balancing?
What is normalization and what are the advantages of it?
What are locks in sql?
List layers of abstraction microsoft architectured to provide relational db through cloud platform ?
What is the purpose of optimization?
Define compound operators?
A trigger can reference objects outside the current database? State true or false.