Tuesday, March 27, 2012

Create a Table using another table!

Hi,
Sorry to trouble you all, but I am not getting anywhere!
I need to copy the contents of 1 table into a new temporary table. What I am
doing is :
SELECT *
FROM U_regulargiver
WHERE Status ='I'
OR Status ='N'
INTO TABLE #U_T_Committed
Obviously I'm doing something wrong, but I can't seem to figure out exactly
what. Can anyone please help?
Thanks in advance
RobYou screwed up with the syntax:

> SELECT *
> INTO TABLE #U_T_Committed
> FROM U_regulargiver
> WHERE Status ='I'
> OR Status ='N'
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Robert" <Robert@.discussions.microsoft.com> schrieb im Newsbeitrag
news:7BE6CA67-EF93-4A97-8BA7-22220C06E0FA@.microsoft.com...
> Hi,
> Sorry to trouble you all, but I am not getting anywhere!
> I need to copy the contents of 1 table into a new temporary table. What I
> am
> doing is :
> SELECT *
> FROM U_regulargiver
> WHERE Status ='I'
> OR Status ='N'
> INTO TABLE #U_T_Committed
> Obviously I'm doing something wrong, but I can't seem to figure out
> exactly
> what. Can anyone please help?
> Thanks in advance
> Rob
>|||You can get the results you want by writing the statement this way.
Create Table #temp
(
Test nvarchar (10),
Description nvarchar (255)
)
select * from testuser.dbo.MyTable
Insert into #temp
Select *
from testuser.dbo.MyTable
Select * from #temp
Drop table #temp
refer to Books Online for more information if you must use the INTO clause.
"Robert" wrote:

> Hi,
> Sorry to trouble you all, but I am not getting anywhere!
> I need to copy the contents of 1 table into a new temporary table. What I
am
> doing is :
> SELECT *
> FROM U_regulargiver
> WHERE Status ='I'
> OR Status ='N'
> INTO TABLE #U_T_Committed
> Obviously I'm doing something wrong, but I can't seem to figure out exactl
y
> what. Can anyone please help?
> Thanks in advance
> Rob
>

No comments:

Post a Comment