SQL Server Performance

BCP out query

Discussion in 'SQL Server 2005 General Developer Questions' started by starwarsbigbang, Mar 31, 2008.

  1. starwarsbigbang New Member

    Is is possible to do bcp out data from a table based on where condition........say for example from an employee table can I bcp out data for only 'Human Sciences' department ?
  2. madhuottapalam New Member

    Yes its possible. CHeck QUERYOUT of BCP
    From BOL
    To copy a specific row, you can use the queryout option. The following example copies only the row for the contact named Jarrod Rana from the AdventureWorks.Person.Contact table into a data file (Jarrod Rana.dat). The example assumes that you are using Windows Authentication and have a trusted connection to the server instance on which you are running the bcp command.
    At the Windows command prompt, enter:
    bcp "SELECT * FROM AdventureWorks.Person.Contact WHERE FirstName='Jarrod' AND LastName='Rana' " queryout "Jarrod Rana.dat" -T -c

Share This Page