I have the following codes to drop and create views in MSSQL 7 in the same PHP page:
$link = mssql_connect($server,$user,$pwd);
$sql = "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '$view_name')
DROP VIEW $view_name";
mssql_query($sql,$link);
$sql = "CREATE VIEW $view_name
AS
SELECT id, detail FROM table_name";
mssql_query($sql,$link);
Both SQL statements run fine on SQL Query analyzer. However, when I ran them in PHP, the second query generated an error, saying : "MS SQL: Query failed on line ..."
Does anyone know what causes the error?
Any comments or advices are welcome. Thanks.