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)
 Stored Procedure

Author  Topic 

ozsql
Starting Member

14 Posts

Posted - 2009-09-26 : 19:18:06
Hi Guys,

I got a situation where I need to create a sproc to seed this table whenever we got changes to it. (e.g.updating, adding or deleting). I am new to store procedure and I need some help here for coding.

One of the consultant told me that I have to truncate the table every time we run it and reload it again. So i have to create sproc to do that by using seeding or reseeding technic. I am not familiar with that technic can anyone help me out.

Do i need to build this sproc in SSIS or SQL server.

All, I need is to update the changes like adding, deleting in the table so every time when execute the sproc it has to update the latest info. Basically, Data is coming from fox-pro database and the records will be deleted and updated regularly. So whenever we execute sproc it has to bring the latest data.

If I am confusing with seeding technic please ignore it.



declare @Depot table (name nvarchar (100), code nvarchar (100), last_date datetime , status nvarchar (5))



insert into @Depot

select 'abc' , '789' , getdate (), 'L' union all

select 'abc' , null , getdate (), 'L' union all

select 'xyz' , '123' , getdate (), 'L' union all

select 'xyz' , '123' , getdate (), 'L' union all

select null , '123' , getdate (), 'L' union all

select 'LMN' , null , getdate (), 'L' union all

select 'abc' , '456' , getdate (), 'L'



select depot_name, depot_code, status, last_date from

(SELECT (coalesce (nullif (d.[name],'' ),'Unknown' ))as depot_name

,coalesce (nullif (d.[code],'' ),'Unknown' ) as depot_code

, d.[status]

,cast (floor (cast (d.[last_date] as float )) as smalldatetime )as last_date

, row_number() over (partition By name order by last_date desc ) r

FROM @Depot d

WHERE d.status = 'L' ) x

where r =1



Thanks,



D



Beginner
   

- Advertisement -