August 25th, 2013, 02:18 PM
How do I automate extract of sql for table structures, stored proc and views?
This may be easy and I may be searching for the wrong keywords but how do I automate extract of sql for table structures, stored proc and views? I've been searching for two days now and only found one way to do it and it's not working for some reason.
unfortunately I can't figure out the error I get so if anyone knows of a way to fix this or if there's another way, I'd greatly appreciate it! Error is below:
execute xp_cmdshell 'bcp "SELECT ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES" queryout "C:\Proc_Backup.txt" -T -c -t'
August 26th, 2013, 01:58 PM
Had to add a -S server\instance at the end of the bcp statement to tell bcp where to run the query.