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 - 2006-01-18 : 02:11:32
|
hi all i want to export data as being inserted into text file so i have created trigger after insert that select data from inserted table and echo it into text filethis works finebut i want to add '-r' and '-n'after each fieldit seems that echo does not have it???so i decided it create a global table in the after insert trigger and insert all the values in inserted table thenuse the bcp with format file but the problem is that an error says invalid object for the global table??can i use drop table ##global ????if global table does not work can i use temp table #temp instead and how???thnx |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-01-20 : 10:38:38
|
Problem is (well one of them) that the trigger works in a transaction. The table you insert into would be locked and the bcp which works on a new connection would be blocked.When you say '-r' and '-n' do you mean control characters or the four characters -r-n?I suspect it's possible with the echo if you say what you aer trying to do.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
muhiar
Starting Member
37 Posts |
Posted - 2006-01-22 : 01:55:07
|
i want to insert carriage return line feed after each field??so it is not possible by bcp???????????????????????????????how can i do it by echo???? or any other ideas |
 |
|
muhiar
Starting Member
37 Posts |
Posted - 2006-01-23 : 03:11:02
|
hi alli have tried the following codecreate trigger t1 on authorsafter insertascreate table ##t ( c varchar(2000));insert into ##t select * from inserted;set @bcpcmd = 'bcp "select * from ##t" queryout c:\t.txt -C -f c:\t1.txt'exec master..xp_cmdshell @bcpcmddrop table ##t;but when ever i insert any record it takes for ever and no thing works?????????any ideasplz help its very urgent |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-01-23 : 03:57:31
|
BCP is something that is a bad idea to do in a trigger.You should look for a different solution.CODO ERGO SUM |
 |
|
muhiar
Starting Member
37 Posts |
Posted - 2006-01-23 : 04:29:23
|
What other solution that can be done????????i used echo but echo does not support carriage return and line feedwhat shall i do???plz help |
 |
|
|
|
|