Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BCP issue with SQL Server 2005

Status
Not open for further replies.

sendba

Programmer
Sep 7, 2005
113
US
Hi all,

I am having some issues with BCP in SQL SERVER 2005.
Can some one help me please.


CREATE TABLE ##t1 (id int identity(1,1) , records VARCHAR(8000), get_date datetime default getdate())
CREATE TABLE ##t2(records VARCHAR(8000))

insert into ##t2
select records from ##t1
order by id asc


declare @temp varchar(250)
set @temp = 'bcp ##t2 out '+@tablename +' -c -t"," -T'
exec master..xp_cmdshell @temp


The table contains a comnination of numbers and varchar.
the first character starts as a Character.

The BCP file is not in order.

Please help
 
The only way to ensure that the file is in the order that you want it is to put a select statement in the BCP command with an ORDER BY clause and change the "OUT" to "QUERY OUT"

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top