Collections:
mssql_field_name() - Retrieve Field Names
How To List All Field Names in the Result Set using mssql_field_name()?
✍: Guest
The result set object returned by a SELECT statement also contains column (field) names, lengths and types. You can use mssql_field_name(), mssql_field_length() and mssql_field_type() to get those information. The tutorial exercise below shows a good example:
$con = mssql_connect('LOCALHOST','sa','FYIcenter');
mssql_select_db('FyiCenterData', $con);
$sql = "SELECT * FROM sys.objects"
. " WHERE type_desc='USER_TABLE'";
$res = mssql_query($sql, $con);
print("Result set columns:\n");
for ($i=0; $i<mssql_num_fields($res); $i++) {
print(" ".mssql_field_name($res,$i));
print(", ".mssql_field_type($res,$i));
print(", ".mssql_field_length($res,$i)."\n");
}
mssql_free_result($res);
mssql_close($con);
Run this PHP script, you will see a list columns (fields):
Result set columns: name, char, 255 object_id, int, 4 principal_id, int, 4 schema_id, int, 4 parent_object_id, int, 4 type, char, 2 type_desc, char, 120 create_date, datetime, 8 modify_date, datetime, 8 is_ms_shipped, bit, 1 is_published, bit, 1 is_schema_published, bit, 1
⇒ SQL Server FAQs - PHP MSSQL Functions - Managing Tables and Data Rows
⇐ mssql_result() - Retrieve Field Values
⇑ SQL Server FAQs - PHP MSSQL Functions - Connections and Query Execution
2024-03-23, 2021🔥, 0💬
Popular Posts:
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...
How To List All Login Names on the Server in SQL Server? If you want to see a list of all login name...
How To Select All Columns of All Rows from a Table with a SELECT statement in SQL Server? The simple...
How To Replace Given Values with NULL using NULLIF() in SQL Server Transact-SQL? Sometime you want t...