Professional Documents
Culture Documents
SQL Server DBF Coop Group 2
SQL Server DBF Coop Group 2
Date:2020-05-06
1. Project Overview
In this task, we mainly used ‘select top XX Column from table order by
NEWID()’ to fetch data from current table randomly, such as
‘ProductID’, ’CustomerID’, ’EmployeeID’
We used ‘ABS(CHECKSUM(NEWID() ’ to create random data, such as
‘OrderDate’
In order to fetch random data from table ‘Products’, ‘Customers’,
‘Employees’, we used different temp tables to preserve the random data
and update into the desired table repeatedly.
After the increase of [Order Details], we got some duplicate key rows.
We tried to find them ,deleted them and re-do the deleted amounts of
fetching data randomly to make the table has 10M rows
2.1 Data Size
The new version show the most recent 20 years of data, from 1999 to
2019.
Before update the date age, we made a copy for updated and
increased tables - [Orders_1M],and [Order Details_10M]
After checking the current data, the [OrderDate] is from 1928 to 1998
To make the date of current rows to the most recent 20 years, we
made a plan to update the column [OrderDate] like as below
--(1928--1948)+71
--(1949--1969)+50
--(1970--1990)+29
--(1991--1999)+8
2.2 Data Age
There are 3 Ad-Hoc Queries in SQL to directly read data from different
type of data source such as SQL Server, EXCEL Worksheet, ACCESS
Database.
These are OpenQuery, OpenRowSet and OpenDataSource
The syntax are:
OPENQUERY (Linked_Server, ‘query’)
OPENROWSET(‘Provider_name’,’Provider_string’,‘Query or TableName’)
OPENDATASOURCE(‘Provider_name’,’init_string’)
2.7 Ad-Hoc Queries
Part of the scripts are demonstrated as below. Full Code of this task is in
‘2.10-Parameterized Query.sql’
2.10 Parameterized Query
2.10 Parameterized Query
Thank you!