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 |
|
fireali
Starting Member
2 Posts |
Posted - 2005-06-02 : 10:58:00
|
| hi every one!I wanna update a field by the return result of a stored procedure.for example:UPDATE table1 SET field1=(EXEC xp_cmdshell 'dir');and then filed1 contains the list of directories.is it possible? how? |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-06-02 : 11:59:05
|
Since xp_cmdshell opens its own batch you'll have to use a temp table within its scope. Once you have your result in a temp you can update your existing table with the value.Something like:-- temp to hold xp_cmdshell outputcreate table #deez (value varchar(8000))-- insert output into tempinsert into #deezexec master..xp_cmdshell 'dir'-- return resultselect * from #deez-- drop tempdrop table #deez Nathan |
 |
|
|
|
|
|