惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
B
Blog
D
Docker
C
Check Point Blog
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
WordPress大学
WordPress大学
Jina AI
Jina AI
罗磊的独立博客
月光博客
月光博客
博客园 - Franky
L
LangChain Blog
H
Help Net Security
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
小众软件
小众软件
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - 天蝎

两岸三地在线编程学习网站 WebinoImageThumb - ZendFramework 2中操作图片的API PHP依赖管理器- Composer Local Temporary Tables and Table Variables Logging with SQL Server SQL Server Database Partitioning Myths and Truths 转载:什么是SHELL 转载:Plan freezing and other plan guide enhancements in SQL Server 2008 - 天蝎 转载:Breaking ownership chaining within a schema in SQL Server 转载:如何正确理解自动化测试技术 存储过程 SOA的设计理念 转载: The DBA as Detective: Troubleshooting Locking and Blocking 转载:锁的概述 转载: Microsoft SQL Server roles Execution plans, estimated vs actual Finding the causes of poor performance in SQL Server Enabling Dedicated Administrator Connection Feature in SQL Server 2008 .net中应用程序域的概念
Why BCP connects to SQL Server instance which start with ...
天蝎 · 2009-08-05 · via 博客园 - 天蝎

Q:
Environment: SQLEXPRESS with start account of Network Service, SQLCMD tool.
When run following BCP utility with XP_cmdshell environment, it will report login failure:    

--1, turn on 'xp_cmdshell'
use master
go

exec sp_configure 'show advanced options','1'
go

reconfigure with override
go

exec sp_configure 'xp_cmdshell', 1
go

reconfigure
go

-- 2, use AdventureWorksDW
go

CREATE TABLE [dbo].[talltypes](
 [rec] [smallint] NOT NULL,
 [cbinary] [binary](255) NULL,
 [cvbinary] [varbinary](255) NULL,
 [cchar] [char](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 [cvchar] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 [cdatetime] [datetime] NULL,
 [csmalldatetime] [smalldatetime] NULL,
 [cdecimal17] [decimal](38, 8) NULL,
 [cdecimal172] [decimal](38, 38) NULL,
 [cnumeric5] [numeric](8, 2) NULL,
 [cnumeric10] [numeric](20, 4) NULL,
 [cfloat8] [float] NULL,
 [creal] [real] NULL,
 [cint] [int] NULL,
 [csmallint] [smallint] NULL,
 [ctinyint] [tinyint] NULL,
 [cmoney] [money] NULL,
 [csmallmoney] [smallmoney] NULL,
 [ctext] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 [cimage] [image] NULL,
 [cbit] [bit] NOT NULL,
 [timestamp] [timestamp] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
go

exec master..xp_cmdshell 'bcp  AdventureWorksDW..talltypes in E:\MYAUTO~1\INSTAL~1\MSSQL1~1.SQL\MSSQL\Data\talltypes.bcp -n -T -E -SSQLPOD065-15\SQLEXPRESS'
go


A:
When you run BCP from SQL Env, using XP_CMDShell , its run in the context of Startup Account, which was Network Service and have very limited prvilage . When you run from OS ENV, its run in the context of  windows user which i assumed that a member of Administrator Group. If the server was configured mixed mode you could have passed -Usa -Ppassword instead of -T. -T is for trusted connection

Refer:

Service Account (SQL Server Express): http://msdn2.microsoft.com/en-us/library/ms143170.aspx
Security Considerations for a SQL Server Installation: http://msdn.microsoft.com/en-us/library/ms144228.aspx