Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vkc12uec
Starting Member
5 Posts |
Posted - 2009-01-22 : 02:06:35
|
| We have -U -P switches for making specialised osql queries.I have a doubt that with -U , we always have "sa" ; i.e. -U -P is used whenever there is sql authentication used ( in which the user name is alwayz given "sa" )Also, does this -U corresponds to "username" of the Windows user, say John ?ie. osql -U John -P pjohn -S pool\MANDAR_SQL2K5 -u -i tmpsql.sql -o .\mssqltempfile.o.txt -I -n -w 2048Thanks in advance. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-01-22 : 07:17:28
|
http://msdn.microsoft.com/en-us/library/aa213088(SQL.80).aspxquote: Authentication switches (-E, -U, -P) that specify the credentials osql uses to connect to the instance of SQL Server. If you specify -E, osql requests a Windows Authentication connection using your current Windows login account. This is the most secure option for connecting to an instance of SQL Server.
So please understand the difference between Windows- and Userauthentication.hope that helpsWebfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-01-22 : 07:22:51
|
Example:C:\>osql -E -S SERVER -Q "select getdate()" ----------------------- 2009-01-22 13:20:30.170(1 row affected)C:\>osql -U SA -P password -S SERVER -Q "select getdate()" ----------------------- 2009-01-22 13:21:19.637(1 row affected) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
vkc12uec
Starting Member
5 Posts |
Posted - 2009-01-23 : 01:47:17
|
| Thnx Webfred for the helpAlthough, I am still having doubt that with all osql queries, the value provided for -U will be sa or can be "BUILTIN\Administrators"C:\>osql -U SA -P password -S SERVER -Q "select getdate()"C:\>osql -U JOHN -P password -S SERVER -Q "select getdate()" <<<can this be a possibility ever ? >>> |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-01-23 : 02:22:40
|
quote: C:\>osql -U JOHN -P password -S SERVER -Q "select getdate()" <<<can this be a possibility ever ? >>>
Have a look at the login properties for JOHN via SSMS.If there is set a windows authentication for JOHN then it is possible.Webfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|