• well nothing gets printed out, because of that error in syntax.

    I shall add the sql agent job though. thanks.

    Is there an easier way to extract columns form tables and dump them into a single text file, without using the command prompt- ?

    when i do the SP below, i get more than 32 statements stating 13 rows affected followed by the error :- Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

    CREATE Procedure BCP_Text_File

    (

    @table varchar(100),

    @FileName varchar(100)

    )

    as

    If exists(Select * from information_Schema.tables where table_name=@table)

    Begin

    Declare @STR varchar(1000)

    set @STR='Exec Master..xp_Cmdshell ''bcp "Select * from '+db_name()+'..'+@table+'" queryout "'+@FileName+'" -c'''

    Exec(@str)

    end

    else

    Select 'The table '+@table+' does not exist in the database'

    EXEC BCP_Text_File 'userreminder','C:\test.txt'

    Your input would be greatly appreciated.