Ok so currently I have a store procedure that does roughly this:
[code=sql]
SELECT
IDX, FirstName, LastName, Email, Phone, etc, etc2, etc3
FROM
ABunchOfTables
WHERE
ALotOfLogic=tru e
[/code]
Due to the nature of what I need elsewhere, it would be good if it did this:
[code=sql]
SELECT
IDX, FirstName, LastName, Email, Phone, etc, etc2, etc3
FROM
ABunchOfTables
WHERE
ALotOfLogic=tru e
END
SELECT
IDX, LastName
FROM
ABunchOfTables
WHERE
ALotOfLogic=tru e
END
[/code]
Now that is a waste, both because the columns returned in the 2nd query are a subset of the first query AND because a lot of logic has to happen and database hits to produce a same results (although with less columns)as well.
I would like to be able to do something more like this:
[code=sql]
SELECT
@IDX=IDX, FirstName, @LastName=LastN ame, Email, Phone, etc, etc2, etc3
FROM
ABunchOfTables
WHERE
ALotOfLogic=tru e
END
SELECT
@IDX, @LastName
END
[/code]
Except that I need it to return multiple rows for each query.
Now I don't think this is possible, but I have been surprized before.
I think what will end up happening is I just have the first query in the storedproc, and I call the proc twice?
[code=sql]
SELECT
IDX, FirstName, LastName, Email, Phone, etc, etc2, etc3
FROM
ABunchOfTables
WHERE
ALotOfLogic=tru e
[/code]
Due to the nature of what I need elsewhere, it would be good if it did this:
[code=sql]
SELECT
IDX, FirstName, LastName, Email, Phone, etc, etc2, etc3
FROM
ABunchOfTables
WHERE
ALotOfLogic=tru e
END
SELECT
IDX, LastName
FROM
ABunchOfTables
WHERE
ALotOfLogic=tru e
END
[/code]
Now that is a waste, both because the columns returned in the 2nd query are a subset of the first query AND because a lot of logic has to happen and database hits to produce a same results (although with less columns)as well.
I would like to be able to do something more like this:
[code=sql]
SELECT
@IDX=IDX, FirstName, @LastName=LastN ame, Email, Phone, etc, etc2, etc3
FROM
ABunchOfTables
WHERE
ALotOfLogic=tru e
END
SELECT
@IDX, @LastName
END
[/code]
Except that I need it to return multiple rows for each query.
Now I don't think this is possible, but I have been surprized before.
I think what will end up happening is I just have the first query in the storedproc, and I call the proc twice?
Comment