You are here

29 May 2012

Example how to get field types in MSSQL. You can use it on any query, even procedures.

Source code viewer
  1. // connect to mssql
  2. $link = mssql_connect($host, $username, $password);
  3. mssql_select_db($db, $link);
  4. // your query
  5. $result = mssql_query('exec procedure', $link);
  6. // fetch results
  7. while ($row = mssql_fetch_assoc($result)) {
  8. $row_count = 0;
  9. foreach($row as $k => $v) {
  10. // echo field type
  11. echo mssql_field_type($result, $row_count);
  12. $row_count++;
  13. }
  14. // after first row break (we have all necessary field types)
  15. break;
  16. }
  17. // close mssql connection
  18. mssql_close($link);
Programming Language: PHP