Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 INSERT INTO temporary table

Author  Topic 

dimoss
Yak Posting Veteran

52 Posts

Posted - 2008-11-11 : 06:57:54
Hi,

I have the following query and I am trying to insert the result in a temporary table with an extra 'id_' column (not null, int, identity(1,1)

SELECT dik.id, COUNT(mel.id) + 1 AS Total
FROM dik LEFT OUTER JOIN
mel ON dik.id = mel.id_ait
GROUP BY dik.id

How can I do this?

Thank you.

www.tabletennis.gr

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-11-11 : 07:04:05
[code]CREATE TABLE #dump (
[Id] INT IDENTITY(1,1)
, [dikId] INT
, [counts] INT
)

INSERT #dump (
[dikId]
, [counts]
)
SELECT
dik.id
, COUNT(mel.id) + 1
FROM
dik
LEFT OUTER JOIN mel ON dik.id = mel.id_ait
GROUP BY
dik.id[/code]


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

dimoss
Yak Posting Veteran

52 Posts

Posted - 2008-11-11 : 07:27:29
Thank you!
Go to Top of Page
   

- Advertisement -