tsql - Write out to text file using T-SQL -
i creating basic data transfer task using tsql retrieving records 1 database more recent given datetime value, , loading them database. happen periodically throughout day.
it's such small task ssis seems overkill - want use scheduled task runs .sql file.
where need guidance need persist datetime last run of task, use filter records next time task runs. initial thought store datetime in text file, , update (overwrite) part of task each time runs.
i can read file in without problems using t-sql, writing out has got me stuck. i've seen plenty of examples make use of dynamically-built bcp command, executed using xp_cmdshell. trouble is, security on server i'm deploying precludes use of xp_cmdshell.
so, question is, there other ways write datetime value file using tsql, or should thinking different approach?
edit: happy corrected ssis being "overkill"...
you can build small app or cmd file wraps start of sql script scheduler. in app can store date , time in file read sql script next time loaded.
i sure can done better show idea, here content of command file use. read content of datetime.txt yourscript.sql
sqlcmd yourscript.sql sqlcmd -q"select getdate()" -o datetime.txt
Comments
Post a Comment