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 2005 Forums
 Transact-SQL (2005)
 Moving data from one table to 3

Author  Topic 

mshsilver
Posting Yak Master

112 Posts

Posted - 2009-04-07 : 08:45:53
Hi,

I am in a situation where I need to move data from one table into 3 other tables in the same database(SQL Server 2005). What would like to find out is the best way to achieve this. It will need to be done once a day and then the data from the source table will need to be deleted.

I have been think of a stored procedure but am not sure exactly on the syntax so am yet to get that working. Before I take that route I thought some advice was needed.

Any help would be greatly appreciated. Thanks in advance.


Here is the test procedure I setup trying to move one field from a table to a field in another table. I did this just to test my code and the logic.

Here is the error:

Msg 201, Level 16, State 4, Procedure move_ebs, Line 0
Procedure or function 'move_ebs' expects parameter '@forename', which was not supplied.


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
alter procedure [dbo].[move_ebs]

@forename varchar(50)

AS

SET @forename = (select forename from wce_ilr where learning_aim = '10003265')


INSERT INTO inserttest (forename) VALUES (@forename)


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-07 : 08:49:33
[code]alter procedure [dbo].[move_ebs]
(
@learning_aim VARCHAR(10) = '10003265'
)
AS

set nocount on

INSERT inserttest
(
forename
)
select forename
from wce_ilr
where learning_aim = @learning_aim[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

mshsilver
Posting Yak Master

112 Posts

Posted - 2009-04-07 : 12:11:24
Thanks for that, worked straight away.
Go to Top of Page
   

- Advertisement -