Is it possible to do something like the following inside of a stored procedure?
INSERT
INTO [Database].[Schema].[Employees]
( [EmployeeID],
[WindowsLogonID],
[Status],
[Name],
[Address] )
VALUES ( @EmployeeID,
(EXEC [usp_GetWindowsLogonIDByEmpID] @EmpID = @EmployeeID),
@Status,
@Name,
@Address )
Where, say, some other table keeps more info on employees and their company Windows computer-use stuff. After all, not all employees may have or need computer access. The alternative is to pass it in as a parameter much like the other four columns... but if the database can look it up itself...?
Essentially, then, this other stored procedure would return only the WindowsLogonID, taking an EmployeeID as a parameter to look it up, and thus automatically provide the value for this INSERT
statement.
Would I be better off (or stuck) doing it like this?
DECLARE @WindowsLogonID int
EXEC @WindowsLogonID = [usp_GetWindowsLogonIDByEmpID]
@EmpID = @EmployeeID
INSERT
INTO [Database].[Schema].[Employees]
( [EmployeeID],
[WindowsLogonID],
[Status],
[Name],
[Address] )
VALUES ( @EmployeeID,
@WindowsLogonID,
@Status,
@Name,
@Address )