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 command would you use to add a column to a table in sql server?
Determine when to use stored procedure to complete sql server tasks?
What is buffer cash and log cache in sql server?
What should be the fill factor for indexes created on tables? : sql server database administration
Can you explain powershell included in sql server 2008?
What is dbcc?
What is the difference between seek predicate and predicate?
Can group by be used without aggregate functions?
How to access the inserted record of an event?
Do I need a report server to run reports in my application?
What is sql azure database?
What stored by the msdb? : sql server database administration
Tell me about the approaches which you used to counter the DI problems.
What is a derived table?
Which are the two editions in which SQL Azure database available?