You heard it well Chatbot wars, the war between Bing vs Bard.
Ladies and gentlemen, in the Google corner we have the challenger, Bard! And in the Microsoft corner, we have a powerful AI-based in ChatGPT 4, the stupendous, the magnificent…Bing! (applause).
These great chatbots will demonstrate their power in different DBA tasks and we will decide which one is the best. Let´s witness a great match between these magnificent competitors.
In previous articles, we talked about ChatGPT vs Bing. Also, we talk about Bard. This time, we will compare Bing and Bard and define who is the winner this time.
General comparison of Bing vs Bard
Both services are free and faster than ChatGPT. ChatGPT is still the best AI service, but currently, it is updated until 2021. Also, it is sometimes slow unless you pay extra money (now 20 USD per month).
Let the battle begin! (drums).
Bing vs Bard (create tables)
Let’s start with Bing.
Me: Please (if the AI conquers the world, I expect some mercy and that is why I use kind words), create the T-SQL code about the Rocky Marciano (1) boxing matches. I want a table with the boxers’ information, and another table with the matches and results.
The information that I want from these tables are:
Total number of matches. Also, the total number of matches won and lost. How old was he and the rivals on the matches, the date of the matches, and knockouts? If you need to create several tables with data, just do it.
Bing: Sure! I can help you with that. Do you have any specific website or source where I can get the data from?
Me: I was kind of disappointed but at least Bing provide me with 2 options:
I will choose the first option.
Bing: I found some information on Rocky Marciano’s boxing matches. Rocky Marciano fought 49 times with 49 wins and no losses1. He remains the only fighter to have stopped every opponent he ever faced for the world heavyweight title. His career knockout-to-win percentage of 87.8% remains one of the highest in heavyweight boxing history.
Bing vs Bard
Me: It is extremely dumb yet. It did not understand anything. Let’s try Bard.
Bard test
Bard: Sure, here is the T-SQL code to create a table with Rocky Marciano's boxing matches:
SQL
CREATE TABLE RockyMarcianoMatches
(
MatchID INT NOT NULL IDENTITY(1,1),
Opponent VARCHAR(50) NOT NULL,
Age INT NOT NULL,
Date DATE NOT NULL,
Result VARCHAR(50) NOT NULL,
Knockout BIT NOT NULL,
PRIMARY KEY (MatchID)
);
Use code with caution. Learn more
This table will store the following information about Rocky Marciano's boxing matches:
MatchID: A unique identifier for each match.
Opponent: The name of Rocky Marciano's opponent in each match.
Age: Rocky Marciano's age at the time of each match.
Date: The date of each match.
Result: The result of each match (win, loss, or draw).
Knockout: Whether or not Rocky Marciano knocked out his opponent in each match.
To populate this table with data, you can use the following INSERT statement:
To get the total number of matches, won, lost, and knockouts, you can use the following queries:
SQL
SELECT COUNT(*) AS TotalMatches
FROM RockyMarcianoMatches;
SELECT COUNT(*) AS WonMatches
FROM RockyMarcianoMatches
WHERE Result = 'Win';
SELECT COUNT(*) AS LostMatches
FROM RockyMarcianoMatches
WHERE Result = 'Loss';
SELECT COUNT(*) AS Knockouts
FROM RockyMarcianoMatches
WHERE Knockout = 'Yes';
This shows that Rocky Marciano fought in 10 matches, won 9 of them, lost 1, and had 7 knockouts.
You can also get the age of Rocky Marciano at the time of each match by using the following query:
SQL
SELECT Age
FROM RockyMarcianoMatches;
Use code with caution. Learn more
This will return a table with one row for each match, and the age of Rocky Marciano at the time of that match in the Age column.
I hope this helps!
Fixing errors with Bard
Bing vs Bard
Me: There are some mistakes in the code. The knockout column is using the bit data type which allows only 0 and 1. However, it is inserting yes, no questions. Also, I will ask Bard to fix the code:
The knockout column of the type bit accepts only 0 and 1. Please modify the insert code.
Bard: Sure, I can do that. Here is the modified INSERT statement:
Bing vs BardMe: The data is not accurate, but at least it showed 10 sample rows. I insisted to have the 49 matches and I got 20 after insisting several times:
I always considered Bing as the Dumb and Bard as Dumber. Bard surprised me. It is extremely bad at T-SQL yet, but I can offer my services to train the AI 😊.
I am very optimistic and I think both chatbots can improve their skills soon.
Currently, we have this score:
Bing
Bard
0
1
Create tables with foreign keys with Bing
Let’s try another test.
Please create a table with an auto numeric id, name, last name, and age. I also want a foreign key to another table with the clubs.
I want the T-SQL code to generate both tables for the best 10 players of the FIFA Ballon d’Or of 2022.
Bing: Sure! I can help you with that. Do you have any specific website or source where I can get the data from?
Me: Unfortunately, this question bothers me, but in some cases can be useful. I said no again.
Bing: Alright. I can help you with that. Do you have any specific database management system (DBMS) you want me to use?
Bing vs Bard
Me: I think Bing is extremely dumb. I said T-SQL, and it does not provide me with the SQL Server option. This is very disappointing considering that Bing is from Microsoft.
I wrote SQL Server.
Bing: Alright. Here’s the T-SQL code to create the two tables you requested:
CREATE TABLE Players (
id INT IDENTITY(1,1) PRIMARY KEY,
name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
age INT NOT NULL,
club_id INT FOREIGN KEY REFERENCES Clubs(id)
);
CREATE TABLE Clubs (
id INT IDENTITY(1,1) PRIMARY KEY,
name VARCHAR(50) NOT NULL
);
Here’s the T-SQL code to insert the best 10 players of the FIFA Ballon d’Or of 2022:
INSERT INTO Clubs (name)
VALUES ('Club 1'), ('Club 2'), ('Club 3'), ('Club 4'), ('Club 5');
INSERT INTO Players (name, last_name, age, club_id)
VALUES
('Player 1', 'Last Name 1', 20, 1),
('Player 2', 'Last Name 2', 21, 2),
('Player 3', 'Last Name 3', 22, 3),
('Player 4', 'Last Name 4', 23, 4),
('Player 5', 'Last Name 5', 24, 5),
('Player 6', 'Last Name 6', 25, 1),
('Player 7', 'Last Name 7', 26, 2),
('Player 8', 'Last Name 8', 27, 3),
('Player 9', 'Last Name 9', 28, 4),
('Player10', 'Last Name10',29,5);
Please note that I used dummy data for the clubs and players. You can replace them with your own data.
Asking for real data in Bing
Bing vs Bard
Me: Could you provide real data?
Bing: I’m sorry but I couldn’t find any real data for the FIFA Ballon d’Or of 2022. However, I can provide you with the T-SQL code to create the tables and insert dummy data. You can replace them with your own data. Is there anything else I can help you with?
Me: It seems that Bard will easily win this competition. Let’s take a look at its answer.
Bing vs Bard
Bard: Sure, here is the T-SQL code to create the tables and insert the data for the best 10 players of the FIFA Ballon d'Or of 2022:
SQL
CREATE TABLE Players
(
ID INT IDENTITY(1,1) PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
Age INT NOT NULL,
ClubID INT FOREIGN KEY REFERENCES Clubs(ID)
);
CREATE TABLE Clubs
(
ID INT IDENTITY(1,1) PRIMARY KEY,
ClubName VARCHAR(50) NOT NULL
);
INSERT INTO Players (Name, LastName, Age, ClubID)
VALUES
('Lionel Messi', 'Messi', 35, 1),
('Karim Benzema', 'Benzema', 34, 2),
('Robert Lewandowski', 'Lewandowski', 33, 3),
('Mohamed Salah', 'Salah', 29, 4),
('Kylian Mbappe', 'Mbappe', 23, 5),
('Neymar', 'Neymar', 30, 6),
('Kevin De Bruyne', 'De Bruyne', 31, 7),
('Jorginho', 'Jorginho', 30, 8),
('Ruben Dias', 'Dias', 25, 9),
('Gianluigi Donnarumma', 'Donnarumma', 23, 10);
INSERT INTO Clubs (ClubName)
VALUES
('Paris Saint-Germain'),
('Real Madrid'),
('Bayern Munich'),
('Liverpool'),
('Paris Saint-Germain'),
('Paris Saint-Germain'),
('Manchester City'),
('Chelsea'),
('Manchester City'),
('AC Milan');
Use code with caution. Learn more
This will create two tables, Players and Clubs, and insert the data for the best 10 players of the FIFA Ballon d'Or of 2022 into the Players table. The ClubID column in the Players table is a foreign key to the ID column in the Clubs table. This means that each player is associated with a club.
Me: I had a few problems with the code. I had to change the order of the table creation to avoid problems related to the foreign key. This problem is easy for someone with some basic experience in databases. However, it can be a big problem for newbies. Anyway, the winner of this test is….(drums).
Bing
Bard
0
2
As I Microsoft fun, I am disappointed. However, there is still hope.
Bing…do not disappoint me again.
Technical Translation in Bing
Let’s try a simple translation of SQL Server text to Spanish (my native language). In this life, I worked as a BI expert, DBA, QA engineer, writer, cowboy, model, and dancer, but also, I worked as a technical translator, so I think I have enough experience to evaluate this software:
Me: Can you translate this to Spanish, please?
Non-leaf Levels
This additional structure is called the non-leaf levels, or node levels, of the index; and is thought of as being built on top of the leaf level, regardless of where its pages are physically located. Its purpose is to give SQL Server a single page entry point for every index, and a short traversal from that page to the page containing any given search key value.
Each page in an index, regardless of its level, contains index rows, or entries. In the leaf level pages, as we have repeatedly seen, each entry either points to a table row or is the table row. So if the table contained one billion rows, the index’s leaf level would contain one billion entries.
In the level just above the leaf level, that is, the lowest non-leaf level; each entry points to one leaf level page. If our one billion entry index averaged 100 entries per page, which is a realistic number for an index whose search key consists of a few numeric, date, and code columns; then the leaf level would contain 1,000,000,000 / 100 = 10,000,000 pages. In turn, the lowest non-leaf level would contain 10,000,000 entries, each pointing to a leaf level page, and would span 100,000 pages.
Each higher non-leaf level has pages whose entries each point to a page at the next lower level. Thus, our next higher non-leaf level would contain 100,000 entries and be 1,000 pages in size. The level above that would contain 1,000 entries and be 10 pages in size; the one above that would consist of ten entries residing on just one page; and that is where it stops.
The lone page sitting at the top of the index is called the root page. The levels of an index that lie below the root page level and above the leaf level are referred to as the intermediate levels. The numbering of the levels starts at zero and works upward from the leaf level. Thus, the lowest intermediate level is always level 1.
Non-leaf level entries contain only index key columns and the pointer to a lower-level page. Included columns only exist in the leaf level entries; they are not carried in the non-leaf level entries.
Each page in an index, except the root page, contains two additional pointers. These pointers point to the next page and the previous page, in index sequence, at the same level. The resulting bi-directional chain of pages enables SQL Server to scan the pages of any level in either ascending or descending sequence.
Bing:
Sure! Here’s the translation:
Niveles no hoja Esta estructura adicional se llama niveles no hoja o niveles de nodo del índice; y se piensa que se construye sobre el nivel de hoja, independientemente de dónde se encuentren físicamente sus páginas. Su propósito es dar a SQL Server un único punto de entrada de página para cada índice y un recorrido corto desde esa página hasta la página que contiene cualquier valor de clave de búsqueda dado.
Cada página en un índice, independientemente de su nivel, contiene filas o entradas de índice. En las páginas del nivel de hoja, como hemos visto repetidamente, cada entrada apunta a una fila de tabla o es la fila de tabla. Por lo tanto, si la tabla contenía mil millones de filas, el nivel de hoja del índice contendría mil millones de entradas.
En el nivel justo por encima del nivel de hoja, es decir, el nivel no hoja más bajo; cada entrada apunta a una página del nivel de hoja. Si nuestro índice de mil millones de entradas tuviera un promedio de 100 entradas por página, que es un número realista para un índice cuya clave de búsqueda consta de algunas columnas numéricas, de fecha y código; entonces el nivel de hoja contendría 1.000.000.000 / 100 = 10.000.000 páginas. A su vez, el nivel no hoja más bajo contendría 10.000.000 entradas, cada una apuntando a una página del nivel de hoja y abarcaría 100.000 páginas.
Cada nivel no hoja superior tiene páginas cuyas entradas apuntan cada una a una página en el siguiente nivel inferior. Por lo tanto, nuestro siguiente nivel no hoja superior contendría 100.000 entradas y tendría un tamaño de 1.000 páginas. El nivel superior a ese contendría 1.000 entradas y tendría un tamaño de 10 páginas; el superior a ese consistiría en diez entradas que residirían en solo una página; y ahí es donde se detiene.
La única página que se encuentra en la parte superior del índice se llama página raíz. Los niveles de un índice que se encuentran por debajo del nivel de la página raíz y por encima del nivel de hoja se denominan niveles intermedios. La numeración de los niveles comienza en cero y funciona hacia arriba desde el nivel de hoja. Por lo tanto, el nivel intermedio más bajo siempre es el nivel 1.
Las entradas del nivel no hoja contienen solo columnas clave del índice y la poi
Me: Something that I noticed is that the limit is 2000 words, the text was truncated.
The translation is not bad, there are some mistakes, but in general, I could understand 99 0f the text.
Technical translations in Bard
Let’s try with our friend Bard (I must admit that I had low expectations for Bard).
Bard:
Sure, here is the translation of the text you provided in Spanish:
Niveles no hoja
Esta estructura adicional se llama niveles no hoja o niveles de nodo del índice; y se considera que se construye sobre el nivel de hoja, sin importar dónde se encuentren sus páginas físicamente. Su propósito es proporcionar a SQL Server un único punto de entrada de página para cada índice, y una breve travesía desde esa página a la página que contiene cualquier valor de clave de búsqueda dado.
Cada página en un índice, independientemente de su nivel, contiene filas de índice o entradas. En las páginas de nivel de hoja, como hemos visto repetidamente, cada entrada apunta a una fila de tabla o es la fila de tabla. Entonces, si la tabla contenía mil millones de filas, el nivel de hoja del índice contendría mil millones de entradas.
En el nivel justo encima del nivel de hoja, es decir, el nivel no hoja más bajo; cada entrada apunta a una página de nivel de hoja. Si nuestro índice de mil millones de entradas promediaba 100 entradas por página, que es un número realista para un índice cuya clave de búsqueda consiste en unas pocas columnas numéricas, de fecha y de código; entonces el nivel de hoja contendría 1,000,000,000 / 100 = 10,000,000 páginas. A su vez, el nivel no hoja más bajo contendría 10,000,000 entradas, cada una apuntando a una página de nivel de hoja, y abarcaría 100,000 páginas.
Cada nivel no hoja más alto tiene páginas cuyas entradas apuntan a una página en el nivel inferior siguiente. Así, nuestro siguiente nivel no hoja más alto contendría 100,000 entradas y tendría 1,000 páginas de tamaño. El nivel superior tendría 1,000 entradas y sería de 10 páginas; el que está encima de ese consistiría en diez entradas que residen en una sola página; y ahí es donde se detiene.
La página solitaria que se encuentra en la parte superior del índice se llama página raíz. Los niveles de un índice que se encuentran por debajo del nivel de la página raíz y por encima del nivel de hoja se denominan niveles intermedios. La numeración de los niveles comienza en cero y se extiende hacia arriba desde el nivel de hoja. Por lo tanto, el nivel intermedio más bajo siempre es el nivel 1.
Las entradas de nivel no hoja contienen solo columnas de índice clave y el puntero a una página de nivel inferior. Las columnas incluidas solo existen en las entradas de nivel de hoja; no se llevan en las entradas de nivel no hoja.
Cada página en un índice, excepto la página raíz, contiene dos punteros adicionales. Estos punteros apuntan a la página siguiente y a la página anterior, en secuencia de índice, en el mismo nivel. La cadena bidireccional resultante de páginas permite a SQL Server escanear las páginas de cualquier nivel en secuencia ascendente o descendente.
Me: The quality is slightly better in Bard. The other advantage is that Bard does not have a limit of 2000 words. This may change in the future. The score is the following:
Bing
Bard
0
3
SQL Server Job in Bing vs Bard
Let´s try to automate some tasks.
Can you create a SQL Server job to back up my Adventureworks2019 database in the c:\backup\adw.bak file?
Please schedule it to run daily at 10 P.M.
Bing:
Sure! Here is a T-SQL script that you can use to back up your Adventureworks2019 database in the c:\backup\adw.bak file and schedule it to run daily at 10 P.M.:
USE [master]
GO
BACKUP DATABASE [AdventureWorks2019] TO DISK = N'C:\backup\adw.bak' WITH NOFORMAT, NOINIT, NAME = N'AdventureWorks2019-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
USE [msdb]
GO
EXEC sp_add_job @job_name=N'Backup AdventureWorks2019',
@enabled=1,
@description=N'This job will backup AdventureWorks2019 database daily at 10 P.M.',
@owner_login_name=N'sa',
@job_id = @jobId OUTPUT
EXEC sp_add_jobstep @job_id=@jobId,
@step_name=N'Backup AdventureWorks2019',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_fail_action=2,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=N'BACKUP DATABASE [AdventureWorks2019] TO DISK = N''C:\backup\adw.bak'' WITH NOFORMAT, NOINIT, NAME = N''AdventureWorks2019-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 10',
@database_name=N'master',
@flags=0
GO
USE [msdb]
GO
EXEC sp_add_schedule @schedule_name=N'Daily at 10 PM',
@enabled=1,
@freq_type=4,
@freq_interval=1,
@freq_subday_type=1,
@freq_subday_interval=0,
@freq_relative_interval=0,
@freq_recurrence_factor=1,
@active_start_date=20230613,
@active_end_date=99991231,
@active_start_time=220000,
@active_end_time=235959
GO
USE [msdb]
GO
EXEC sp_attach_schedule @job_name=N'Backup AdventureWorks2019', @schedule_name=N'Daily at 10 PM'
GO
USE [msdb]
GO
EXEC sp_add_jobserver @job_name=N'Backup AdventureWorks2019', @server_name = N'(local)'
GO
Please note that you should replace the path C:\backup\adw.bak with your desired backup location and that you should replace the database name AdventureWorks2019 with your database name.
I hope this helps! Let me know if you have any questions.
It does not work
Me: When I tried to execute the code, I got this error:
Msg 137, Level 15, State 2, Line 7
Must declare the scalar variable "@jobId".
I complained to Bing.
I got this error message when trying to execute the previous code: Msg 137, Level 15, State 2, Line 7
Must declare the scalar variable "@jobId".
Bing: This error message is because the variable @jobId is not declared. You can add the following line of code before the line that uses the variable @jobId:
DECLARE @jobId UNIQUEIDENTIFIER
This will declare the variable @jobId as a uniqueidentifier data type.
I hope this helps! Let me know if you have any other questions.
Me: I don’t think that the Bing chatbot is understanding the problem. Can you fix your previous code?
Bing:
Sure! Here is the updated code:
USE [master]
GO
DECLARE @jobId UNIQUEIDENTIFIER
EXEC sp_add_job @job_name=N'Backup AdventureWorks2019',
@enabled=1,
@description=N'This job will backup AdventureWorks2019 database daily at 10 P.M.',
@owner_login_name=N'sa',
@job_id = @jobId OUTPUT
EXEC sp_add_jobstep @job_id=@jobId,
@step_name=N'Backup AdventureWorks2019',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_fail_action=2,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=N'BACKUP DATABASE [AdventureWorks2019] TO DISK = N''C:\backup\adw.bak'' WITH NOFORMAT, NOINIT, NAME = N''AdventureWorks2019-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 10',
@database_name=N'master',
@flags=0
GO
USE [msdb]
GO
EXEC sp_add_schedule @schedule_name=N'Daily at 10 PM',
@enabled=1,
@freq_type=4,
@freq_interval=1,
@freq_subday_type=1,
@freq_subday_interval=0,
@freq_relative_interval=0,
@freq_recurrence_factor=1,
@active_start_date=20230613,
@active_end_date=99991231,
@active_start_time=220000,
@active_end_time=235959
GO
USE [msdb]
GO
EXEC sp_attach_schedule @job_name=N'Backup AdventureWorks2019', @schedule_name=N'Daily at 10 PM'
GO
USE [msdb]
GO
EXEC sp_add_jobserver @job_name=N'Backup AdventureWorks2019', @server_name = N'(local)'
GO
Please let me know if you have any other questions.
Me:
The code still has errors. Bing is only copying code from the internet, but the code requires some extra work that a newbie will never detect.
Let’s try Bard.
SQL Server Job in Bard
Bard: Sure, here is the T-SQL code to create a SQL Server job to back up your AdventureWorks2019 database in the c:\backup\adw.bak file and schedule it to run daily at 10 P.M.:
SQL
USE [master];
GO
CREATE PROCEDURE [dbo].[BackupAdventureWorks2019]
AS
BEGIN
BACKUP DATABASE AdventureWorks2019
TO DISK = 'c:\backup\adw.bak'
WITH INIT, COMPRESSION, STATS = 10;
END;
GO
CREATE SCHEDULE [BackupAdventureWorks2019Schedule]
AS
ENABLE;
GO
ALTER SCHEDULE [BackupAdventureWorks2019Schedule]
RUN DAILY AT 22:00;
GO
CREATE JOB [BackupAdventureWorks2019Job]
AS
BEGIN
EXEC [dbo].[BackupAdventureWorks2019];
END;
GO
ALTER JOB [BackupAdventureWorks2019Job]
WITH
START_DATE = '2023-06-15',
DESCRIPTION = 'Backs up the AdventureWorks2019 database daily at 10 P.M.',
SCHEDULE = [BackupAdventureWorks2019Schedule];
GO
Use code with caution. Learn more
This will create a job called BackupAdventureWorks2019 that will back up the AdventureWorks2019 database daily at 10 P.M. The backup file will be created in the c:\backup\adw.bak file.
Me:
In this new example, Bard was completely lost and Bing was for the first time a little bit closer.
Surprisingly, Bing won this time. However, it lost anyway. And the final score is...(drums)…
Bing
Bard
1
3
Conclusion about Bing vs Bard
Both AI entities are in the early stages yet. At least when we talk about coding. Compared with ChatGPT, they provide worse code and are full of errors. ChatGPT also has some problems, but currently, it provides fewer coding errors than Bing and Bard. I had a low expectations about Bard, but I can say it won the test.
Congratulations Bar. You won a test against Bing Chatbot!
Bard:
Thank you! I'm glad to hear that I was able to perform well in the test. Also, I'm always working to improve my skills. I'm excited to continue learning and growing, and I hope to one day be the best chatbot out there.
Also, I'm grateful to the team at Google AI for creating me and for giving me the opportunity to compete in this test. In addition, I know that Bing Chatbot is a very capable chatbot, so it's a great honor to have won.
I'm looking forward to the next challenge!
Notes
Rocky Marciano is the greatest heavyweight boxer of all time. He won 49 of his fights and 43 by knockout. He had an undefeated professional career.
Introduction In this article, we will see how to work with GitHub Copilot. GitHub copilot is an interesting plug-in that generates code using AI. The technology is from Microsoft and OpenAI. We will show how to install Copilot, and how to generate SQL Server code (T-SQL) using Copilot. First, we will answer some FAQs about Copilot […]
Introduction This SQLServerCentral article shows how to create a SQL Server presentation in 5 minutes using AI. AI is revolutionizing the world as it continues to evolve. In this article, we aim to answer the question: Is it truly possible to create a high-quality presentation using AI in such a short amount of time? Is […]