I'm trying to import data into a table I have created in SQL2008 Express, I've used the same scripts for other tables and they have worked, I get the following error:
Invoke-Sqlcmd : Invalid object name 'Customer'.
At D:\devinfo\Customer\PullCustEnv.ps1:23 char:14
+ Invoke-Sqlcmd <<<< -InputFile "D:\devinfo\Customer\TSQL\CSV-Import-CustDetails.sql" -verbose -ServerInstance server1
+ CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException
+ FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand
Using the following syntax:
Invoke-Sqlcmd -InputFile "D:\devinfo\Customer\TSQL\CSV-Import-CustDetails.sql" -verbose -ServerInstance server1
CSV-Import-CustDetails.sql:
USE DATA
TRUNCATE TABLE Customer
GO
BULK
INSERT Customer
FROM 'd:\test.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
The table exists and the TSQL script I have run works locally on the SQL server.
Any ideas ?