Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SQL Table Hello I need to create a SQL table for Account Number, Products, and Route tables. With a bulk insert script. This is what

SQL Table

Hello I need to create a SQL table for Account Number, Products, and Route tables. With a bulk insert script.

This is what I have came up with:

IF Object_id('dbo.Env_Acct_Number', 'U') IS NOT NULL DROP TABLE dbo.env_acct_number;

CREATE TABLE env_acct_number ( env_acct_numberid INT UNIQUE, propertyid INT NOT NULL, accountnumber CHAR(20) NOT NULL UNIQUE, accounttype CHAR(12) NOT NULL CONSTRAINT atc CHECK (accounttype IN ( 'C', 'S')), balance MONEY NOT NULL, modifieddate DATETIME DEFAULT (Getdate()), PRIMARY KEY (env_acct_numberid), FOREIGN KEY (propertyid) REFERENCES property(propertyid) ON DELETE CASCADE );

BULK INSERT dbo.Env_Acct_Number FROM 'C:\Users\user_\Desktop\Classes\Fall 2017\Folder\Env_Acct_Number.txt' WITH(FIRSTROW = 1,FIELDTERMINATOR = ',',ROWTERMINATOR = ' ');

IF Object_id('dbo.Product_Comp', 'U') IS NOT NULL DROP TABLE dbo.product_comp;

CREATE TABLE product_comp ( product_comp_id INT PRIMARY KEY, product_comp_name VARCHAR(30), product_comp_location VARCHAR (15), address VARCHAR(50), phone_number VARCHAR(12), email VARCHAR(50) );

BULK INSERT dbo.Product_Comp FROM 'C:\Users\user_\Desktop\Classes\Fall 2017\Folder\Product_Comp.txt' WITH(FIRSTROW = 1,FIELDTERMINATOR = ',',ROWTERMINATOR = ' ');

IF Object_id('dbo.Delivery_Routes', 'U') IS NOT NULL DROP TABLE dbo.delivery_routes;

CREATE TABLE delivery_routes ( delivery_routes_id INT PRIMARY KEY, customer_name VARCHAR(30), customer_address VARCHAR (15), city VARCHAR(50), country VARCHAR(50), state VARCHAR(12), year VARCHAR(50), month VARCHAR(12), day VARCHAR(10), hour VARCHAR(10), minute VARCHAR(12) );

BULK INSERT dbo.Delivery_Routes FROM 'C:\Users\user_\Desktop\Classes\Fall 2017\Folder\Delivery_Routes.txt' WITH(FIRSTROW = 1,FIELDTERMINATOR = ',',ROWTERMINATOR = ' ');

I have created the three SQL tables with the bulk statement but I am not sure if I did them correctly please go over my code to point out the errors that I have done

Thank you in advance

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+management system of the MNE?

Answered: 1 week ago