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
 Transact-SQL (2000)
 Copy from Table

Author  Topic 

Sirchrisak
Starting Member

19 Posts

Posted - 2005-06-23 : 13:12:23

I want to copy some rows from Table tblA to Table tblB
But my code is not working, help
ALTER PROCEDURE [dbo].[BulkInsert]

AS

Declare @var1 char(10)
Declare @var2 char(10)
Declare @Var3 char(10)

BEGIN



Insert Into TblB(var1,Var2,Var3)
(Select Var1,Var2,Var3 From tblA)
FETCH NEXT INTO @var1,@Var2,@Var3

END


Chris

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-06-23 : 13:17:58
code
Insert Into TblB(var1,Var2,Var3)
values (Select Var1,Var2,Var3 From tblA)
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-06-23 : 14:46:01
That is wrong syntax Afrika.

INSERT TblB(var1,var2,var3)
SELECT var1,var2,var3
FROM TblA
WHERE <criteria to select the rows You want from TblaA>

Chris, please, You really don't need a cursor to do this.

rockmoose
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-24 : 01:37:04
In Books On Line , Go to Index and Type Insert into. You can see how to copy from one table to other

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -