Showing posts with label urgent. Show all posts
Showing posts with label urgent. Show all posts

Sunday, March 25, 2012

Creating A Trigger

Hallo,
I am new on this forum but I have an urgent problem. How can I

1. Create a trigger which has the following characteristics:
It should be named reorder.
It should fire after an update of the qty column on the stock table, if the new
value of qty is <= 5.
New should be referenced as n.
The triggered action should insert the values n.itemno and current timestamp
into the reorder table,
whereby when an inventory item in the STOCK table falls below a quantity of 6, the REORDER table will have a row inserted.

Any kind of help is very much appreciated.

Quote:

Originally Posted by JKAG

Hallo,
I am new on this forum but I have an urgent problem. How can I

1. Create a trigger which has the following characteristics:
It should be named reorder.
It should fire after an update of the qty column on the stock table, if the new
value of qty is <= 5.
New should be referenced as n.
The triggered action should insert the values n.itemno and current timestamp
into the reorder table,
whereby when an inventory item in the STOCK table falls below a quantity of 6, the REORDER table will have a row inserted.

Any kind of help is very much appreciated.


hi jkag,

Check out the Trigger i have developed in sqlserver 2000.

sample tables used:
create table stock
(
itemid int identity(1,1) primary key,
prdname varchar(100),
qty int,
)

create table reorder
(
reoid int identity(1,1) primary key,
itemid int,
prdname varchar(100),
qty int,
currdate timestamp
)

create Trigger ReorderTrigg
on stock
for update
as
begin
insert into reorder(itemid,prdname,qty) select itemid,prdname,qty from stock where qty<=5
end
go

Go through the trigger and do let me know if it has solved ur query. If not also, pm me your problem. I shall try it. Gud Luck!

cheers,
jaisql

Wednesday, March 7, 2012

creating a duplicate table Urgent

Hi All,
I want to create duplicate of a table that is present in database with new name. How can i do it.
I am fogeting the syntax
is it
insert into newtablename from oldtable name
Regards
AdilSELECT * INTO NewTable FROM OldTable|||Remember that your new table will not have any indexes, triggers, constraints, etc that your original table had. It is a duplicate in content only.

blindman|||Originally posted by blindman
will not have any indexes, triggers, constraints, etc
blindman

What are those?|||Ask Sundial. He'll tell you that they aren't really necessary and you can generally ignore them.

blindman :cool:|||And even if you have them in your database, they are self maintaining ... no need to run dbcc's on the database ;)