Developer Network
Developer Network
Developer Network
ProfileText
ProfileText
:CreateViewProfileText:
Sign in
Subscriber portal
Get tools
Downloads
Visual Studio
SDKs
Trial software
Free downloads
Office resources
Programs
Subscriptions
Overview
Administrators
Students
Microsoft Imagine
Microsoft Student Partners
ISV
Startups
Events
Community
Magazine
Forums
Blogs
Channel 9
Documentation
APIs and reference
Dev centers
Samples
Retired content
We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second.
This forum has migrated to
Microsoft Q&A
.
Visit
Microsoft Q&A
to post new questions.
Learn More
Ask a question
Quick access
Forums home
Browse forums users
FAQ
Search related threads
Remove From My Forums
Answered by:
SQLCMD adding a text qualifier
Archived Forums 421-440
>
Transact-SQL
Question
0
Sign in to vote
How in the world do I add a text qualifier to an output result set in a csv file?
My code is as follows:
sqlcmd -S database_servername -i e:\sqldata\mysqlscript.sql -o\\shared_networkserver\directory\folder\subfolder\myoutput.CSV -s "," -W
Now that works fine except I want my result set to look like this: "fieldresult1", "fieldresult2", "fieldresult3"
Basically have them in double qoutes and separated by a comma.
Thanks in advance
Network Analyst
Tuesday, February 2, 2010 2:10 AM
Answers
1
Sign in to vote
You can add quotes in your query like this:
select '"' + isnull(column1,'') + '"', '"' + isnull(cast(column2 as varchar),'') + '"'
from t1
column2 is numeric datatype
With kind regards
Krystian Zieja
http://www.projectenvision.com
Marked as answer by
Frank Ivey
Tuesday, February 2, 2010 4:29 AM
Tuesday, February 2, 2010 2:33 AM
All replies
1
Sign in to vote
You can add quotes in your query like this:
select '"' + isnull(column1,'') + '"', '"' + isnull(cast(column2 as varchar),'') + '"'
from t1
column2 is numeric datatype
With kind regards
Krystian Zieja
http://www.projectenvision.com
Marked as answer by
Frank Ivey
Tuesday, February 2, 2010 4:29 AM
Tuesday, February 2, 2010 2:33 AM
0
Sign in to vote
Kyrstian, thanks so much
That really helped me and that was the answer i was looking for
Network Analyst
Tuesday, February 2, 2010 4:29 AM