Get the most out of SQL Server Management Studio (SSMS) with AI-powered SQL query generator

Summary: Shows how easy it is to use the AI-powered SQL query builder together with SSMS. The AI Bot boosts your productivity and creativity by generating formatted and ready-to-use SQL queries in a matter of seconds ⚡️

Introduction

SQL Server Management Studio (SSMS) is a great tool for working with SQL Server. It has a lot of features, but one of the most important ones is the ability to write SQL queries. However, writing SQL queries can be a tedious task. You need to know the structure of the database, the tables, the columns, and the relationships between them. You also need to know the syntax of the SQL language. This is where the AI-powered SQL query builder comes in. It can help you write SQL queries faster and more efficiently.

How does AIHelperBot work

The AI-powered SQL query builder uses OpenAI to generate SQL queries based on the input you provide. The input is natural language description of what you want to see in the query. The AI-powered SQL query builder will then generate a SQL query that matches your input. The generated SQL query is formatted and ready-to-use. You can copy and paste it into SSMS and run it.

How to use the AI-powered SQL query builder

To start the free trial you only need to sign in. Once signed in you will land on the SQL query builder. To use it optimally (with SSMS) you need to click the settings and select "MSSQL" as language. This will enable the AI-powered SQL query builder to generate queries for MSSQL databases:

MSSQL SQL query builder settings

To generate a SQL statement you simply need to type what you want to see using natural language (i.e. everyday non-SQL language). For example, if you want to generate a query that gets all employees who was created this year you can type in the following:

employees created this year

The AI-powered SQL query builder will then generate the following SQL query:

SELECT
  *
FROM
  Employees
WHERE
  YEAR (CreatedDate) = YEAR (CURRENT_TIMESTAMP);

Examples

To get you started here are some examples of what you can do with the AI-powered SQL query builder. When AI Bot doesn't return what you expect, try to reformulate your input and/or request a few suggestions.

Generating tables and fields

If you want AI Bot to assist you in generating the tables and fields you can type in the following:

create a table named "Employees" with id, name, age, url, image, created and updated date

AI Bot suggests the following SQL snippet:

CREATE TABLE
  Employees (
    Id INT PRIMARY KEY,
    Name VARCHAR(100) NOT NULL,
    Age INT,
    Url VARCHAR(255),
    Image VARCHAR(100),
    CreatedDate DATETIME DEFAULT CURRENT_TIMESTAMP,
    UpdatedDate DATETIME DEFAULT CURRENT_TIMESTAMP
  );

Inserting data

If you want AI Bot to assist you in inserting data you can type in the following:

add user named "John Doe", aged 32, with url: https://mywebsite.com

AI Bot suggests the following SQL snippet:

INSERT INTO
  Users (Name, Age, Url)
VALUES
  ('John Doe', 32, 'https://mywebsite.com');

Updating data

If you want AI Bot to assist you in updating data you can type in the following:

update users named "John Doe" to be named "Jane Doe"

AI Bot suggests the following SQL snippet:

UPDATE
  Users
SET
  Name = 'Jane Doe'
WHERE
  Name = 'John Doe';

Or it can be a specific user:

update user with id 1 to be named "Jane Doe"

AI Bot suggests the following SQL snippet:

UPDATE
  Users
SET
  Name = 'Jane Doe'
WHERE
  Id = 1;

Deleting data

If you want AI Bot to assist you in deleting data you can type in the following:

delete users named "John Doe"

AI Bot suggests the following SQL snippet:

DELETE FROM
  Users
WHERE
  Name = 'John Doe';

Or it can be a specific user:

delete user with id 1

AI Bot suggests the following SQL snippet:

DELETE FROM
  Users
WHERE
  Id = 1;

Selecting data

If you want AI Bot to assist you in selecting data you can type in the following:

get all users created this year with older first

AI Bot suggests the following SQL snippet:

SELECT
  *
FROM
  users
WHERE
  YEAR (date_created) = YEAR (GETDATE ())
ORDER BY
  date_created ASC;

Joining tables

If you want AI Bot to assist you in joining tables you can type in the following:

users with their posts, comments, images

AI Bot suggests the following SQL snippet:

SELECT
  u.*,
  p.*,
  c.*,
  i.*
FROM
  Users u
  INNER JOIN Posts p ON u.userId = p.userId
  INNER JOIN Comments c ON u.userId = c.userId
  INNER JOIN Images i ON u.userId = i.userId;

Grouping data

If you want AI Bot to assist you in grouping data you can type in the following:

users grouped by age

AI Bot suggests the following SQL snippet:

SELECT
  Age,
  COUNT(*)
FROM
  Users
GROUP BY
  Age;

Aggregating data

If you want AI Bot to assist you in aggregating data you can type in the following:

users with the oldest age

AI Bot suggests the following SQL snippet:

SELECT
  MAX(Age)
FROM

  Users;

Calculating all data

If you want AI Bot to assist you in calculating data you can type in the following:

row count for all tables in a SQL SERVER database

AI Bot suggests the following SQL snippet:

SELECT
  OBJECT_NAME (OBJECT_ID),
  COUNT(*)
FROM
  sys.all_objects
WHERE
  type_desc = 'USER_TABLE'
GROUP BY
  OBJECT_NAME (OBJECT_ID);

Delete duplicate record

If you want AI Bot to assist you in deleting duplicate records you can type in the following:

delete duplicate records from users and employees

AI Bot suggests the following SQL snippet:

DELETE FROM users
WHERE
  id NOT IN (
    SELECT
      MIN(id)
    FROM
      users
    GROUP BY
      user_name,
      employee_id
  );