I’m trying to import data into a SQL table using BCP in a Powershell script, but I’m getting an error and don’t understand why.
The error is
Username not provided, either use -U to provide the user name or use -T for Trusted Connection
Windows Authentication is not an option.
Here is the code:
$server = "sqlserver.domain" $userName = "username" $pass = "password" $formatFilePath = "<path to format file>" $file = "<path to file>" bcp database.dbo.table in $file -f $formatFilePath -s $server -U $userName -P $pass