3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Azure SQLServerで、php /var/www/artisan migrate 時に "Could not find stored procedure 'sp_msforeachtable'." が出た場合の対処

Posted at

Azure 使うなら SQL Server使うでしょ、ということでSQL Server と Laravelを組み合わせて使うと、 artisan migrate実行時にエラーが発生。つらい。

[2022-02-07 06:54:34] local.ERROR: SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Could not find stored procedure 'sp_msforeachtable'. (SQL: EXEC sp_msforeachtable 'DROP TABLE ?') {"exception":"[object] (Illuminate\\Database\\QueryException(code: 42000): SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Could not find stored procedure 'sp_msforeachtable'. (SQL: EXEC sp_msforeachtable 'DROP TABLE ?') at /var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:703)
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php(663): Illuminate\\Database\\Connection->runQueryCallback('EXEC sp_msforea...', Array, Object(Closure))
#1 /var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php(493): Illuminate\\Database\\Connection->run('EXEC sp_msforea...', Array, Object(Closure))

どうやら、AzureのSQLServerには sp_msforeahtableが存在しないらしいです。
Stackoverflowさんもそうおっしゃっております。なんてこった。

Deploy database to Azure SQL fails, sp_MSforeachtable not found
https://stackoverflow.com/questions/46651612/deploy-database-to-azure-sql-fails-sp-msforeachtable-not-found

が、そこはStackoverflowさんということで、解法も載っていました。

あわてず、以下記載のSQLを実行してcreate

無事解決。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?