NeoPa 32,557
Recognized Expert Moderator MVP
I am looking to piece together a few T-SQL scripts into a single script in a way similar to the c "include BlahBlah.H" feature.
I've searched Online books and Googled but everything comes up with solutions that invoke an external script via OSQL or ISQL rather than a continuation of inline code (which is what I'm after).
It may well be that the reason is that this is not a supported feature. If so, please let me know. My experience level is that I get to play in here once every two or three years, so I get quite rusty.
If there is a more helpful answer that's fine too of course, but I'd like the view of someone with the current experience :)
12 18037 NeoPa 32,557
Recognized Expert Moderator MVP
I found http://bytes.com/groups/ms-sql/83051...call-sql-files in the archives. I suspect this means there is no support for this idea in T-SQL.
If anyone knows anything to the contrary then please post. Otherwise, I suspect this question can be considered to be answered.
Plater 7,872
Recognized Expert Expert
Could you save them as stored procedures and call them that way?
NeoPa 32,557
Recognized Expert Moderator MVP
I suppose if I got my thinking around how SQL Server generally works, that would be the best solution. I'm coming at it from a sort of different mind-set (file system based) because I'm not in SQL Server mode at the moment.
I think that is actually the logical solution. Thanks Plater :)
ck9663 2,878
Recognized Expert Specialist
That's actually the answer to your question. In C, the compiled program will not be able to see other module that are not included during compilation. Unless it's another executable that you want to call.
In SQL Server, once the function or stored proc is created, and you have the necessary rights, you can use it. If there are multiple copies of these modules in separate database or even within the database but of different owner, qualifying the call will allow you to use it.
-- CK
Plater 7,872
Recognized Expert Expert
I *am* curious how you would actually use a set of results returned from a stored procedure.
I cannot seem to find a way to use a SELECT statement on it, so unless it returns a scaler, how can it be used?
ck9663 2,878
Recognized Expert Specialist
Depending on what value want returned. You can either use a ReturnCode technique or use a Return Parameter (aka pass by reference) or use a Function instead of stored proc.
Happy Coding.
-- CK
Plater 7,872
Recognized Expert Expert
So there is no way to use a SELECT statement on a stored procedure results (it makes sense I guess since you never know what will be returned, one result set, two sets, etc etc)?
ck9663 2,878
Recognized Expert Specialist
Could you give an example of what you're trying to do?
-- CK
Plater 7,872
Recognized Expert Expert
Well for instance in a number of queries i have a sub query like:
SomeColumn in (SELECT SomeSimilarColumn FROM SomeTable WHERE (conditions) )
And it would be nice to have that elsewhere so if I make changes to it, everything that uses it is all set.
That sounds like a function I guess except that the subquery has been known to take parameters from its encompassing stored procedure.
Such as -
-
WHERE
-
(
-
@myParam = 1 AND (conditions)
-
OR
-
(some other conditions)
-
)
-
NeoPa 32,557
Recognized Expert Moderator MVP
I'm not at work today so I can't check this very easily (and I'm rusty as I mentioned), but I think a Stored Procedure is some code which doesn't return a value at all. Like a subroutine, but not a function.
If returned values are required, then a User Defined Function is required and that can return SELECTed results as a cursor if necessary. Otherwise it can return scalar values in more ordinary formats (int; bigint; nvarchar; etc; etc).
Please correct me if I'm wrong. I certainly could be, but that's my understanding.
ck9663 2,878
Recognized Expert Specialist
A function can return a value like this: -
-
if MyFunction(@myparameter) = Value
-
-
or multiple values that could act like a table like this: -
-
select column1, column2, column3 from MyFunction(@myparameter)
-
-
If you need the value of these columns as returned like a table, you can either use a cursor or some other technique to process each row and column.
As always, your function could be a single or a group of t-sql statements and, yes, you change it once and everything that uses it gets affected.
Hope I make sense :)
-- CK
Plater 7,872
Recognized Expert Expert
Hmmm.
I have quite a few stored procedures that do this: -
WHERE
-
(--
-
(
-
@IDNumber in
-
(
-
SELECT WO.OwnerID
-
FROM WebOwnership as WO
-
WHERE WO.IDType='PowerUser'
-
)
-
OR
-
T.Zone in
-
(--Only the correct zone(s)?
-
SELECT O.IDString
-
FROM WebOwnership as O
-
WHERE
-
O.OwnerID=@IDNumber
-
AND
-
O.IDType='ClientZone'
-
)
-
)
-
AND
-
T.ClientID in
-
(--Only the correct Company(-ies)
-
SELECT O.IDNumber
-
FROM WebOwnership as O
-
WHERE
-
O.OwnerID=@IDNumber
-
AND
-
O.IDType='Client'
-
AND
-
O.OwnerType='Manager'
-
)
-
)
-
it would be nice to say like: -
(
-
@IDNumber in SomeFunc1()
-
OR
-
T.Zone in SomeFunc2(@IDNumber)
-
)
-
AND
-
T.ClientID in SomeFunc3(@IDNumber)
-
I will have to look into this
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Danny Anderson |
last post by:
Hola!
I am working on a program where I am including a library that came with my
numerical methods textbook. The "util.h" simply includes a large number
of files. I had to change the util.h...
|
by: michaaal |
last post by:
I have two folders in my website...
Folder1 (this is where my #include file is, this is where the style.css is)
--Folder2
(Folder2 is inside of Folder1)
Folder2 contains a file that has...
|
by: mescaline |
last post by:
Hi,
Suppose a_file.cpp contains a function a_function()
Now to include it in main_file.cpp I just do #include "a_file.cpp" and
I'm all set.
i recently came across this seemingly roundabout...
|
by: wukexin |
last post by:
Help me, good men. I find mang books that introduce bit "mang header
files",they talk too bit,in fact it is my too fool, I don't learn it, I have
do a test program, but I have no correct doing...
|
by: Exits Funnel |
last post by:
Hello,
I'm slightly confused about when to use parens around #included files
and when to use angle brackets. I understand (I think) that the
difference is that the compiler will search in its...
| |
by: Tuckers |
last post by:
My question is, if I have created my own library which lives in its own
install directory, to refer to its header file is it better to use
#include "MyLibrary.h"
or
#include <MyLibrary.h>
...
|
by: clusardi2k |
last post by:
Hello,
I'm trying to understand someone else code.
The below compiles and works fine and dandy.
#include <sys/types.h>
#include "unistd.h"
#include "stdio.h"
|
by: bibsoconner |
last post by:
Hi,
I hope someone can please help me. I'm having a lot of trouble with
schema files in .NET. I have produced a very simple example that uses
"include" to include other schema files. It all...
|
by: Susan Baker |
last post by:
Hi,
I am (trying) to compile some code I downloaded from the internet. The
sources contain references to header files - using the form :
#include <pathname/file>
If I change the form to...
|
by: Kceiw |
last post by:
Dear all,
When I use #include "queue.h", I can't link it.
The error message follows:
Linking...
G:\Projects\Datastructure\Queue\Debug\main.o(.text+0x136): In
function `main':...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |