Connect to SQL Server Using Visual Studio Code 2022 and Run SQL Queries (Create Read Update Delete)

Channel Avatar
Comment
X
Share
Connect to SQL Server Using Visual Studio Code 2022 and Run SQL Queries (Create Read Update Delete)
Connect to SQL Server Using Visual Studio Code 2022 and Run SQL Queries (Create Read Update Delete)
How to connect to sql server database using vs code 2022. How to run CRUD operations using vscode

############ SQL queries #############
— get current database:
select DB_NAME()

— create database
create database myshop

— select database
use myshop

— create table:
CREATE TABLE users
(
id INT NOT NULL PRIMARY KEY IDENTITY(1,1),
username varchar(90) NOT NULL,
email varchar(100) NOT NULL,
register_date datetime default CURRENT_TIMESTAMP
)

— insert rows
INSERT INTO users
(username, email)
VALUES
(‘Bill Gates’, ‘[email protected]’),
(‘Will Smith’, ‘[email protected]’),
(‘Elon Musk’, ‘[email protected]’),
(‘Bob Marley’, ‘[email protected]’)
GO

— read rows
select * from users

— Update rows in table ‘users’
UPDATE users
SET
email ‘[email protected]’
WHERE id4
GO

— Delete rows from table ‘users’
DELETE FROM users
WHERE id4
GO

— execute multiple queries
create table products
(
id INT NOT NULL PRIMARY KEY IDENTITY(1,1), — primary key column
product_name VARCHAR(100) NOT NULL,
purchase_price INT NOT NULL,
sale_price INT NOT NULL,
description TEXT
);

create table messages
(
id INT NOT NULL PRIMARY KEY IDENTITY(1,1),
message TEXT,
created_at datetime default CURRENT_TIMESTAMP
);

— drop table
drop table products .

***********************************

*Complete Udemy Courses* :
Build E-commerce *Web Application* using *ASP.NET Core* : https://www.udemy.com/course/aspnet-core-web-application-using-razor-pages/?couponCodeA00078B1466BD4192708
Build E-commerce *Web API* using *ASP.NET Core* : https://www.udemy.com/course/build-aspnet-web-api/?couponCodeA000E2637EEE55E4618E
Build E-commerce *Web Application* using *React JS* : https://www.udemy.com/course/build-complete-react-application/?couponCodeA000228C757F40C404F9

️ *Free Document Proofreading* ️
*Grammarly* : https://grammarly.go2cloud.org/SH3YB

Take the opportunity to connect and share this video with your friends and family if you find it useful.

Read Also

Leave a Reply

Your email address will not be published. Required fields are marked *