CREATE VIEW on NVARCHAR data type columns
Error
Msg 15151, Level 16, State 1, Procedure testnvarchar, Line 2
Cannot find the type 'nvarchar', because it does not exist or you do not have permission.
Today I was trying to troubleshoot a problem for a client who was trying to create a view. He was receiving the above error after I granted one user the permission to create views. The client was using the following command to create the view
Reason
Looks like you can not create views and select columns that are of unicode data types like nvarchar, ntext and nchar. I was able to duplicate this error on multiple servers where the users had CREATE VIEW permission.
Solution
The work around for this issue is to CONVERT the columns to non unicode data type like the following TSQL
CREATE VIEW testvarchar AS
SELECT CONVERT( VARCHAR(50), FirstName) AS FirstName
FROM Person.Contact
Error
Msg 15151, Level 16, State 1, Procedure testnvarchar, Line 2
Cannot find the type 'nvarchar', because it does not exist or you do not have permission.
Today I was trying to troubleshoot a problem for a client who was trying to create a view. He was receiving the above error after I granted one user the permission to create views. The client was using the following command to create the view
CREATE VIEW testnvarchar AS
SELECT ContactID, FirstName
FROM Person.Contact
SELECT ContactID, FirstName
FROM Person.Contact
Reason
Looks like you can not create views and select columns that are of unicode data types like nvarchar, ntext and nchar. I was able to duplicate this error on multiple servers where the users had CREATE VIEW permission.
Solution
The work around for this issue is to CONVERT the columns to non unicode data type like the following TSQL
CREATE VIEW testvarchar AS
SELECT CONVERT( VARCHAR(50), FirstName) AS FirstName
FROM Person.Contact
Hello Kaykay,
ReplyDeleteThanks for your post.
I would like to highlight that i have tested this in SQL Server 2012 and it is working fine without any issue.
Could you please re-check this post and update if required.