stored procedure for seeding

  • 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.,'' ),'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

  • 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/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply