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.
| Author |
Topic |
|
Rauken
Posting Yak Master
108 Posts |
Posted - 2005-08-31 : 17:54:07
|
| It's getting late here in Sweden maybe that's why I'm stuck.I have 2 tables, let's say a invoice table and a invoice_item table. 30 of my invoices does not have any invoice_items connected. I want to add a invoice_item for all 30. Something like this...INSERT INTO invoice_item (itemno, price) VALUES (9999, 10) WHERE InvoiceDoesNotHaveInvoiceItems...Any fast solution? |
|
|
VIG
Yak Posting Veteran
86 Posts |
Posted - 2005-08-31 : 18:33:04
|
| [code]insert invoice_item (itemno, price)select 9999,10from invoice ileft join invoice_item it on i.itemno=it.itemnowhere it.itemno is null[/code]but may be you want[code]insert invoice_item (itemno, price)select i.itemno,10from invoice ileft join invoice_item it on i.itemno=it.itemnowhere it.itemno is null[/code] |
 |
|
|
Rauken
Posting Yak Master
108 Posts |
Posted - 2005-08-31 : 19:00:06
|
| Thanks, it's the first one I'm after. It feels a little bit akward to write select 9999, 10 from invoice but it works. |
 |
|
|
|
|
|