sqlpad icon indicating copy to clipboard operation
sqlpad copied to clipboard

The type 'dbo.varchar' already exists, or you do not have permission to create it.

Open rudolphk-om opened this issue 3 years ago • 2 comments

Hi

I am trying to launch our SQL pad using Azure SQL database as the backend and getting the following error.

"The type 'dbo.varchar' already exists, or you do not have permission to create it.","stack":"Error\n at Query.run (D:\\Projects\\sqlpad\\server\\node_modules\\sequelize\\lib\\dialects\\mssql\\query.js:99:25)\n at D:\\Projects\\sqlpad\\server\\node_modules\\sequelize\\lib\\sequelize.js:311:28\n at async Object.up (D:\\Projects\\sqlpad\\server\\migrations\\04-00100-query-acl-schema.js:20:5)","name":"SequelizeDatabaseError","parent":{"type":"RequestError","message":"The type 'dbo.varchar' already exists, or you do not have permission to create it.","stack":"Error: The type 'dbo.varchar' already exists, or you do not have permission to create it.\n at RequestTokenHandler.onErrorMessage (D:\\Projects\\sqlpad\\server\\node_modules\\tedious\\lib\\token\\handler.js:368:21)\n at Readable.<anonymous> (D:\\Projects\\sqlpad\\server\\node_modules\\tedious\\lib\\token\\token-stream-parser.js:26:33)\n at Readable.emit (node:events:390:28)\n at Readable.emit (node:domain:475:12)\n at addChunk (node:internal/streams/readable:315:12)\n at readableAddChunk (node:internal/streams/readable:289:9)\n at Readable.push (node:internal/streams/readable:228:10)\n at next (node:internal/streams/from:98:31)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)","code":"EREQUEST","number":219,"state":1,"class":16,"serverName":"omnisient-sqlpad","procName":"","lineNumber":3,"sql":"IF TYPE_ID('JSON') IS NULL\n BEGIN\n CREATE TYPE [dbo].[JSON] FROM [NVARCHAR](MAX) NULL;\n END"},"original":{"type":"RequestError","message":"The type 'dbo.varchar' already exists, or you do not have permission to create it.","stack":"Error: The type 'dbo.varchar' already exists, or you do not have permission to create it.\n at RequestTokenHandler.onErrorMessage (D:\\Projects\\sqlpad\\server\\node_modules\\tedious\\lib\\token\\handler.js:368:21)\n at Readable.<anonymous> (D:\\Projects\\sqlpad\\server\\node_modules\\tedious\\lib\\token\\token-stream-parser.js:26:33)\n at Readable.emit (node:events:390:28)\n at Readable.emit (node:domain:475:12)\n at addChunk (node:internal/streams/readable:315:12)\n at readableAddChunk (node:internal/streams/readable:289:9)\n at Readable.push (node:internal/streams/readable:228:10)\n at next (node:internal/streams/from:98:31)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)","code":"EREQUEST","number":219,"state":1,"class":16,"serverName":"omnisient-sqlpad","procName":"","lineNumber":3,"sql":"IF TYPE_ID('JSON') IS NULL\n BEGIN\n CREATE TYPE [dbo].[JSON] FROM [NVARCHAR](MAX) NULL;\n END"},"sql":"IF TYPE_ID('JSON') IS NULL\n BEGIN\n CREATE TYPE [dbo].[JSON] FROM [NVARCHAR](MAX) NULL;\n END","parameters":{}},"msg":"Error starting SQLPad"}

Please advise, if this is a configuration or SQL Server issue?

Regards

rudolphk-om avatar Jul 26 '22 13:07 rudolphk-om

The dbo.schema_version does get created.

rudolphk-om avatar Jul 26 '22 13:07 rudolphk-om

@rudolphk-om this is likely a SQL Server issue with the SQL used for migration.

In a migration we have some code to add a JSON type if JSON does not exist. This is to support the use of Sequelize, an ORM for Node.js.

IF TYPE_ID('JSON') IS NULL 
BEGIN 
  CREATE TYPE [dbo].[JSON] FROM [NVARCHAR](MAX) NULL; 
END

If I were to guess, this SQL is not supported on Azure SQL and would need some customizing to work properly.

rickbergfalk avatar Jul 26 '22 15:07 rickbergfalk