Saturday, February 25, 2012

Call a Stored Procedure from a SELECT Statement

Is there a way to call a stored procedure within a SELECT statement?
Example;
----
SELECT FirstName,
LastName,
(EXEC UniqueID_KEYGEN @.keyval output) AS UniqueID
INTO #tNewEmployee
FROM EmployeeTable
----
SELECT *
FROM #tNewEmployee
The return from the temp table would have a unique ID ready to insert into another table.
Our DBA has this stored procedure to create unique ID's and is to be used on all INSERTS. I was used to having a Identity field do this for me, I don't know why we have to do it his way. Except for the reason of sequence and easily get the next record. But we don't use URL variables, only FORM or SESSION.
Thanks for your help in advance.

No you can not. Usually this type of thing is done by using user defined functions. So, ask your DBA to convert into a function, so you can execute it from your stored procedure|||

That is a real pisser ;P, why would he do that?
grrrrrrrrrrr

No comments:

Post a Comment