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 implicit cursors?
What is key set driven?
Is oracle faster than sql server?
As a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this?
What is difference between cte and view?
Explain database normalization?
List the types of recovery model available in sql server?
What is multi-statement table-value user-defined function?
What are the differences between substr and charindex in sql server.
What does normalization do to data?
What is index, cluster index and nonclustered index?
What is difference between inner join and full join?
How to check parameter value in stored procedure sql server?
What is meant by referential integrity?
Do you know how to implement service broker?