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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 explain

Author  Topic 

inbs
Aged Yak Warrior

860 Posts

Posted - 2008-11-25 : 05:27:53
every day i export data from DB to text file.

all i need ,to change the name of text file as i explain before.

and the job operate the dts.

how i change the name

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-25 : 05:40:32
you could use a bat file with dos commands to use this.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-25 : 05:40:56
If not a bat file, you could use dos commands with xp_cmdshell.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-25 : 05:49:14
Add a variable to dts and map it to filename property using dynamic properties task. using it you can change the name by passing a value for variable.
Go to Top of Page

inbs
Aged Yak Warrior

860 Posts

Posted - 2008-11-25 : 05:49:22
sorry,but my privious message jump.
i wrote again

how i can change the name of the file, like "file200822512 115208"
every day in the dts(tomorrow it'll look "file200822612 115208")

in addition

i wrote query that send mail, how i can write in

@attachments ='D:\FILES\file1_' + GETDATE() + '052020.txt',
the error is Line 14: Incorrect syntax near '+'.



(i wrote GETDATE() ,cause i want to send every day so , the dts
need to know to get to current file.)


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-25 : 06:02:38
where are you writing this exporession?
Go to Top of Page

inbs
Aged Yak Warrior

860 Posts

Posted - 2008-11-25 : 06:31:30
i wrote in "EXECUTE SQL TASK" -in DTS.

i didnt write akk the qurey.
but is id go like that:


exec Master.Dbo.xp_sendmail
@recipients = 'inbs@xxx.co.il',
@query = 'SELECT * FROM table1',
@attachments ='D:\FILES\file1_' + GETDATE() + '052020.txt',,
@subject = 'sent test file',
@message = @msg,
@attach_results = 'TRUE',
@width = 450,
@separator = '|'
end
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-25 : 07:29:30
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=115136

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-25 : 07:38:16
declare @filename nvarchaR(256)

set @filename = 'D:\FILES\file1_' + GETDATE() + '052020.txt'

exec Master.Dbo.xp_sendmail
@recipients = 'inbs@xxx.co.il',
@query = 'SELECT * FROM table1',
@attachments = @filename,
@subject = 'sent test file',
@message = @msg,
@attach_results = 'TRUE',
@width = 450,
@separator = '|'
end

You can't build strings when passing them as parameter values.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -