Skip to content

Instantly share code, notes, and snippets.

@StaniTr StaniTr/Part1

Last active Aug 29, 2015
What would you like to do?
Part1 - Create DB, Create Table, Import Data From CSV
USE master
CREATE DATABASE sqlPuzzleSessions
--The model database is used as the template for all databases created on an instance of SQL Server.
/*Primary data file - contains the startup information for the database; points to the other files in the database.
User data and objects can be stored in this file or in secondary data files.
Every database has one primary data file. (.mdf)*/
-- Because MAXSIZE is not specified, the files can grow to fill all available disk space.
(NAME = puzz,
--puzz - primary file, size = size of the primary file in the model database
--transaction log file - automatically =25%*max(primaryFileSize, 512 KB)
FILENAME = 'D:\SQLTraining\SQLpuzzle\sqlPuzzleSessions.mdf')
CREATE TABLE puzzSessions(
--Create table
Session_ID INT,
"Timestamp" DATETIME,
ActionName VARCHAR(6)
--insert data from 'sql_puzzle_sessions.csv'
BULK INSERT puzzSessions
FROM 'D:\SQLTraining\SQLpuzzle\sql_puzzle_sessions.csv'
FIELDTERMINATOR = ',', --CSV field delimiter
ROWTERMINATOR = '\n', --Use to shift the control to next row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.