<?php
// 连接mssql
$serverName = "PC-202003XXXXXXX\ABC"; //实例名
$connectionInfo = array( "Database"=>"XXXXXXX", "UID"=>"sa", "PWD"=>"XXXXXXX"); //数据库;用户名;密码
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( !$conn ) {
echo "mssql数据库连接失败.<br />";
die( print_r( sqlsrv_errors(), true));
}
//查询sql
$sql = "SELECT name from test";
if (!$result = sqlsrv_query($conn, $sql)) {
die('sql 数据查询失败');
}
while ($row = sqlsrv_fetch_array($result)) {
echo $row['name'];
}
?>
php连接mssql 和 查询sql写法
最新推荐文章于 2024-08-22 15:08:14 发布