Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

stored procedure for seeding Expand / Collapse
Author
Message
Posted Saturday, September 26, 2009 12:38 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 8, 2014 10:53 PM
Points: 27, Visits: 202
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.


Note: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
Post #794145
Posted Monday, September 28, 2009 1:11 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 7:25 AM
Points: 1,221, Visits: 1,294
Not realy sure what you're looking for. Do you want to delete the data before loading? Reseeding has to do with a table that has an identity column. You can reseed the identity to something else. Can you clarify what you're trying to do.

For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #794708
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse