April 2, 2013 at 12:20 pm
DECLARE @tempOutput TABLE (
vend_num NVARCHAR(7) NULL ,
name NVARCHAR(60) NULL ,
pay_type NCHAR(1) NULL ,
check_num INT NULL ,
date DATETIME NULL ,
check_date DATETIME NULL ,
)
DECLARE @cmd VARCHAR(2048)
SET @cmd = 'bcp '
+' "SELECT * FROM @tempOutput WHERE @Severity = 0" '
+ ' queryout '
+' "c:\temp\query.txt" '
+' -T -c -t^|'
EXEC master..xp_cmdshell @cmd, NO_OUTPUT
This does not create a file.
How do i get this to work ?
April 2, 2013 at 12:33 pm
skb 44459 (4/2/2013)
DECLARE @tempOutput TABLE (vend_num NVARCHAR(7) NULL ,
name NVARCHAR(60) NULL ,
pay_type NCHAR(1) NULL ,
check_num INT NULL ,
date DATETIME NULL ,
check_date DATETIME NULL ,
)
DECLARE @cmd VARCHAR(2048)
SET @cmd = 'bcp '
+' "SELECT * FROM @tempOutput WHERE @Severity = 0" '
+ ' queryout '
+' "c:\temp\query.txt" '
+' -T -c -t^|'
EXEC master..xp_cmdshell @cmd, NO_OUTPUT
This does not create a file.
How do i get this to work ?
Convert the table variable to a permanent table. Create and populate the table prior to your call to xp_cmdshell with the BCP call, then drop the table upon return if it isn't needed anymore.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply