Collections:
PHP MSSQL - Inserting Data with NULL Values
PHP MSSQL - How To Insert Data with NULL Values?
✍: Guest
There are two ways to provide NULL value to a column in an INSERT statement:
The following tutorial exercise inserts two rows. Both of them have NULL values. But they were inserted differently:
<?php
$con = mssql_connect('LOCALHOST','sa','FYIcenter');
mssql_select_db('FyiCenterData', $con);
$sql = "INSERT INTO fyi_links"
. " (id, url, notes, counts, time)"
. " VALUES (101, 'dev.fyicenter.com',"
. " NULL, NULL, NULL)";
$res = mssql_query($sql,$con);
if (!$res) {
print("SQL statement failed with error:\n");
print(" ".mssql_get_last_message()."\n");
} else {
print("One data row inserted.\n");
}
$sql = "INSERT INTO fyi_links (id, url) VALUES ("
. " 102, 'dba.fyicenter.com')";
$res = mssql_query($sql,$con);
print("Another data row inserted.\n");
mssql_close($con);
?>
If you run this script, you will get:
One data row inserted. Another data row inserted.
⇒ PHP MSSQL - Inserting Multiple Rows with a Subquery
⇐ PHP MSSQL - Making Columns to Take NULL
⇑ SQL Server FAQs - PHP MSSQL Functions - Managing Tables and Data Rows
2024-02-28, 2010🔥, 0💬
Popular Posts:
How To Convert Numeric Expression Data Types using the CONVERT() Function in SQL Server Transact-SQL...
What Privilege Is Needed for a User to Delete Rows from Tables in Another Schema in Oracle? For a us...
How To Use GO Command in "sqlcmd" in SQL Server? "sqlcmd" is a command line client application to ru...
How to obtain the number of rows found by the last SELECT statement using the FOUND_ROWS() function?...
How To Count Rows with the COUNT(*) Function in SQL Server? If you want to count the number of rows,...