Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kgundava
Yak Posting Veteran
66 Posts |
Posted - 2011-07-12 : 18:19:59
|
| Hi All, I am trying to write to a file from sql server 2008 R2 using xp_cmdshell.Every thing seems to work fine except that when i try to write a numeric value to a file the program throws up an error Msg 8114, Level 16, State 5, Line 33Error converting data type varchar to bigint. Please see the code below set @SRCRCNT = (SELECT SourceCnt from dbo.PROGRAMDELTA where SourceTable = @SRCTBLNAM) set @TRGTRCNT = (SELECT TargetCnt from dbo.PROGRAMDELTA where SourceTable = @SRCTBLNAM) set @VARROWVALUE = (SELECT Delta from dbo.PROGRAMDELTA where SourceTable = @SRCTBLNAM) SET @cmd_ROWVAR1 = 'echo' + @LABEL3 + '' + @SRCRCNT + '' + @LABEL3 + '' + @TRGTRCNT + '' + @LABEL4 + ' ' + @VARROWVALUE + '>> E:\Deltaprogram_Report.txt' EXEC master..xp_cmdshell @cmd_ROWVAR1 I know this is due to @TRGTRCNT,@SRCRCNT,@VARROWVALUE which are intended to store numeric values. I defined them as BIGINT.Please let me know if this can be fixed.Thanks,Krishna |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2011-07-12 : 18:22:39
|
| use a convert function to convert the int to varchar for concatenating..Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
kgundava
Yak Posting Veteran
66 Posts |
Posted - 2011-07-12 : 20:06:05
|
| Thanks a lot for the fast reply. It worked. |
 |
|
|
|
|
|