SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how to run this query in window authentication mode


how to run this query in window authentication mode

Author
Message
pratyush.singh.chandra
pratyush.singh.chandra
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 74
how to run this query in window authentication mode can any one give the suggestion

EXEC master..xp_cmdshell 'bcp "SELECT * FROM [company]" queryout d:\mushi.txt"" -U --- -P -- -c -t
edwardelliott
edwardelliott
SSC Veteran
SSC Veteran (217 reputation)SSC Veteran (217 reputation)SSC Veteran (217 reputation)SSC Veteran (217 reputation)SSC Veteran (217 reputation)SSC Veteran (217 reputation)SSC Veteran (217 reputation)SSC Veteran (217 reputation)

Group: General Forum Members
Points: 217 Visits: 351
bcp /?

usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"] [-x generate xml format file]

-T will use windows authentication (aka trusted connection)
Jerry Hung
Jerry Hung
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1410 Visits: 1208
or use SQLCMD with the -E flag?

http://msdn.microsoft.com/en-us/library/ms162773.aspx


sqlcmd
[{ { -U login_id [ -P password ] } | –E trusted connection }]
[ -z new password ] [ -Z new password and exit]
[ -S server_name [ \ instance_name ] ] [ -H wksta_name ] [ -d db_name ]
[ -l login time_out ] [ -A dedicated admin connection ]
[ -i input_file ] [ -o output_file ]
[ -f ] ]
[ -u unicode output ] [ -r [ 0 | 1 ] msgs to stderr ]
[ -R use client regional settings ]
[ -q "cmdline query" ] [ -Q "cmdline query" and exit ]
[ -e echo input ] [ -t query time_out ]
[ -I enable Quoted Identifiers ]
[ -v var = "value"...] [ -x disable variable substitution ]
[ -h headers ][ -s col_separator ] [ -w column_width ]
[ -W remove trailing spaces ]
[ -k [ 1 | 2 ] remove[replace] control characters ]
[ -y display_width ] [-Y display_width ]
[ -b on error batch abort ] [ -V severitylevel ] [ -m error_level ]
[ -a packet_size ][ -c cmd_end ]
[ -L [ c ] list servers[clean output] ]
[ -p [ 1 ] print statistics[colon format]]
[ -X [ 1 ] ] disable commands, startup script, enviroment variables [and exit]
[ -? show syntax summary ]


SQLServerNewbie

MCITP: Database Administrator SQL Server 2005
EdVassie
EdVassie
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5806 Visits: 3866
If you cannot get your query to work, try the following troubleshooting:
1) You are running a Windows command - bcp - so try running this outside SQL Server. If the command syntax is wrong, it is often easier to get diagnostic information when you run in a Command window than when you run in SQL Server.
2) When you know you have working syntax, try it in SQL Server using an account with sysadmin authority, and look at any SQL Server diagnostics. When you can get the command to work with a sysadmin account you then know you have a process that can work.
3) If you want to run the command using a non-sysadmimn account, log on using that account and try the command. Again look at the SQL Server diagnostics and fix any issues.

The use of xp_cmdshell within SQL Server 2005 or above requires some configuration. The full details are in Books Online (BOL), so I will just give an outline here.
a) Enable xp_cmdshell option within SQL Server.
b) If an account that is not sysadmin is to use xp_cmdshell, you must configure the xp_cmdshell proxy. A single xp_cmdshell proxy is used for allnon-sysadmin use of xp_cmdshell on the SQL instance, and any Windows file permisions that may be needed must be granted to the proxy account.
c) You must grant execute rights to xp_cmdshell for any account that uses it.

The xp_cmdshell proxy account must have Windows execute rights on any program folder containing the commands you execute. Often the proxy account will not have this right on the program folder containging the bcp command, so this right must be granted in Windows. For some sites you may also need to grant execute rigts to cmd.exe in the Windows \system32 folder.

Original author: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005. 14 Mar 2017: now over 40,000 downloads.Disclaimer: All information provided is a personal opinion that may not match reality.Quote: When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist. - Archbishop Hélder Câmara
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search