I am taking a datatable
as parameter in my stored procedure and I am trying to insert a few of its column in one of the database tables but I don't know the correct syntax.
This is what I have tried
ALTER PROCEDURE [dbo].[spInsertInvoice]
@tblInvoice [TypeExcel] READONLY
AS
BEGIN
SET NOCOUNT ON;
INSERT into Invoice(InvoiceNo, InvoiceDate, CustomerName,[Subject], Reference)
VALUES (SELECT Template, Invoice_No, InvoiceDate, Cust_Name,[Subject], Reference FROM @tblInvoice)
END
Please guide me how can I correctly insert values in my table.
You need the form of insert that takes a select rather than a values:
All the features of a select are available (column aliases, grouping, joins, sub queries, ...).