Author |
Topic |
wided
Posting Yak Master
218 Posts |
Posted - 2014-02-18 : 05:19:03
|
what is the SQL instrction that allows the export of a table. csv by code and not directly from the explorer example: table1 (col1 int, col2 varchar (10), col3 decimal (15,3) |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2014-02-18 : 11:15:49
|
To interact with the file system you need something other than straight t-sql.possible options include:the Management Studio - one of the import/export wizards or results to file with specific text result options setSSIS package CLR routinethird party csv writer (possibly MS Excel)something ugly like from a dos cmd prompt use SQLCMD specifying a query, delimiter, and output file.Be One with the OptimizerTG |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
wided
Posting Yak Master
218 Posts |
Posted - 2014-02-20 : 04:32:25
|
I tried this:EXEC xp_cmdshell 'bcp "SELECT * BSIAZUR.DBO.ZANNEXE_EMP FROM " queryout "D:\manufacturer.txt" -S "AZUR-SQL8-R2\MUTUELLE" -T -c' but I have this message Msg 15281, Niveau 16, État 1, Procédure xp_cmdshell, Ligne 1SQL Server a bloqué l'accès à procédure 'sys.xp_cmdshell' du composant 'xp_cmdshell', car ce composant est désactivé dans le cadre de la configuration de la sécurité du serveur. Un administrateur système peut activer l'utilisation de 'xp_cmdshell' via sp_configure. Pour plus d'informations sur l'activation de 'xp_cmdshell', voir "Configuration de la surface d'exposition" dans la documentation en ligne de SQL Server.What should I do?Dtatabsename = BSIAZURTableName = ZANNEXE_EMP |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2014-02-20 : 04:34:56
|
ServerName = "AZUR-SQL8-R2\MUTUELLE" |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2014-02-20 : 08:47:16
|
I Locate this:RECONFIGUREGO-- To enable the feature.EXEC sp_configure 'xp_cmdshell', 1GO-- To update the currently configured value for this feature.RECONFIGUREGObut i have this message:Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51 The configuration option 'xp_cmdshell' does not exist or is an advanced option. |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2014-02-20 : 08:48:26
|
where I can find sp_configure (master, msdb..?) |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
|
wided
Posting Yak Master
218 Posts |
Posted - 2014-02-20 : 11:47:17
|
thanks |
|
|
wided
Posting Yak Master
218 Posts |
Posted - 2014-02-21 : 06:05:42
|
it is possible that the output file should be. csv with a column separator (;)? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2014-02-21 : 10:22:09
|
well you can name the file with whatever extension you want and you can format the file with any separator you want so yes, it's possible.But in my opinion by convention a file with .csv extension should actually be a csv file.Be One with the OptimizerTG |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|