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 |
|
khalik
Constraint Violating Yak Guru
443 Posts |
Posted - 2009-02-13 : 10:24:46
|
| Hi I need to write a SP which can generate script for a given table to a txt file. i am using SQL 2005.RegardsKhalik========================================Project Manager who loves to code.===============Ask to your self before u ask someone |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-13 : 11:08:39
|
| make use INFORMATION_SCHEMA.COLUMNS and INFORMATION_SCHEMA.TABLES view for this |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-02-13 : 11:11:47
|
| >>for a given tableDo you mean the structure or the content?Be One with the OptimizerTG |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-13 : 11:27:46
|
| http://www.databasejournal.com/features/mssql/article.php/3401081/Automating-Generate-SQL-Script.htm |
 |
|
|
khalik
Constraint Violating Yak Guru
443 Posts |
Posted - 2009-02-13 : 11:43:28
|
| thanks Visakh. me to found the same... i was testing it========================================Project Manager who loves to code.===============Ask to your self before u ask someone |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-14 : 00:56:06
|
| welcome |
 |
|
|
khalik
Constraint Violating Yak Guru
443 Posts |
Posted - 2009-02-14 : 06:24:53
|
| I am trying to execuete the sp which generates the script and get the output to a .txt file.here goes the script set QUOTED_IDENTIFIER OFFdeclare @sql varchar(8000)select @sql = 'bcp "exec sp_ScriptTable ''user@abc.com'',''CustomerTable'' " queryout E:\SyncData\DBScript.txt -w -T -x ' print @sqlexec xp_cmdshell @sqli get a error SQLState = 42000, NativeError = 2812Error = [Microsoft][SQL Native Client][SQL Server]Could not find stored procedure 'sp_ScriptTable'.NULLwhat is the issue i have the sp when i execute the sp alone works fine..exec sp_ScriptTable 'user@abc.com','CustomerTable'========================================Project Manager who loves to code.===============Ask to your self before u ask someone |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-14 : 10:50:21
|
| does the account running bcp has access to execute the stored procedure ? |
 |
|
|
|
|
|