Under other circumstances I might be tempted to use
$result = mssql_query(\"INSERT INTO table (fields) VALUES (data); SELECT CAST(scope_i
Maybe you are getting two rowsets returned. Try adding SET NOCOUNT ON; to eliminate the INSERT's rowset, or use $stmt->nextRowset if your driver supports it.