From: big on
Hi,
on MS SQL server 2005, I receive the following error :

bcp PSOPRDEFN format nul -T -c -f C:/somefile.fmt

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'format'.


Any idea ?

Thank you.
From: John Bell on
On Thu, 3 Jun 2010 03:40:51 -0700, big <big(a)discussions.microsoft.com>
wrote:

>Hi,
>on MS SQL server 2005, I receive the following error :
>
>bcp PSOPRDEFN format nul -T -c -f C:/somefile.fmt
>
>Msg 102, Level 15, State 1, Line 1
>Incorrect syntax near 'format'.
>
>
>Any idea ?
>
>Thank you.

You need to correctly name the table using a 3 part name e.g.


bcp AdventureWorks.Sales.Currency format nul -T -c -f Currency.fmt

John
From: Erland Sommarskog on
big (big(a)discussions.microsoft.com) writes:
> on MS SQL server 2005, I receive the following error :
>
> bcp PSOPRDEFN format nul -T -c -f C:/somefile.fmt
>
> Msg 102, Level 15, State 1, Line 1
> Incorrect syntax near 'format'.
>
>
> Any idea ?

Seems like you are running this from a query window. BCP is a command-line
tool, so you should run it from a Command Prompt.

Once you have come that far, you need to specify the table with
database and schema as John pointed out.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

From: big on
Thanks to all.
should it be :
bcp servername.databasename.tablename format nul -T -c -f C:/somefile.fmt

Then I did but:

C:\Documents and Settings\Administrateur>bcp MYSERVER.MYDB.PSOPRDEFN format
nul -T -c -f C:/somefile.fmt
SQLState = 28000, NativeError = 18456
Error = [Microsoft][SQL Native Client][SQL Server]Login failed for user
'MYDOMAIN\Administrateur'.
SQLState = 42000, NativeError = 4060
Error = [Microsoft][SQL Native Client][SQL Server]Cannot open database
"MYSERVER" requested by the login. The login fail


Regards.

"Erland Sommarskog" wrote:

> big (big(a)discussions.microsoft.com) writes:
> > on MS SQL server 2005, I receive the following error :
> >
> > bcp PSOPRDEFN format nul -T -c -f C:/somefile.fmt
> >
> > Msg 102, Level 15, State 1, Line 1
> > Incorrect syntax near 'format'.
> >
> >
> > Any idea ?
>
> Seems like you are running this from a query window. BCP is a command-line
> tool, so you should run it from a Command Prompt.
>
> Once you have come that far, you need to specify the table with
> database and schema as John pointed out.
>
>
> --
> Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se
>
> Links for SQL Server Books Online:
> SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
> SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
>
> .
>
From: Erland Sommarskog on
big (big(a)discussions.microsoft.com) writes:
> Thanks to all.
> should it be :
> bcp servername.databasename.tablename format nul -T -c -f C:/somefile.fmt

No, it should be

database.schema.tablename

> Then I did but:
>
> C:\Documents and Settings\Administrateur>bcp MYSERVER.MYDB.PSOPRDEFN
> format
> nul -T -c -f C:/somefile.fmt
> SQLState = 28000, NativeError = 18456
> Error = [Microsoft][SQL Native Client][SQL Server]Login failed for user
> 'MYDOMAIN\Administrateur'.
> SQLState = 42000, NativeError = 4060
> Error = [Microsoft][SQL Native Client][SQL Server]Cannot open database
> "MYSERVER" requested by the login. The login fail

Exactly what the error message says. There is no database MYSERVER on
your server.

--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx