November 19, 2008 at 12:09 am
i have a select statement and through this select statement i want to create txt file .if is a possible give a better suggestion to me as soon as possible...thanks
November 19, 2008 at 12:12 am
pratyush.singh.chandra (11/19/2008)
i have a select statement and through this select statement i want to create txt file .if is a possible give a better suggestion to me as soon as possible...thanks
master..xp_cmdshell 'bcp master..sysobjects out c:\file.bcp -S -U -P -c '
but the path would be relative to sql server
kshitij kumar
kshitij@krayknot.com
www.krayknot.com
November 19, 2008 at 2:22 am
You could also use the sqlcmd command line utility for this - you can specify either a path on the server or use a UNC path (as long as access to the UNC path is available)
sqlcmd -S -d master -E -Q "SELECT * FROM sys.objects" "C:\MasterObjects.txt"
sqlcmd -S -d master -E -Q "SELECT * FROM sys.objects" \\UNCPath\MasterObjects.txt
sqlcmd -S -d master -E -Q "sp_help [sys.objects]" C:\sysobjects.txt
Lookup the sqlcmd syntax for details on all the options available
November 19, 2008 at 2:27 am
One more option is to use OSQL (from command line or from SQL Server with xp_cmdshell).
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
November 19, 2008 at 2:58 am
how to run this query in window authentication mode can any one give the suggestion
EXEC master..xp_cmdshell 'bcp "SELECT * FROM persondb..[company]" queryout d:\mushi.txt"" -U sa -[b]P[/b] -c -t
November 19, 2008 at 4:01 am
how to run this query in window authentication mode can any one give the suggestion
EXEC master..xp_cmdshell 'bcp "SELECT * FROM persondb..[company]" queryout d:\mushi.txt"" -U sa -P -c -t
November 19, 2008 at 4:22 am
pratyush.singh.chandra (11/19/2008)
how to run this query in window authentication mode can any one give the suggestionEXEC master..xp_cmdshell 'bcp "SELECT * FROM persondb..[company]" queryout d:\mushi.txt"" -U sa -P -c -t
Instead of using the -U and -P switches and supply the user and password, use the -T switch.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply