USE [master]
GO
------------- Check database if already exists then drop -------------------
IF EXISTS (SELECT [name] FROM sys.databases WHERE [name] = 'db_Product' )
DROP DATABASE db_Product
GO
------------- Create Database-------------
CREATE DATABASE db_Product
GO
-------------Switch database -------------
USE [db_Product]
GO
------------ Check table if already exists then drop -------------------
IF EXISTS (SELECT [name] FROM sys.tables WHERE [name] = 'tbl_Product' )
DROP TABLE tbl_Product
GO
------------ Create tbl_Product table ----------------------------------
CREATE TABLE tbl_Product
(
ProductId INT,
ProductName VARCHAR(50),
ProductPrice FLOAT,
Quintity INT,
)
GO
----------------Insert data into tbl_Product table-------------------------
INSERT INTO tbl_Product VALUES (1, 'Mobile', 5200, 15);
INSERT INTO tbl_Product VALUES (2, 'Laptop', 25452, 25);
INSERT INTO tbl_Product VALUES (3, 'Desktop', 18451, 8);
----------------Count total inseted data --------------------------------
SELECT COUNT(*) AS 'TotalRecords' FROM tbl_Product
Once you have save successfully Product.sql in the SQLScripts folder then go to next step.
Step 2: Using the CMDSQL Command:
1: Open the run window and type CMD then enter.
2: Type command CD C:\ for Change the directory to C drive
3: Type command CD "SQLScripts" for select SQLScripts folder where your saved SQL scripts file.
4: Using dir command you can see Product.sql file.