MSSQL

Lab Database 17/7/2556

July 17, 2013

Preparing Database and table CREATE TABLE product ( prod_id VARCHAR(6) PRIMARY KEY, prod_name VARCHAR(30), sup_id VARCHAR(6), cat_id INT, price money, inStock INT, onOrder INT, reOrder INT )create table product ( prod_id varchar(6) primary key, prod_name varchar(30), sup_id varchar(6), cat_id int, price money, inStock int, onOrder int, reOrder int ) File Data ‘import.txt’ p0001,Tofu,s0031,2,23.00,33,7,10 p0002,Seaweed,s0031,2,6.00,24,11,12 p0003,Biscuits […]

Lab Database 10/7/2556

July 10, 2013

Preparing Database /* Create Database and use Database */ CREATE DATABASE Northwind USE Northwind /* Create Table */ CREATE TABLE Orders ( ord_id INT PRIMARY KEY, emp_id VARCHAR(7), cus_id VARCHAR(7), shipName VARCHAR(30), freight money, qty INT, orderDate datetime, shipedDate datetime );   /* Insert Data */ INSERT INTO Orders (ord_id,emp_id,cus_id,shipName,freight,qty,orderDate,shipedDate) VALUES (10249, ‘e0003’, ‘c0031’ , […]

MSSQL Lab Test 1

June 26, 2013

/*1*/ SELECT CompanyName AS ‘ชื่อบริษัท’ FROM Customer_data ;   /*2*/ SELECT CompanyName,Country FROM Customer_data WHERE Country=’Germany’;   /*3*/ SELECT * FROM Customer_data WHERE Payment BETWEEN 1 AND 20 ORDER BY Country DESC;   /*4*/ SELECT DISTINCT Country FROM Customer_data;   /*5*/ SELECT CompanyName,ContectName,Region FROM Customer_data WHERE Region IS NOT NULL;   /*6*/ SELECT CompanyName,ContectName,Contectitle FROM […]