June 22, 2015 at 2:05 pm
Hi All,
I have a need to insert stored procedure output a table and in addition to that add a datetimestamp column.. For example, Below is the process to get sp_who output into Table_Test table. But I want to add one additional column in Table_test table with datetimestamp when the procedure was executed.
insert into Table_Test execute sp_who
any help will be highly appreciated.
Thanks.
June 22, 2015 at 2:25 pm
something like this:
add a column "when datetime" to your table then:
begin tran
declare @when datetime = current_timestamp;
insert into table
exec sp_who2
update table
set when = @when
where when is null
commit
Gerald Britton, Pluralsight courses
June 22, 2015 at 2:34 pm
Or put a DEFAULT (GetDate() / GetUTCDate()) constraint on the new column.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy