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 are cascading parameters in ssrs reports?
How to use "begin ... End" statement structures in ms sql server?
What is the purpose of data source?
List types of tables in SQL Azure?
How to retrieve error messages using mssql_get_last_message()?
What is difference between view and materialized view?
How much does sql server 2016 cost?
What are the benefits and tasks of object explorer? : sql server management studio
What are the extra roles available in msdb? : sql server security
Do you know sql server 2008 introduces automatic auditing?
What is the need for indexing?
What are the rules to use the rowguidcol property to define a globally unique identifier column?
What is store procedure? How do they work? When do you use?
What is table level trigger?
What is the difference between functions and scalar functions?