MS SQL Server Concepts and Programming Question:
Download Questions PDF

PHP MSSQL - How To Drop an Existing Table?

Answer:

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','GlobalGuideLine');
mssql_select_db('GlobalGuideLineDatabase', $con);

# dropping an existing table
$sql = "DROP TABLE ggl_links";
$res = mssql_query($sql,$con);
print("Table ggl_links dropped. ");

# creating a new table
$sql = "CREATE TABLE ggl_links ("
. " id INT NOT NULL"
. ", url VARCHAR(80) NOT NULL"
. ", notes VARCHAR(1024)"
. ", counts INT"
. ", time DATETIME"
. ")";
$res = mssql_query($sql,$con);
print("Table ggl_links created. ");

mssql_close($con);
?>

If you run this script, "ggl_links" will be dropped and created again:

Table ggl_links dropped.
Table ggl_links created.

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
PHP MSSQL - How To Create a New Table?PHP MSSQL - How To Insert Data into an Existing Table?