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 |
boonboon
Starting Member
5 Posts |
Posted - 2013-10-10 : 01:48:02
|
i able to run this successfully in my sql jobdeclare @sql varchar(8000)select @sql = 'bcp "SELECT* FROM [NTUCHC-LIVE].[dbo].[Shelflabel_Promotion_ESL]" queryout F:\PDT\ESL-Promotion.csv -c -t, -T -S' + @@servernameexec master..xp_cmdshell @sqlbut I hit error when I try to run this.. is there anything went wrong? pls advise.. thanks!declare @sql varchar(8000)select @sql = 'bcp "SELECT[No_] ,[PLU] ,[Item Family Description] ,[Description] ,[Description 2] ,[Remarks] ,[Offer Price] ,[Usual Price] ,[Quantity] ,[Starting Date] ,[Ending Date] ,[HSA Code] ,[Type] FROM [NTUCHC-LIVE].[dbo].[Shelflabel_Promotion_ESL] Where [Price Group] = 'TPO' OR [Price Group] = 'ALL'" queryout F:\PDT\ESL-Promotion.csv -c -t, -T -S' + @@servernameexec master..xp_cmdshell @sql |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-10 : 03:58:56
|
yes. you've escape those single quotes coming inside.likedeclare @sql varchar(8000)select @sql = 'bcp "SELECT[No_],[PLU],[Item Family Description],[Description],[Description 2],[Remarks],[Offer Price],[Usual Price],[Quantity],[Starting Date],[Ending Date],[HSA Code],[Type]FROM [NTUCHC-LIVE].[dbo].[Shelflabel_Promotion_ESL] Where [Price Group] = ''TPO'' OR [Price Group] = ''ALL''" queryout F:\PDT\ESL-Promotion.csv -c -t, -T -S' + @@servernameexec master..xp_cmdshell @sql ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
boonboon
Starting Member
5 Posts |
Posted - 2013-10-17 : 07:52:08
|
quote: Originally posted by visakh16 yes. you've escape those single quotes coming inside.likedeclare @sql varchar(8000)select @sql = 'bcp "SELECT[No_],[PLU],[Item Family Description],[Description],[Description 2],[Remarks],[Offer Price],[Usual Price],[Quantity],[Starting Date],[Ending Date],[HSA Code],[Type]FROM [NTUCHC-LIVE].[dbo].[Shelflabel_Promotion_ESL] Where [Price Group] = ''TPO'' OR [Price Group] = ''ALL''" queryout F:\PDT\ESL-Promotion.csv -c -t, -T -S' + @@servernameexec master..xp_cmdshell @sql ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
it did not prompt any error but the file did not export out. any ideas why? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-17 : 08:14:00
|
do you've access to the path specified? Is it local machine path?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-17 : 08:15:57
|
try running this from command line and see if you get any error messagebcp "SELECT[No_],[PLU],[Item Family Description],[Description],[Description 2],[Remarks],[Offer Price],[Usual Price],[Quantity],[Starting Date],[Ending Date],[HSA Code],[Type]FROM [NTUCHC-LIVE].[dbo].[Shelflabel_Promotion_ESL] Where [Price Group] = 'TPO' OR [Price Group] = 'ALL'" queryout "F:\PDT\ESL-Promotion.csv" -c -t, -T -S <YourServerName> ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|