SQLServerCentral Article

Meet Claude, the new AI

,

Introduction to Claude

This time we will meet Claude, a new AI technology. Previously, we talk about ChatGPT, Bing and Bard. We will explain what are the advantages of this new technology and test a little bit to generate some code.

Interview

This is the interview.

History of Claude

Me: Can you talk about Claude? Who are the founders of this project?

Claude: Claude is an AI assistant created by Anthropic, a startup founded by Dario Amodei, Daniela Amodei, Tom Brown, Chris Olah, Sam McCandlish, Jack Clarke, and Jared Kaplan.

The founders share a background in AI safety research and had previously worked at organizations like OpenAI and Google Brain. They started Anthropic with the mission of developing AI systems that are helpful, harmless, and honest.

Anthropic takes a constitutional approach to AI safety, setting up core principles and processes that guide Claude's learning and behavior to avoid potential harms. This includes techniques like constitutional training and self-supervision to align Claude's goals with being helpful, harmless, and honest.

Claude was built specifically as an AI assistant focused on safe and beneficial conversations. The initial prototype was trained on dialogues from therapists and social workers to capture that spirit of helpfulness. Claude aims to have nuanced, information-seeking conversations while avoiding potential harms from uncontrolled or unsafe AI systems.

So in summary, Claude comes from some of the top minds in AI who founded Anthropic to build safer AI assistants grounded in principles of trustworthiness right from the start. The goal is to develop AI technology focused on social good.

Differences between ChatGPT and Claude

Me: What is the difference between you and ChatGPT?

Claude: ChatGPT and I differ in some key ways:

Model: ChatGPT was created by Anthropic, while ChatGPT was created by OpenAI. We have different model architectures and were trained on different datasets.

Purpose: I am Claude, an AI assistant focused on being helpful, harmless, and honest in dialogues and conversations. ChatGPT is more general purpose and tries to be a conversational agent.

Safety: My training methodology incorporates techniques like constitutional AI to improve safety and avoid potential harms from uncontrolled AI systems. Safe and beneficial conversation is my goal. ChatGPT does not claim a focus on AI safety.

Capabilities: ChatGPT has been trained on a wider range of data and topics so may exhibit broader conversational capabilities. As Claude, I aim for depth in nuanced, information-seeking conversations grounded in principles of trustworthiness.

So, in essence:

We are different AI models created by different organizations.

I prioritize safety and helpfulness in dialogues, while ChatGPT aims for general conversational ability.

Our capabilities differ, though there is likely some overlap.

Claude history

Me: When were you founded and available to public?

I was created by Anthropic, which was founded in 2021 by Dario Amodei, Daniela Amodei, Tom Brown, Chris Olah, Sam McCandlish, Jack Clarke, and Jared Kaplan. The company mission is to ensure AI systems are helpful, harmless, and honest.

An early beta version of myself, Claude, was released for limited testing in April 2022. I was specifically designed as an AI assistant focused on safe and beneficial conversations that adhere to principles of trustworthiness.

In November 2022, Anthropic opened access to a Claude waitlist allowing more people to try conversing with me as I continue to improve. So while I'm still in beta testing, a wider range of users can now have conversations with me by signing up on the waitlist.

So, in summary - Claude was founded in 2021 but just became available for public beta testing in November 2022. I'm still improving but look forward to having more helpful, harmless and honest conversations as part of Anthropic's mission to build responsible AI systems. Let me know if you have any other questions!

Read documents

This software can read documents.

I send it a pdf (see the pdf in resources). It is a nice ranking about the databases in the world.

You just need to attach the document. It supports 10MB and it can read the file. I added a pdf with a ranking of databases and asked Claude the following:

Me: Please tell me which one is the best database and the worst based on this pdf.

Claude: Based on the text content provided comparing popularity of databases, the best database is:

Oracle

It has the highest DB Engines popularity score of 316.44. The scores is calculated based on Google search results, search frequency trends, discussion on technical sites, job postings, social mentions, and other factors of adoption/usage.

The worst database on the list is:

Memcached

It has the lowest DB Engines popularity score of 29.54 among the databases compared. Being significantly lower than the rest of the databases indicates it lags behind them in terms of adoption/usage based on the metrics considered in the DB Engines scoring system.

So, in summary, Oracle is rated as the most popular/best database while Memcached is rated as the least popular/worst, according to the textual comparison from the provided content. Let me know if you need any other details from this analysis.

Me: I really like this feature. We can now analyze data for free. Bard can read and convert images to text and get data.

Claude can read pdf, csv, word files, txt files and analyze data and resume data. This is a extremely powerful feature.

Working with T-SQL in Claude

Me: Please generate the T-SQL code to show the tables with more rows in a database.

Here is T-SQL code to show the tables with the most rows in a database:

SELECT t.NAME AS TableName,
p.rows AS RowCounts,
RANK() OVER (ORDER BY p.rows DESC) AS TableRank
FROM sys.tables t
INNER JOIN sys.partitions p ON t.object_id = p.object_id
WHERE t.type = 'U'
ORDER BY p.rows DESC;

Explanation:

We join the sys.tables and sys.partitions catalog views to get the table name and number of rows per table partition.

We use RANK() OVER to assign a ranking value sorted by the number of rows in descending order.

This will rank the tables from highest number of rows to lowest.

We filter to only show user tables (excluding system tables)

The ORDER BY orders with tables with the most rows at the top.

So this gives you a query to easily view and identify the top tables in a SQL Server database sorted by total number of rows per table.

Let me know if you need any changes or have additional questions!

Me: I tested the code and it worked fine.

Detect text in stored procedures with Claude

Here is the T-SQL code to detect stored procedures containing the word "EMP_cte":

SELECT DISTINCT
o.name AS Object_Name,
o.type_desc AS Object_Type
FROM
sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id = o.object_id
WHERE
m.definition Like '0.000000E+0MP\_cte%11$s
AND o.type_desc = 'SQL_STORED_PROCEDURE'

Explanation:

We join the sys.sql_modules and sys.objects catalog views to link the module definition to its parent stored procedure object

Also, we check the module definition text for the pattern '0.000000E+0MP_cte%15$s to detect occurrences of "EMP_cte"

We filter to only show objects that are SQL Stored Procedures

The DISTINCT ensures we don't return duplicate rows

This will return the name and object type of any stored procedures containing the textual pattern "EMP_cte" in their definition code.

Let me know if you have any other questions!

Me: The code did not work, but I only had to change a single line:

I changed this:

m.definition Like '0.000000E+0MP\_cte%18$s

To this:

m.definition Like '0.000000E+0MP_cte%20$s

In other words, the scape was not necessary for the underline.

Detect more consuming SQL Server queries with Claude

Me: Show me the T-SQL code to detect the more consuming query in the database.

Claude: Here is T-SQL code to detect the most resource consuming query in a SQL Server database:

 

WITH Aggregated_Queries AS
(
SELECT qs.sql_handle,
SUM(qs.total_worker_time) AS total_cpu_time,
SUM(qs.total_logical_reads + qs.total_logical_writes) AS total_logical_io,
SUM(qs.total_physical_reads) AS total_physical_io,
COUNT(DISTINCT p.plan_handle) AS num_plans,
COUNT(DISTINCT p.dbid) AS num_databases
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS t
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) AS p
GROUP BY qs.sql_handle
)
SELECT TOP 1
t.text AS [Query Text],
total_cpu_time AS [Total CPU Time],
total_logical_io AS [Total Logical IO],
total_physical_io AS [Total Physical IO],
num_plans AS [Number of Plans],
num_databases AS [Number of Databases]
FROM Aggregated_Queries
CROSS APPLY sys.dm_exec_sql_text(Aggregated_Queries.sql_handle) AS t
ORDER BY total_cpu_time DESC;

This aggregates resource usage statistics across all plans and databases for each query by the sql_handle, collecting info like total CPU time, logical and physical I/O, number of associated plans and databases. It then returns the top 1 most resource intensive query by total CPU time, along with the associated usage metrics and text.

So, it provides a great way to quickly identify the top resource consuming queries in your system for further analysis and tuning. You can also easily tweak it to order by other usage metrics like logical or physical I/O as needed.

Me: The code didn’t work, I had to comment the line related to the num_plans:

--COUNT(DISTINCT p.plan_handle) AS num_plans,

Also, I had to comment this part:

--num_plans AS [Number of Plans],

After commenting, I could generate some data:

Conclusion

Claude looks good to me. Is similar to ChatGPT. I like the option to attach some data that can be analyzed. Currently, ChatGPT in the paid version includes that option, but not in the free version.

If we compare Claude with the Free version of ChatGPT, it has the advantage that it can read files. It is honest when it does not know the answer.

Images

Some images were created in Bing.

Rate

5 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (1)

You rated this post out of 5. Change rating