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

推荐订阅源

爱范儿
爱范儿
博客园 - 【当耐特】
量子位
Engineering at Meta
Engineering at Meta
博客园_首页
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
V
Visual Studio Blog
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
Jina AI
Jina AI
The Cloudflare Blog
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
博客园 - 聂微东

博客园 - 天蝎

两岸三地在线编程学习网站 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