24 Sept 2019

How to use Visual Studio Code to manage MSSQL Databases

1. Install the mssql extension for VS Code
2. Create or open a SQL file
3. Connect to SQL Server
-- Press Ctrl+Shift+P or F1 to open the Command Palette.
-- Start to type MS SQL and select MS SQL: Connect from the dropdown
--- MS SQL: Manage Connection Profiles
--- Then select Create
--- Follow the prompts to specify the properties for the new connection profile. After specifying each value, press Enter to continue.

5. Run the SQL script to test it.

CREATE DATABASE AppDB
GO

EXEC SP_HELPDB AppDB;

USE AppDB;

CREATE TABLE [User]
(
UserId int NOT NULL PRIMARY KEY IDENTITY,
FirstName [NVARCHAR](50) NOT NULL,
LastName [NVARCHAR](50) NOT NULL
);
GO

INSERT INTO [User]
(FirstName, LastName)
VALUES
('Borys', 'Razin'),
('Olga', 'Proshkina'),
('Ivan', 'Yankovsky');
GO

SELECT * FROM [User];

4. Press Ctrl+Shift+E to execute the Transact-SQL commands.

More info here

No comments:

Post a Comment

Popular Posts