--**************************************
-- Name: Read a text file into SQL SERVER
--
-- Description:Using BULK INSERT TO READ
-- A TEXT FILE into SQL SERVER and ELIMINATING
-- THE USE of another text editor.
-- By: Eli Leiba
--
-- Inputs:@filename sysname (filename includes path)
--
-- Returns:a recordset of the file lines in QUERY analyzer
--
-- Assumes:Usage :
EXEC sp_readTextFile 'c:\autoexec.bat'
--
--This code is copyrighted and has limited warranties.
--Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=359&lngWId=5
--for details.
--**************************************
--
CREATE PROC sp_readTextFile @filename sysname
as
BEGIN
SET nocount ON
CREATE TABLE #tempfile (line varchar(8000))
EXEC ('bulk INSERT #tempfile FROM "' + @filename + '"')
SELECT * FROM #tempfile
DROP TABLE #tempfile
END
GO

在你的C盘写一个txt文件,然后试试这个:
create table test(id int identity,txt varchar(8000))
insert into test(txt) exec master..xp_cmdshell 'type c:\a.txt'
--update,delete,or insert test表
exec master..xp_cmdshell 'bcp
"select txt from 数据库名..test order by id"
queryout c:\a.txt -c -S 服务器名 -U sa -P 密码'