Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 INSERT statement

Author  Topic 

CM670
Starting Member

2 Posts

Posted - 2012-10-19 : 05:39:18
I have a table which holds the status of peoples orders. It holds information on order_id, order_status, order_desc, letter.

A letter is printed for each of the different statuses. However for one status i need two different letters to be printed.

So far i have done
insert into order_status (order_id,order_status,
order_desc, letter) values('025', 'Dispatched', 'Black tailored coat ','DPT notification');

This prints the DPT notification fine but i need another letter to print along with this. How can I insert two values into the same field?

It would be helpful if anyone has any ideas on how to do this!
Thanks.

NeilG
Aged Yak Warrior

530 Posts

Posted - 2012-10-19 : 05:53:34
you could try an if statement, for example see below, not near a machine but something alone these lines,

Or an insert trigger to insert the additional lines based on what's being inserted

DECLARE @Orderstatus INT

SET @Orderstatus = 2


if @Orderstatus = 1
BEGIN

INSERT INTO order_status (order_id,order_status, order_desc, letter) VALUES('025', 'Dispatched', 'Black tailored coat ','DPT notification');

END

ELSE IF @Orderstatus = 2

BEGIN

---first row
INSERT INTO order_status (order_id,order_status, order_desc, letter) VALUES('025', 'Dispatched', 'Black tailored coat ','DPT notification');

---second row
INSERT INTO order_status (order_id,order_status, order_desc, letter) VALUES('065', 'get', 'sdf ','fdfd');

END
Go to Top of Page
   

- Advertisement -