I want to export data from a database Azur to an Excel file. To do this, i use the command :
bcp [DatabaseName].[Table] OUT C:...\Test_Export.xls -c -U [email protected] -S tcp:ServerName.database.windows.net -P xxxxxxxx
--> It Works
BUT, when i want do the same with SQL Query in the command, like this :
bcp "Select field1, Field2 FROM [dbo].[ForecastTrialDisag]" QUERYOUT C:..\Test_Export.xls -d [DataBaseName] -c -U [email protected] -S tcp:ServerName.database.windows.net -P xxxxxx
I have errors :
SQLState = 37000, NativeError = 4060 Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot open database "[DataBaseName]" requested by the login. The login failed.
SQLState = 28000, NativeError = 18456 Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'UserName'.
I don't understand why it doesn't work with a SQL query. UserName, databaseName and password are OK.
Thank you for your help,
Simon