Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Can I use Output Into for this idea?

$
0
0
I want to insert many rows at a time into two tables - I have a ValidationMessage Table with the ValidationMessageID and the message, and then an OrderValidationMessages table with the OrderID and the ValidationMessageIDright now the system goes order by order and insert validation messages for each order -and I was thinking I could speed it up by doing a whole result that failed validation at one time - such as:Insert Into ValidationMessage(ValidationMessageTypeID, Text) Output Inserted.ValidationMessageID, O.OrderID into OrderValidationMessage (ValidationMessageID, OrderID)select 2, 'Customer Name Cannot be GAYLE' from [Order] O where agentbatchID = 29216 AND CustomerName like '%GAYLE%'but of course O.OrderID is not available on the Output line :(Any Ideas? rewriting the table structure is not possible ;)Thanks!Jamie

Viewing all articles
Browse latest Browse all 3145

Trending Articles