• Okay Thanks a lot For your help.

    Here is the working solution I created

    DECLARE @FileName varchar(50),

    @bcpCommand varchar(2000)

    SET @FileName = 'c:\dod\authors_06-04-14.doc' --REPLACE('c:\dod\authors_'+CONVERT(char(8),GETDATE(),1)+'.doc','/','-')

    PRINT @FileName

    SET @bcpCommand = 'C:\"Program Files"\"Microsoft SQL Server"\90\Tools\binn\bcp.exe "SELECT DocData FROM db.schema.table WHERE DocId = 1" queryout "'

    SET @bcpCommand = @bcpCommand + @FileName + '" -S Server -c -T'

    EXEC master..xp_cmdshell @bcpCommand

    Here is the output I can see, in SSMS Results pane,

    NULL

    Starting copy...

    NULL

    1 rows copied.

    Network packet size (bytes): 4096

    Clock Time (ms.) Total : 79 Average : (12.66 rows per sec.)

    NULL

    But when I try to open the pdf file it gives me error.

    At the same time when I run the same command from CMD line it works fine and I can open the pdf file as well.

    Also file size is 134 KB from cmd line but its 234 KB from SQL Query.

    Any suggestion why??