If you’re getting SQL Server error 2715, which reads something like “Column, parameter, or variable #1: Cannot find data type SERIAL“, it appears that you’re trying to define a column to have a data type that’s not supported in SQL Server.
To fix this issue, be sure to use a supported data type for all columns.
Example of Error
Here’s an example of code that produces the error:
CREATE TABLE Products (
ProductID SERIAL PRIMARY KEY,
ProductName VARCHAR(255),
Quantity INT,
Price DECIMAL(10, 2)
);
Output:
Msg 2715, Level 16, State 6, Line 1
Column, parameter, or variable #1: Cannot find data type SERIAL.
In this case I’m trying to define the ProductID
column as a SERIAL
type. The only problem is that SQL Server doesn’t support the SERIAL
type.
This could happen if you’re trying to run code that was meant for another DBMS. For example, the above code should work fine in PostgreSQL or MySQL, but not SQL Server.
Here’s another example:
CREATE TABLE Products (
ProductID INT IDENTITY PRIMARY KEY,
ProductName VARCHAR(255),
Quantity OOPS,
Price DECIMAL(10, 2)
);
Output:
Msg 2715, Level 16, State 6, Line 2
Column, parameter, or variable #3: Cannot find data type OOPS.
This time it was column three that caused the issue. Regardless, it’s the same cause; there’s no such data type.
Solution 1
Assuming you intend to run this code against SQL Server (i.e. you’re not accidentally running the code against the wrong DBMS), then the following solution should work:
CREATE TABLE Products (
ProductID INT IDENTITY PRIMARY KEY,
ProductName VARCHAR(255),
Quantity INT,
Price DECIMAL(10, 2)
);
Output:
Commands completed successfully.
Here, I changed SERIAL
to INT IDENTITY
and it resolved the issue. Obviously, the data types you use will depend on the actual table and columns that you’re trying to create. In my case the issue was caused by the SERIAL
keyword, and so I rectified that.
Solution 2
There’s also the possibility that you intended to run the code in MySQL (or another DBMS) and accidentally ran your code against the wrong DBMS. This could easily happen if you’re using the same client application to connect to multiple DBMSs.
In this case, simply switching to the correct DBMS should do the trick (unless there are other issues with your code).
So double check that you’re running the code against the right DBMS – and database for that matter!.