Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Adding a column to a temporary table?

deostrolldeostroll Member Posts: 65
Hi. I am trying to do the following in a stored proc:

I insert into a temporary table (#tmp):
[code]SELECT * INTO #TMP FROM JOB[/code]

Then I try to add an identity column to it:
[code]ALTER TABLE #TMP ADD ROWNO INT IDENTITY(1,1) NOT NULL;[/code]

Insert a row:
[code]INSERT INTO #TMP (JOBNAME, JOB_CLOCKTIME) VALUES ('TOTAL', @TOTALHOURS)[/code]

Display result set:
[code]SELECT JOBNAME, JOB_CLOCKTIME FROM #TMP ORDER BY ROWNO[/code]

The final output will be a complete report in itself...the row jobname = 'TOTAL' should come last, and the jobs should be in the order they are run. Tthe problem is sql server does not allow me to alter the temporary table. Is there a work around for this?
Sign In or Register to comment.