Collections:
mssql_select_db() - Selecting an Exiting Database
How To Select an Exiting Database using mssql_select_db()?
✍: Guest
The first thing after you have created a connection object to the SQL Server is to select the database where your tables are located, by using the mssql_select_db() function. If your MSSQL server is offered by your Web hosting company, they will assign an empty database to you and provide you the database name. You should use this name to select this empty database as your current database. The following script shows you how to select a database called "FyiCenterData".
To test the mssql_select_db() function, try the following script:
<?php $con = mssql_connect('LOCALHOST','sa','FYIcenter'); mssql_select_db('FyiCenterData', $con); $sql = 'SELECT * FROM sys.tables'; if ($res = mssql_query($sql, $con)) { print(mssql_num_rows($res) . " tables in database.\n"); } else { print("SQL failed.\n"); } mssql_close($con); ?>
You will get something like this:
10 tables in database.
⇒ mssql_query() - Executing SQL Statements
⇐ mssql_close() - Disconnecting from a SQL Server
⇑ SQL Server FAQs - PHP MSSQL Functions - Connections and Query Execution
2024-04-07, 1384🔥, 0💬
Popular Posts:
How To Present a Past Time in Hours, Minutes and Seconds in MySQL? If you want show an article was p...
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, y...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
What Is an Oracle Tablespace in Oracle? An Oracle tablespace is a big unit of logical storage in an ...
How To Use "IF ... ELSE IF ..." Statement Structures in SQL Server Transact-SQL? "IF ... ELSE IF ......