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 |
|
Rajeswari
Starting Member
20 Posts |
Posted - 2001-12-04 : 01:06:55
|
| I provided sample user defined function,create function fn_test(@orgname varchar(200),@Renname varchar(200),@Tempname varchar(200)) returns int asbegindeclare @cmdsql varchar(250)declare @retval intset @cmdsql = 'copy ' + @orgname + ' ' + @rennameexec @retval = exec master..xp_cmdshell @cmdsqlif (@retval = 0) -----------------111beginset @cmdsql = 'del ' + @orgname exec @retval = exec master..xp_cmdshell @cmdsqlset @cmdsql = 'copy ' + @renname + '+' + @tempname + ' ' + @orgnameexec @retval = exec master..xp_cmdshell @cmdsqlendelsebeginset @cmdsql = 'copy ' + @tempname + ' ' + @orgnameexec @retval = exec master..xp_cmdshell @cmdsqlendreturn 0endif orginal file name not present in the directory, i will copy the content of temporary file to orginal file, otherwise i copy org. file to temp. file, delete the org. file, append 2 files and copy to original file. I will delete the temporary files created.I am getting return value is always 1(See the code,in the place marked, -------111). If i copy the above statements in query analyser it is returning 0 if success, if i added to the function , it not works. What's the problem in the code. |
|
|
|
|
|