|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 9:56 AM
Points: 1,882,
Visits: 1,459
|
|
Hi All,
After this: EXEC master.dbo.sp_configure 'show advanced options', 1 RECONFIGURE EXEC master.dbo.sp_configure 'xp_cmdshell', 1 RECONFIGURE
--This works
declare @str varchar(100) select @str = 'declare @i int' print @str select @str = 'ECHO ' + @str + ' >>C:\file1.txt' EXEC xp_cmdshell @str, no_output --This does not work
declare @str varchar(100) select @str = 'create table #test (ind int primary key not null, name varchar(50) )' print @str select @str = 'ECHO ' + @str + ' >>C:\file2.txt' EXEC xp_cmdshell @str, no_output
Additionally, if I want to save "print object_definition(object_id)" where object_id is an id for a view with definition longer than 8000 chars, then what is the solution to save its definition into a text file?
xp_cmdshell expects parameter 'command_string' of type 'varchar', and varchar(max) is not supported.
Thanks in advance, IgorMi
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Wednesday, May 22, 2013 6:20 PM
Points: 89,
Visits: 877
|
|
Have a look at the scripter object that is available in Powershell. This link has some details.
This would be a much better way of doing what you want.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: 2 days ago @ 8:24 AM
Points: 1,176,
Visits: 1,253
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 9:56 AM
Points: 1,882,
Visits: 1,459
|
|
Hi Guys,
Thank you for your replies! They are both useful. Albeit I'll go with the Scripter class in C#.
Regards IgorMi
|
|
|
|