In a stored procedure I am selecting from a table using variables passed in. Then, I want to log what is selected. Is there any way to do this without using a temporary table or table variable?
The select statement:
Select userId, firstName, lastName, address
from myTable
where userName = @userName and password = @password
Then, I want to log the userId, firstName, lastName, and address that were selected. So:
Insert into loginLog...[results gotten above]
Note: I only want to log it if there is only one result returned. If more than one result is returned, I still want to select all the results, but I do not want to log it.
Use your
selectto populate local variables in the stored procedure. Log the results, thenselectthe variable to return them to the caller: