Error "-2147217900 CREATE VIEW" when getting data from SQL Server

waldux 21 Reputation points
2020-09-04T06:40:39.627+00:00

Hello,

I'm using Excel VBA to connect to SQL Server and get accounting data from accounting software. There are several databases (companies) in accounting software, but they all look alike.

Whenever I connect to database (company) "A" with User ID, password, SQL query, I get recordset and can analyse the data. However, when I connect to database (company) "B" with the same User ID, password and SQL query, I get error message.

22677-image.png

I made some checks and found that SQL Query code is the same both in database "A" and "B", parameters of SQL are also the same. User exists both in database "A" and "B".

What could be the problem and how can I solve it?

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
8,576 questions
No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 68,371 Reputation points Microsoft MVP
    2020-09-04T09:58:04.42+00:00

    The explanation that comes first to mind is that the user has permission to create views in database A, but not in database B. CREATE VIEW is a fairly hefty permission, so it is nothing to take for granted.


2 additional answers

Sort by: Most helpful
  1. Miamiao-MSFT 4,216 Reputation points
    2020-09-04T07:36:06.33+00:00

    Hi @waldux ,

    What could be the problem and how can I solve it?

    1.Please make sure you have tested with the correct database path;(You can clear the cache and refresh then connect again,maybe it save the first db path as the second one)
    2.If there are spaces in your column name as Column Name , please change it as [Column Name] to have a test.

    This case may be helpful: run-time-error-2147217900-80040e14-automation-error

    BR,
    Mia
    If the reply is helped, please do “Accept Answer”.

    No comments

  2. Miamiao-MSFT 4,216 Reputation points
    2020-09-07T06:40:56.913+00:00

    Hi @waldux ,

    Is the issue solved?

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    BR,
    Mia

    No comments