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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Complicated Insert into temp table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-06-02 : 07:40:56
Gabriel Elizondo writes "I'm trying to perform a complicated insert into a temp table I have created, the insert is done using the select/from method, it includes concatenating data from another SQL database to create one primary key field, it also includes UNION statments to combine data I haven't been able to get the query to run, am I trying to do too much at once? Does the select/from method not allow concatenation or unions?


INSERT INTO ##tblIncludes (CAG, cid, aid, gid, filter)
SELECT ((RTrim(xData.dbo.ename.cid)+RTrim(xData.dbo.ename.aid)+RTrim(xData.dbo.ename.gid)), xData.dbo.ename.cid, xData.dbo.ename.groupid, xData.dbo.ename.aid, epbmctl2.filter)
FROM xData.dbo.ename LEFT JOIN ectl2 ON xData.dbo.ename.cid = ectl2.cid
WHERE ectl2.filter = 'I' AND ectl2.aid IS NULL AND ectl2.gid IS NULL
UNION
SELECT (RTrim(xData.dbo.ename.cid)+RTrim(xData.dbo.ename.aid)+RTrim(xData.dbo.ename.gid)), xData.dbo.ename.cid, xData.dbo.ename.gid, xData.dbo.ename.aid, ectl2.filter)
FROM xData.dbo.ename LEFT JOIN ectl2 ON xData.dbo.ename.cid = ectl2.cid
WHERE ectl2.filter = 'I' AND ectl2.aid = xData.dbo.ename.aid AND ectl2.gid IS NULL
UNION
SELECT (RTrim(xData.dbo.ename.cid)+RTrim(xData.dbo.ename.aid)+RTrim(xData.dbo.ename.gid)), xData.dbo.ename.cid, xData.dbo.ename.gid, xData.dbo.ename.aid, ectl2.filter)
FROM xData.dbo.ename LEFT JOIN ectl2 ON xData.dbo.ename.cid = ectl2.cid
WHERE ectl2.filter = 'I' AND ectl2.aid = xData.dbo.ename.aid AND ectl2.gid = xData.dbo.ename.gid

Thanks
Gabriel Elizondo"

dsdeming

479 Posts

Posted - 2003-06-02 : 07:57:45
We need some more information here. You say you haven't been able to get the query to run, but does that mean you're simply not inserting rows, or are you getting some sort of error?

Dennis
Go to Top of Page
   

- Advertisement -