I am trying to insert new rows into a table but there are a few tricky things I have not been able to get my head around.
1. I need to insert a unique ID in each row.
2. I need to insert rows based on information from another table.
I am using sql server 2005.
I have come up with some code, but it does not work. I get an "Error in list of function arguments: 'FROM' not recognized." message.
Can someone tell me if I am on the right track with this or if I need to take a different approach?
1. I need to insert a unique ID in each row.
2. I need to insert rows based on information from another table.
I am using sql server 2005.
I have come up with some code, but it does not work. I get an "Error in list of function arguments: 'FROM' not recognized." message.
Can someone tell me if I am on the right track with this or if I need to take a different approach?
Code:
insert into activity (seqn, id, activity_type, transaction_date) VALUES ( coalesce(MAX(seqn), 0) + 1 FROM activity WITH (UPDLOCK), (select id FROM subscriptions WHERE (PRODUCT_CODE = 'Product1') AND (PAID_THRU = '2007-12-31')) , 'DUES', '2008-12-31')
Comment