exec master..xp_cmdshell ‘bcp "select c.Category_Title as 标题,p.Category_Title as 所属分类 from ltblGameStore..tbl_Category as c left join ltblGameStore..tbl_Category as p on c.Category_ParentId = p.Category_Id" queryout D:\test\Temp.xls -c -q -S"192.168.100.18" -U"sa" -P"A_123"‘
数据库使用:master
查询的sql语句中的表名要写成:数据库名..表名
导出的文件要放到文件夹下,并给这个文件夹Everyone权限