| Author |
Topic |
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2005-12-03 : 03:37:47
|
Is there a stored procedure that will generate a SQL script of records based on my query?The script should look like this.SELECT 'A' AS A, 'B' AS Bunion allSELECT 'Aa' AS A, 'Bb' AS Bunion allSELECT 'AaA' AS A, 'BbB' AS Bunion allSELECT 'aAa' AS A, 'bBb' AS Bunion allSELECT 'AA' AS A, 'BB' AS B..... Want Philippines to become 1st World COuntry? Go for World War 3... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2005-12-03 : 05:48:56
|
| But i want to write it on a file ".sql"Want Philippines to become 1st World COuntry? Go for World War 3... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-03 : 06:06:55
|
| In the above code replace Exec(@execStr) byCreate table InsertData(data varchar(8000))Insert into InsertData Exec(@execStr)EXEC Master..xp_cmdShell 'bcp "select * from DBName..InsertData" queryout "C:\data.sql" -c'Drop table InsertDataNow open the File C:\data.sql and see the scriptMadhivananFailing to plan is Planning to fail |
 |
|
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2005-12-03 : 07:19:04
|
I had this result but there is no file created.(50 row(s) affected)output ---------------------------------------------------------------------------------------- Password: SQLState = S0002, NativeError = 208Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'DBName..InsertData'.SQLState = 37000, NativeError = 8180Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.NULL(6 row(s) affected) Want Philippines to become 1st World COuntry? Go for World War 3... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-03 : 07:23:29
|
You need to Replace DBName by the Database name you are working with MadhivananFailing to plan is Planning to fail |
 |
|
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2005-12-03 : 07:27:39
|
hihihihitnx....Want Philippines to become 1st World COuntry? Go for World War 3... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-03 : 07:28:58
|
Did you get what you tried to get? MadhivananFailing to plan is Planning to fail |
 |
|
|
jonasalbert20
Constraint Violating Yak Guru
300 Posts |
Posted - 2005-12-03 : 07:32:19
|
| [code]SELECT 'A' AS A, 'B' AS Bunion allSELECT 'Aa' AS A, 'Bb' AS Bunion allSELECT 'AaA' AS A, 'BbB' AS Bunion allSELECT 'aAa' AS A, 'bBb' AS Bunion allSELECT 'AA' AS A, 'BB' AS B[/code]Is it possible to put this output into the ".sql" file? Result should be like that.Want Philippines to become 1st World COuntry? Go for World War 3... |
 |
|
|
|