SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


stored procedure for seeding


stored procedure for seeding

Author
Message
dreamslogic
dreamslogic
SSC Journeyman
SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)SSC Journeyman (77 reputation)

Group: General Forum Members
Points: 77 Visits: 203
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
Mike01
Mike01
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1547 Visits: 1527
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/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search