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 |
|
muhiar
Starting Member
37 Posts |
Posted - 2005-11-23 : 03:34:30
|
| hi allcan any body tell me how can i create a procedure that is called when ever a new record added to a table .this procedure allows to determine the fields and their orders and transfers that record into a text file whose name generated dynamicallyany ideas |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-23 : 03:40:42
|
| you have to call the stored procedure from the insert trigger... What do u means by fields and orders..???? Check out for this link for the inserting the data in the text file.. http://www.sqlteam.com/item.asp?ItemID=3207Hope this helps..Sucess Comes to those who Believe in Beauty of their Dream.. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-23 : 03:42:15
|
| Why do you want to call sp whenever a new record is added?Do you mean to use Trigger?To transfer data to text file use thisExec Master..xp_cmdShell 'bcp "Select columns from DBName..tableName" queryout "C:\result.txt" -c'MadhivananFailing to plan is Planning to fail |
 |
|
|
muhiar
Starting Member
37 Posts |
Posted - 2005-11-23 : 04:35:59
|
| i want a kind of triggers to do it automaticallyi want to be able to select the fields and their orders as well when i export that record to the text file |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-23 : 06:49:47
|
| Can you post the table structer for the same..???Sucess Comes to those who Believe in Beauty of their Dream.. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-23 : 08:06:33
|
| Did you try the bcp query I suggested?MadhivananFailing to plan is Planning to fail |
 |
|
|
muhiar
Starting Member
37 Posts |
Posted - 2005-11-29 : 03:59:03
|
| i have tried Exec Master..xp_cmdShell 'bcp "Select * from pubs..authors" queryout "C:\result.txt" -C -P pass'it asks me for the file stroage type of field au_id |
 |
|
|
JoshuaF
Starting Member
10 Posts |
Posted - 2005-11-29 : 05:16:52
|
| try the same but with a lower case "-c" switchExec Master..xp_cmdShell 'bcp "Select * from pubs..authors" queryout "C:\result.txt" -c -P pass'change the "pass" password if necessary.A question to add: Would it be possible to generate the text file's name dynamically? something like:Exec Master..xp_cmdShell 'bcp "Select * from pubs..authors" queryout "C:\'+cast(year(getDate()) as varchar(4))+cast(Month(getDate()) as varchar(2))+cast(day(getDate()) as varchar(2))+'result.txt" -c -P pass' |
 |
|
|
|
|
|