-1

I tried to run: php artisan migrate

Also to connect to SQL Server using Xampp on Windows.

SQL Server 2008

PHP Version 8.1.4

Laravel Framework 9.29.0

Windows 7 64 bit maximum

I Got this error:

C:\xampp\htdocs\LaraUral>php artisan migrate

   Illuminate\Database\QueryException

  SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Ser ver to communicate with SQL Server. Access the following URL to download the ODB C Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712 (SQL: select * from sys.sysobjects where id = object_id(migrations) and xtype in  ('U', 'V'))

  at C:\xampp\htdocs\LaraUral\vendor\laravel\framework\src\Illuminate\Database\C onnection.php:759
    755aЦХ         // If an exception occurs when attempting to run a query, we' ll format the error
    756aЦХ         // message to include the bindings with SQL, which will make this exception a
    757aЦХ         // lot more helpful to the developer instead of just the data base's errors.
    758aЦХ         catch (Exception $e) {   az? 759aЦХ             throw new QueryException(
    760aЦХ                 $query, $this->prepareBindings($bindings), $e
    761aЦХ             );
    762aЦХ         }
    763aЦХ     }

  1   C:\xampp\htdocs\LaraUral\vendor\laravel\framework\src\Illuminate\Database\ Connectors\Connector.php:70
      PDOException::("SQLSTATE[IMSSP]: This extension requires the Microsoft ODB C Driver for SQL Server to communicate with SQL Server. Access the following URL  to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fw link/?LinkId=163712")

  2   C:\xampp\htdocs\LaraUral\vendor\laravel\framework\src\Illuminate\Database\ Connectors\Connector.php:70
      PDO::__construct("sqlsrv:Server=127.0.0.1,1433;Database=xproject2", "sa", "123456789", [])

.env file:

DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
DB_PORT=1433
DB_DATABASE=xproject2
DB_USERNAME=sa
DB_PASSWORD="123456789"
korvon
  • 15
  • 4
  • 3
    as the exception says you need to install ODBC Driver 18 – Behzad Sep 12 '22 at 06:41
  • *This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODB C Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712* - There's links in that URL to download the appropriate SQL server drivers for your OS, PHP version and architecture and there's also instructions on how to enable them – apokryfos Sep 12 '22 at 06:46

1 Answers1

0

Did you already enabled the extension pdo_sqlsrv in your Xampp ? if not please enable that extension additionally you will also need to have the ODBC driver installed on your machine.

You can get it at one of these locations:

https://www.microsoft.com/en-us/download/details.aspx?id=36434 https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017