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!

space separated in sqlserver 2000

Status
Not open for further replies.

jrprogr

Programmer
Jul 20, 2006
74
US
I want to export the data to a file with space separated.

Ex:
Location Length
-------- ------
Col1value 1 10
Column2 12 2
Col3value 18 3

Please help me.I did tried by enabling in the tools- options-results tab.
 
Make your query look like this...

[tt][blue]
Select Left(Col1Value + Replicate(' ', 10), 10)
+ Left(Column2 + Replicate(' ', 2), 2)
+ Left(Col3Value + Replicate(' ', 3), 3)
From TableName
[/tt][/blue]

If any of the columns have a data type other than varchar, then you should first convert the value to varchar in the query.

Then, in query analyzer, Query -> Results To File just before you run it. When you run the query, you will be prompted with a file name.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Use BCP. It's made for exporting data.

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)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top