16

How can I run commands, passed to sqlcmd, as currently logged on user automatically i.e without having to enter username and password?

I want to use Windows Authentication only. It is a local server.

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
Aashiq Hussain
  • 543
  • 2
  • 8
  • 17
  • can you set up a scheduled task to run as a specific user? If so, I think the -E argument with sqlcmd is what you are looking for. – Jeremy Holovacs Mar 29 '13 at 10:56
  • 1
    Solution: go to Google, search for `SQL Server SQLCMD`, pick the first link which leads you to the [**official MSDN documentation** for `SQLCMD`](http://msdn.microsoft.com/en-us/library/ms162773.aspx), read the docs, see that you need to use `-E` for integrated security - was that so hard? – marc_s Mar 29 '13 at 11:26
  • 8
    @marc_s it does imply that you know that Windows Authentication == Integrated Security == Trusted Connection, which is not necessarily obvious. – Jeremy Holovacs Oct 07 '13 at 19:18

1 Answers1

24

sqlcmd takes the -E argument, which means, "Use Trusted Connection"... IOW, your windows credentials.

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

Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254