Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server Login Not Allowed Through SQLCMD 1

Status
Not open for further replies.

mickeyj2

Programmer
Jun 7, 2007
79
0
0
US
Hi,

I have SQL Server 2005 (Dev Edition) installed in my machine (Computer A). I'm using my regular desktop (Computer B) to Remote Desktop into Computer A.

I'm able to access my SQL Server databases. I'm using Windows Authentication - the same login for both machines.

I'm not a DBA by any means, and I'm trying to get familiar wtih all of the concepts as well as familiarize myself with this version of SQL Server.

From both Computer A and Computer B, I have tried the following SQLCMD. (Suppose my username and password are user and user1, respectively.)

>SQLCMD -S WYI900 -d AdventureWorks -Q "select * from Purchasing.Vendor" -U user -P user1 - ooutput.txt

The line executes, but when I check my output.txt file,
instead of data, I get the following message:

Msg 18452, Level 14, State 1
'Login failed for user 'user'. The user is not associated with a trusted SQL Server connection.'

FYI - I created this user myself using Computer B.

Does anyone have a clear, quick method with how I can accomplish this simple query?

Needless to say, when I investigate this under Microsoft's Online Books, I get a series of links to articles that delve into subject matter that seems to be irrelevant. (Not a big Microsoft fan.)

Thanks in advance for any help you can provide.

mickeyj2

 
Oh, BTW, I'm trying to still do this through SQLCMD. I know that I can run Query Analyzer in Management Studio, but that's not the route I'm investigating. Thanks.
 
Open SQL Server Management Studio
Log in with windows authentication
In 'Object Explorer' window, right click on the server name
Click Properties
Click 'Security' in the 'Select a page' section.

What is listed for 'Server authentication'? I'm guessing you have 'Windows Authentication mode'. Try changing to 'SQL Server and Windows Authentication mode'.



-George

"the screen with the little boxes in the window." - Moron
 
When using Windows Authentication you do not pass the username and password in the command line. You use -E switch.

Code:
SQLCMD -S WYI900 -d AdventureWorks -Q "select * from Purchasing.Vendor" -E - ooutput.txt

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Hi gmmastros,

That worked! It worked great. Thanks for providing such a quick and easy solution. Star for you!

I hope I can return the favor someday.

Thanks,
mickeyj2
 
Hi mrdenny,

This also worked. Thanks for the information.
I appreciate it.

mickeyj2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top