Creating FILE using T-SQL

  • Can any one help me about text files creating using in the t-sql.

    provide me any script or articals regarding this.

     

    thanks in advance

    Kalai


    Kindest Regards,

    Kalai

  • Hello

    The following example writes the contents of the @var variable to a file named var_out.txt in the current server directory:

    DECLARE @cmd sysname, @var sysname

    SET @var = 'Hello world'

    SET @cmd = 'echo ' + @var + ' > var_out.txt'

    EXEC master..xp_cmdshell @cmd

    Assumptions:

    1) this requires, that you  have rights to run xp_... procedures  -sysadmin role

    2) you must enable xp_... to be called :

    sp_configure

    'Show advanced options','1'

    go

    RECONFIGURE

    go

    sp_configure

    'xp_cmdshell', '1'

    go

    RECONFIGURE

    go

    Kindest Regards,

    Damian Widera
    SQL Server MVP,
    MCT, MCSE Data Platform, MCSD.NET

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply