Answer Posted / vijayalakshmi u
Create Table emp
(
dbID int NOT NULL IDENTITY (1,1) PRIMARY KEY,
customerNumber NVARCHAR(100) auto_increment,
Name Varchar(100)
)
Create function CustomerNumber (@id int)
returns varchar(10)
as
begin
DECLARE @ret varchar(10) ;
select @ret='gt' + right('0000' + convert(varchar(10), @id), 4)
RETURN @ret
end
create trigger emp_insert on emp
after insert as
update emp
set
emp.customerNumber = dbo.CustomerNumber(emp.dbID)
from
emp inner join
inserted on emp.dbID= inserted.dbID
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Explain cdc and sql injection?
Which is better statement or preparedstatement?
How do you use a subquery to find records that exist in one table and do not exist in another?
Call by value and call by reference in procedure and function, with NOCOPY.
What is the difference between system objects and user objects?
What do you mean by recursive stored procedure?
How to make a column nullable?
Can group by be used without aggregate functions?
What is multi-statement table-value user-defined function?
What is ddl and dml commands?
What is the difference between ‘having’ clause and a ‘where’ clause?
What happens if ntwdblib.dll is missing on your machine?
Do you know what is openxml in sql server?
What is the web service used for reporting services?
How can you tell if a database object is invalid?