I have a large csv file (over 100,000 lines) encoded in UTF-8-BOM that looks like this:
27336;00203-AND1;90-BLACK;9.5;2
27336;00203-ET1;90-BLACK;10;1
27336;00203-ET1;90-BLACK;12;1
...
And a table in my SQL Server database with these columns :
storenumber | stylecode | colour | size | units | timestamp
I use Bulk Insert Data to load the file at once, but I would like to add my $timestamp variable to each line inserted in my table but it doesn't work... How do I do it?
<?php
include("connexion.php");
ini_set('max_execution_time', 32400);
$timestamp= date("y-m-d H:i");
$csv= "D:/xampp/htdocs/retail_BI/files/BI2_20200720_1344_00076.txt";
$query = "BULK INSERT dbo.Y2_Inventory
FROM '$csv'
WITH (
FIELDTERMINATOR = ';',
ROWTERMINATOR = '\n',
ERRORFILE = 'myfileerror.log'
)";
$stmt = $conn->query( $query );
if (!$stmt) { echo $conn->error;}
$query2 = "UPDATE dbo.Y2_Inventory SET timestamp = ? WHERE timestamp IS NULL";
$stmt = $conn->query( $query2 );
echo "good";
?>