any know how to Print data through Store Procedure to the printer Directly
Print data through Store Procedure
Collapse
X
-
Tags: None
-
Try this:
[PHP]DECLARE @FileName varchar(8000), @bcpCommand varchar(8000), @PrintCommand varchar(8000)
Select @FileName = 'c:\query_resul t' + replace(convert (varchar(20), getdate()),' ','_') + '.txt'
SET @bcpCommand = 'bcp "select * from table_name" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -U uid_here -P pwd_here -c'
EXEC master..xp_cmds hell @bcpCommand
SET @PrintCommand = 'TYPE ' + @FileName + '>\\severname\p rintername'
xp_cmdshell @PrintCommand[/PHP]
Good Luck
Comment