November 14, 2013 at 3:10 pm
I'm working on a stored procedure that I plan to use for importing a simple list from a text file. I pretty much have it figured out except that I'm getting extra information when I import the file using the bcp utility through xp_cmdshell. It displays the import information when the file is imported in addition to the items in the list. I just need to list the items imported and can ignore any other messages or errors.
Here's a sample file that I'm importing.
Item #1
Item #2
Item #3
Item #3
AND SO ON
and the code I'm testing for the sp.
USE [MYDB]
GO
IF OBJECT_ID('tempdb.dbo.tempList') IS NULL
BEGIN
CREATE TABLE tempdb.dbo.tempList (
LISTTXT VARCHAR(30)
);
END
GO
SET NOCOUNT ON;
EXEC master..xp_cmdshell 'bcp tempdb.dbo.tempList in \\mydb\LISTS\LIST.TXT -T -c '
SELECT * FROM tempdb.dbo.tempList
DROP TABLE tempdb.dbo.tempList
output from the code
output
-----------------------------------------------------------------
NULL
Starting copy...
NULL
5 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1 Average : (5000.00 rows per sec.)
NULL
LISTTXT
------------------------------
Item #1
Item #2
Item #3
Item #3
AND SO ON
Is it possible to suppress the output from the xp_cmdshell?
Thanks
November 14, 2013 at 3:17 pm
Are you seriously asking something that is clearly documented?
November 14, 2013 at 3:22 pm
I swear I've been googling 'no output' all day and couldn't find that.
Thanks
November 14, 2013 at 3:43 pm
Maybe I sound pedantic, but a good advice is to use the help included with SQL Server. Is as easy as pressing F1.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply