Re: execute a t-sql code from outer files



Executing the T-SQL within a file can be done with T-SQL, but really
you would probably find it easier to do it in another programming
language. The file IO features in T-SQL are fine, but when you decide
that you want to move the processed files to a different folder,
delete them, or rename them, or whatever T-SQL starts to make those
types of operations more difficult than most computer languages. You
have a line in there that says "//some code." This to me implies that
you need to execute code beyond just T-SQL. If you need to do
anything other than T-SQL or you need to do anything with the files
after they've been executed, I would suggest picking your favorite
computer language over T-SQL, but if you just want to read those files
and execute the T-SQL without changing the files, T-SQL will work.
You can execute the T-SQL via ADO.NET from any of the .NET languages.
You can bulk insert the lines in the file into a temp table, then
process the lines into a variable and execute that string in T-SQL
too. But you would probably find the programming language approach to
be the easiest.

-Eric Isaacs
www.jstreettech.com

.



Relevant Pages

  • Re: CASE (or similar) in SQL
    ... The IF-THEN-ELSE constructs in T-SQL are ... You are not writing SQL yet, just forcing your old language ... all at once" in this kind of programming. ...
    (microsoft.public.sqlserver.programming)
  • RE: ELSE UPDATE
    ... I am reviewing your post and our MVP provide some information and some ... place to check when you execute your T-SQL, ...
    (microsoft.public.sqlserver.programming)
  • Re: SqlCommand.ExecuteReader takes too much time
    ... Are you starting your "T-SQL", whatever you mean with that as the DataReader uses as well T-SQL, from the same machine as your DataReader? ... "Achim Domma" schreef in bericht ... If I execute a "select * from ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Execute SSIS Package
    ... There is no native T-SQL command to execute a package, ... I don't think executing packages from T-SQL is the best idea. ... > in SQL Server 2005 without having to go to xp_cmdshell and run DTExec? ...
    (microsoft.public.sqlserver.dts)
  • Re: How to retrieve a returned SQL function value?
    ... You can use SqlCommand to execute a T-SQL to return the value. ... > Hello, friends, ... > There is a function in SQL Server 2000, ...
    (microsoft.public.dotnet.framework.adonet)