Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 125399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:09:10+00:00 2026-05-11T05:09:10+00:00

I have a temp table that needs the values of a Stored procedure. So

  • 0

I have a temp table that needs the values of a Stored procedure. So the SP inserts 3 columns into the temp table, then I want to add a datetime to every row without modifying the SP.

Since I call the SP 3 times, each time with a different datetime, I can’t just update the whole temp table.

Any Suggestions?

DECLARE @temp TABLE (     id INT IDENTITY(1,1),     Name VARCHAR(150),     Address VARCHAR(25),     Date DATETIME )  WHILE (@count>=@daysBack) BEGIN     SET @date=DATEADD(dd, @count, GETDATE())     INSERT INTO @temp (Name,Address)         EXEC[dbo].StoredProc@date  --I Want to check for Null and insert the date there     Update @temp SET Date=@date WHERE Date=''       SET @count=@count-1 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:09:11+00:00Added an answer on May 11, 2026 at 5:09 am

    Yes. Create the temp table and in the added date column that does not have representation from your sproc put a default value constraint of getdate() or whatever date formula you need. In the insert statement specify the columns explicitly and omit the date column and it should work. As the rows are added the default value constraint will kick in and fill that column for you.

    example:

    create table #tmp (c1 int, c2 int, dt datetime default(getdate()) )  insert into #tmp (c1, c2) exec mysproc 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that returns values from a temp table. In my
I have a stored procedure that returns a result with 250!!! columns. But I
I have a file temp.txt, that I want to sort with the sort command
Hi Stackoverflow super stars... Here's my problem. I have a stored procedure that outputs
I have a stored procedure that gets a list of items, sorts and applies
I have a temp table with the exact structure of a concrete table T
I have a temp table I am creating a query off of in the
I have been reading about the differences between Table Variables and Temp Tables and
I have this code, showmessage('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID); if removedir('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID) then showmessage('Removed') else showmessage('Failed'); The message shows
I have some stored procedures that I need to write against a nasty beast

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.