Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

running tsql from filetable Expand / Collapse
Author
Message
Posted Friday, October 11, 2013 11:21 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 23, 2014 2:27 PM
Points: 132, Visits: 910
I have used the filetable to store the tsql scripts. what can be the best way to run them against the server. the only road block i have using the exec(@sql) or execute_sql (@command) is the 'GO' statement in the filetable script.
Any help will be appriciated. Thanks
Post #1504106
Posted Friday, October 11, 2013 3:22 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:58 PM
Points: 36,794, Visits: 31,253
AK1516 (10/11/2013)
I have used the filetable to store the tsql scripts. what can be the best way to run them against the server. the only road block i have using the exec(@sql) or execute_sql (@command) is the 'GO' statement in the filetable script.
Any help will be appriciated. Thanks


Take the GO out. It won't work with EXEC or EXECUTE_SQL. If the GO is important to the success of the script, then you will need to split the script at the GO and execute each section separately.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1504148
Posted Friday, October 11, 2013 3:43 PM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, July 28, 2014 4:49 AM
Points: 556, Visits: 2,581
I have used the filetable to store the tsql scripts. what can be the best way to run them against the server. the only road block i have using the exec(@sql) or execute_sql (@command) is the 'GO' statement in the filetable script.
Any help will be appriciated. Thanks


There are different methods for querying the contents of a document stored in a filetable. I haven't done it personally but have seen Sam Nasr do it (SQL Saturday Detroit ). Sam Nasr has some articles out there about this.

That said, what you are doing sounds like a bad idea to me. Filetables are not intended to for storing documents that contain scripts (SQL or other) that are executed directly from the filetable. The idea of a file on a file share (secured or otherwise) with scripts that can be executed from inside SQL Server. That sounds scary for too many reasons to detail in one post.


-- Alan Burstein



Read this article for best practices on asking questions.
Need to split a string? Try this (Jeff Moden)
Need a pattern-based string spitter? Try this (Dwain Camps)
My blog
Post #1504157
Posted Saturday, October 12, 2013 9:10 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:58 PM
Points: 36,794, Visits: 31,253
And with that and the fact that I've seen many people try to do the same thing, I guess now would be a great time to ask...

... what's wrong with using stored procedures, etc, instead of all this saving of scripts either in a file or in a table? It just doesn't make sense to me to do such a thing.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1504208
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse