Create a table for invoices that have been paid. Name this table invoicespaid. T
ID: 3854683 • Letter: C
Question
Create a table for invoices that have been paid. Name this table invoicespaid. The table should have columns for the VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal, AccountNo, InvoiceLineItemAmount, and InvoiceLineItemDescription. You can use this create table statement. CREATE TABLE [dbo].[invoicespaid]( [VendorName] [varchar](200) NOT NULL, [InvoiceNumber] [varchar](50) NOT NULL, [InvoiceDate] [smalldatetime] NOT NULL, [InvoiceTotal] [money] NOT NULL, [AccountNo] [int] NOT NULL, [InvoiceLineItemAmount] [money] NOT NULL, [InvoiceLineItemDescription] [varchar](300) NOT NULL)
Insert into the invoicespaid table all of the records from the invoices and invoicelineitems tables that have been paid. Make sure this is an insert into statement that is using a select statement to get the records from the invoices and invoicelineitems tables.
Now, you want to mark those records that have been moved to this table. Add a column named moved to the invoices table using an alter table statement.
Write an update statement to update the records that were moved to true. All other records should be false.
1 create table statement, 1 insert statement, 1 alter table statement, 1 update statement
(Make sure your insert statement uses a select statement to pull values from the invoices and invoicelineitems table)
Need it all written out please! So I can just plug into SQL server! thank you!!
dbo.ContactUpdates dbo.GLAccounts dbo.InvoiceArchive dbo.InvoiceLineltems ES dbo·Invoices dbo.Terms dbo.VendorsExplanation / Answer
1. Create a table:
CREATE TABLE [dbo].[invoicespaid]( [VendorName] [varchar](200) NOT NULL, [InvoiceNumber] [varchar](50) NOT NULL, [InvoiceDate] [smalldatetime] NOT NULL, [InvoiceTotal] [money] NOT NULL, [AccountNo] [int] NOT NULL, [InvoiceLineItemAmount] [money] NOT NULL, [InvoiceLineItemDescription] [varchar](300) NOT NULL)
2. Add a column to table
ALTER TABLE [dbo].[invoicespaid] ADD moved varchar(5) NOT NULL DEFAULT 'False'
3. Inserts a records to into table:
INSERT INTO [dbo].[invoicespaid] ([VendorName], [InvoiceNumber],[InvoiceDate], [InvoiceTotal], [AccountNo],
[InvoiceLineItemAmount],[InvoiceLineItemDescription])
SELECT B.VendorName,A.InvoiceNumber,A.InvoiceDate,A.InvoiceTotal,B.DefaultAccountNo,A.PaymentTotal,C.TermsDescription from Invoices A Join Vendors B on A.VendorId=B.VendorId Join Terms C on A.TermsId=C.TermsId
4. Update the value of the colums
Update [dbo].[invoicespaid] Set moved='True'
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.