run bcp in command promt and query analyzer **

run bcp in command promt and query analyzer **

Post by marya » Mon, 04 Feb 2002 19:53:35



Hi

I run following code at command promt with successfully result
c:\program files\...\binn> bcp qq.dbo.t1 in i:\q.txt -Ssystem109  -c -Usa -P -CRAW -t,

but that one in query analyzer made an error following the one:

exec xp_cmdshell    'bcp qq.dbo.t1 in i:\q.txt -Ssystem109  -c -Usa -P -CRAW -t,';

Password:
SQLState = 28000, NativeError = 18452
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
NULL

what's wrong in 2th mode?
Thanks
Maryam

 
 
 

run bcp in command promt and query analyzer **

Post by lindawi » Tue, 05 Feb 2002 02:36:52


Maryam,

When you run bcp from a command prompt, it connects to SQL Server using the
login and password you supply. When you shell out bcp from Query Analyzer,
xp_cmdshell must first connect to SQL Server using it's own security
context. From Books Online:

"When xp_cmdshell is invoked by a user who is a member of the sysadmin fixed
server role, xp_cmdshell will be executed under the security context in
which the SQL Server service is running. When the user is not a member of
the sysadmin group, xp_cmdshell will impersonate the SQL Server Agent proxy
account, which is specified using xp_sqlagent_proxy_account. If the proxy
account is not available, xp_cmdshell will fail. This is true only for
Microsoft? Windows NT? 4.0 and Windows 2000. On Windows 9.x, there is no
impersonation and xp_cmdshell is always executed under the security context
of the Windows 9.x user who started SQL Server."

Perhaps in your case the SQL Server service is running under an account that
is not in the local administrators group, and you are not a member of the
sysadmin role.

Linda


> Hi

> I run following code at command promt with successfully result
> c:\program files\...\binn> bcp qq.dbo.t1 in

i:\q.txt -Ssystem109  -c -Usa -P -CRAW -t,
Quote:

> but that one in query analyzer made an error following the one:

> exec xp_cmdshell    'bcp qq.dbo.t1 in

i:\q.txt -Ssystem109  -c -Usa -P -CRAW -t,';
Quote:

> Password:
> SQLState = 28000, NativeError = 18452
> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for

user '(null)'. Reason: Not associated with a trusted SQL Server connection.
Quote:> NULL

> what's wrong in 2th mode?
> Thanks
> Maryam


 
 
 

run bcp in command promt and query analyzer **

Post by marya » Tue, 05 Feb 2002 15:08:45


Linda I login with sa in Query analyzer as the same as login in bcp.
and sa is member of sysadmin.
so what's wrong?

> Maryam,

> When you run bcp from a command prompt, it connects to SQL Server using the
> login and password you supply. When you shell out bcp from Query Analyzer,
> xp_cmdshell must first connect to SQL Server using it's own security
> context. From Books Online:

> "When xp_cmdshell is invoked by a user who is a member of the sysadmin fixed
> server role, xp_cmdshell will be executed under the security context in
> which the SQL Server service is running. When the user is not a member of
> the sysadmin group, xp_cmdshell will impersonate the SQL Server Agent proxy
> account, which is specified using xp_sqlagent_proxy_account. If the proxy
> account is not available, xp_cmdshell will fail. This is true only for
> Microsoft? Windows NT? 4.0 and Windows 2000. On Windows 9.x, there is no
> impersonation and xp_cmdshell is always executed under the security context
> of the Windows 9.x user who started SQL Server."

> Perhaps in your case the SQL Server service is running under an account that
> is not in the local administrators group, and you are not a member of the
> sysadmin role.

> Linda


> > Hi

> > I run following code at command promt with successfully result
> > c:\program files\...\binn> bcp qq.dbo.t1 in
> i:\q.txt -Ssystem109  -c -Usa -P -CRAW -t,

> > but that one in query analyzer made an error following the one:

> > exec xp_cmdshell    'bcp qq.dbo.t1 in
> i:\q.txt -Ssystem109  -c -Usa -P -CRAW -t,';

> > Password:
> > SQLState = 28000, NativeError = 18452
> > Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for
> user '(null)'. Reason: Not associated with a trusted SQL Server connection.
> > NULL

> > what's wrong in 2th mode?
> > Thanks
> > Maryam

 
 
 

1. Command-line options for running SQL Query Analyzer (SQL 2000)

I'm trying to create a batch file that will, upon running, open up an
instance of SQL Query Analyzer, and pass it the necessary information
(server name, database name, user ID, and password).

Unfortunately, I'm not having much luck. This is what I have so far (the
names have been changed to protect the innocent, of course... ;)  ):

"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\isqlw.exe" -s
SQLSvr1 -d Database1 -E -U MyUserID -P password

Unfortunately, when I try this, it seems to open up a Query analyzer window,
but it gives me an error that says "[Microsoft][ODBC SQL Server
Driver][Shared Memory]SQL Server does not exist or access denied.

However, I have verified that the server name, database name, user ID, and
password are all valid (if I use them to manually connect within Query
Analyzer, it all works fine).

What am I missing here?

Thanks!

2. S0S - Sql query

3. BCP query out executed by xp_cmdshell works fine from query analyzer but fails from VB Component

4. copy diagrams from orginal database

5. Error running SP as Job but not when run from Query Analyzer

6. How to drop secondary data files

7. Running SQL Query outside Query Analyzer

8. Bad timestamp external representation

9. Slow query execution through JDBC - runs fast in Query Analyzer

10. how to write XML Format Query to run in SQL Server Query Analyzer

11. Opening a DTS package file from command promt

12. Login to osql at command promt