Collections:
PHP MSSQL - Dropping an Existing Table
PHP MSSQL - How To Drop an Existing Table?
✍: Guest
If you need to delete a table created before, you can run the DROP TABLE SQL statement using the mssql_query() function, as shown in the following sample script:
<?php
$con = mssql_connect('LOCALHOST','sa','FYIcenter');
mssql_select_db('FyiCenterData', $con);
# dropping an existing table
$sql = "DROP TABLE fyi_links";
$res = mssql_query($sql,$con);
print("Table fyi_links dropped.\n");
# creating a new table
$sql = "CREATE TABLE fyi_links ("
. " id INT NOT NULL"
. ", url VARCHAR(80) NOT NULL"
. ", notes VARCHAR(1024)"
. ", counts INT"
. ", time DATETIME"
. ")";
$res = mssql_query($sql,$con);
print("Table fyi_links created.\n");
mssql_close($con);
?>
If you run this script, "fyi_links" will be dropped and created again:
Table fyi_links dropped. Table fyi_links created.
⇒ PHP MSSQL - Inserting Data into an Existing Table
⇐ PHP MSSQL - Creating a New Table
⇑ SQL Server FAQs - PHP MSSQL Functions - Managing Tables and Data Rows
2024-03-07, 1840🔥, 0💬
Popular Posts:
How To Disable a Login Name in SQL Server? If you want temporarily disable a login name, you can use...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How To Install Oracle Database 10g XE in Oracle? To install 10g universal edition, double click, Ora...
How Fixed Length Strings Are Truncated and Padded in SQL Server Transact-SQL? When the length of the...
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPA...