Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Fix for dropping columns when using MSSQL as database #37308

Closed
wants to merge 2 commits into from

Conversation

samloft
Copy link

@samloft samloft commented May 7, 2021

When using MSSQL as the database for an application you are unable to drop columns.

 $table->dropColumn('name');

The error received is

SQLSTATE[42S02]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'SYS.COLUMNS'. (SQL: DECLARE @sql NVARCHAR(MAX) = '';SELECT @sql += 'ALTER TABLE...

This is due to the fact that the SYS.COLUMNS table is actually located in the "master" database, so that is why you are unable to query this table from any other database.

This (very) simple PR fixes this by prefixing the table name with the master database.

@taylorotwell
Copy link
Member

I can drop a table from a SQL Server table on my local machine.

@samloft
Copy link
Author

samloft commented May 10, 2021

@taylorotwell this is a fix for not being able to drop columns on MSSQL, not tables.

Could you please re-review?

@taylorotwell
Copy link
Member

Sorry - I meant drop column. I can drop a column. I dropped the "name" column from my users table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants