Error Msg 2760, Level 16 When trying to create a table in a schema

I was trying to create a table in a schema, but received the following error message: Msg 2760, Level 16, State 1, Line 1

Read on to find out how I solved this problem.

Read more: Error Msg 2760, Level 16 When trying to create a table in a schema

Why create a schema? A schema in SQL Server is a way to organize database objects such as tables, views, and stored procedures into logical groups. By creating separate schemas for different categories of information, we can easily manage and access the data we need, improve security, and simplify database maintenance.

Those are all good points, so I want to create a new table in a schema called HR. I get the following error that the HR schema does not exist. It is correct, I need to create the HR schema first before creating objects in it.

To create the schema, all you have to do is use the CREATE SCHEMA command.

Here is how I created the HR schema.

CREATE SCHEMA [HR]

After the schema is created, the table can now be created in the HR schema.

If I look in SSMS, I can see that the new table is created within the HR schema that just got created.

Below I am trying to drop the HR schema. It errors off with a Msg 3729, Level 16, State 1 error. It is telling us that there is an object that exists and it will not let you drop it until the objects are removed from the schema.

First drop the table.

Now I can successfully drop the schema.

To read more about schemas, I encourage you to follow this link to the documentation. https://learn.microsoft.com/en-us/sql/t-sql/statements/create-schema-transact-sql?view=sql-server-ver16

Msg 4701, Level 16 trying to truncate table through Linked Server

I was trying to truncate a table on a remote server using a Linked Server and received the following error:

Msg 4701, Level 16, State 1, Line 6
Cannot find the object "bill" because it does not exist or you do not have permissions.

Read on to see how I solved this issue.

Continue reading Msg 4701, Level 16 trying to truncate table through Linked Server

Msg 7399, Level 16, State 1 Linked Server. Access Denied

I setup a linked server on a new database server and was trying to run a query that runs against an Oracle database and I got the following error:

Msg 7399, Level 16, State 1, Line 1
The OLE DB provider “OraOLEDB.Oracle” for linked server “ccbtst” reported an error. Access denied.
Msg 7350, Level 16, State 2, Line 1
Cannot get the column information from OLE DB provider “OraOLEDB.Oracle” for linked server “ccbtst”.

Continue reading Msg 7399, Level 16, State 1 Linked Server. Access Denied

Msg 8115, Level 16 Arithmetic overflow

In Sql Server, if you try to count more than 2.1 billion rows or sum up values more than that, you will get this message: Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type int.

Today I will show you the solution to this problem.

Continue reading Msg 8115, Level 16 Arithmetic overflow

SQL Server 2019 New Feature — Msg 8152, Level 16, State 14 String or binary data would be truncated. Improvement!

There are all kinds of new features in the new version of SQL Server 2019.  One of the ones I am excited about is the additional information you now receive be default when you try to insert data that is too long to fit into an existing field.  In prior versions you would get the message below, but you would have no idea what row or field was causing the issue:

Msg 8152, Level 16, State 14, Line 5 String or binary data would be truncated.

Continue reading SQL Server 2019 New Feature — Msg 8152, Level 16, State 14 String or binary data would be truncated. Improvement!

Insert into Table with an Identity column

Have you ever deleted a row of data and then needed to put it back due to being told it was the wrong row, but the table had an identity column and will not let you insert the row back?  Using the Set Identity_Insert command, you can insert into the table.

Continue reading Insert into Table with an Identity column