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
 General SQL Server Forums
 New to SQL Server Programming
 how to make a job in sql server 2008

Author  Topic 

immad
Posting Yak Master

230 Posts

Posted - 2014-12-15 : 02:26:58
hi,

can any one help me . how to export data in text file using sql server 2008 job.

please help me out,
thanks for the help.

immad uddin ahmed

ChinmayBairagi
Starting Member

1 Post

Posted - 2014-12-15 : 02:45:58
How can I Use one sql database use by multiple computer? I am using sql server 2008
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-12-15 : 02:57:20
Chinmay,please post your query as a separate topic.

Immad you can do it using multiple ways.
1.Openrowset
2.BCP
3.SSIS

you can then schedule script into a sql agent job.

Javeed Ahmed
https://www.linkedin.com/pub/javeed-ahmed/25/5b/95
Go to Top of Page

immad
Posting Yak Master

230 Posts

Posted - 2014-12-15 : 04:26:17
quote:
Originally posted by ahmeds08

Chinmay,please post your query as a separate topic.

Immad you can do it using multiple ways.
1.Openrowset
2.BCP
3.SSIS

you can then schedule script into a sql agent job.

Javeed Ahmed
https://www.linkedin.com/pub/javeed-ahmed/25/5b/95



Please sir send me a demo of
1.Openrowset
2.BCP
3.SSIS

thanks for the help

immad uddin ahmed
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-12-15 : 05:21:42
using BCP,it should be like this



DECLARE
@saveas VARCHAR(2048)
,@query VARCHAR(2048)
,@bcpquery VARCHAR(2048)
,@bcpconn VARCHAR(64)
,@bcpdelim VARCHAR(2)

SET @query = 'SELECT col1,col2
FROM [Table]'
SET @saveas = 'E:\one.txt'
SET @bcpdelim = '|'
SET @bcpconn = '-T'


SET @bcpquery = 'bcp "' + replace(@query, char(10), '') + '" QUERYOUT "' + @saveas + '" -c -t^' + @bcpdelim + ' ' + @bcpconn + ' -S ' + @@servername
EXEC master..xp_cmdshell @bcpquery




Javeed Ahmed
https://www.linkedin.com/pub/javeed-ahmed/25/5b/95
Go to Top of Page
   

- Advertisement -