Link to home
Start Free TrialLog in
Avatar of Sok Dymang
Sok DymangFlag for Cambodia

asked on

Automatically add row to table by job in SqlServer 2012

Dear all brother and sister, i am working on VB.Net and SqlServer application, let say i have table "tbl_att" with field (empid, WorkingDate) and i want Sql job to do a task for me. I want it automatically insert 1 row for 1 user every Sunday (I have more than 100 empID) like:
empid         WorkingDate
    1                 2017-05-02
    2                 2017-05-02
    3                 2017-05-02

So is this operation need loop? as in attached picture
Thanks in advance.
ew.PNG
Avatar of HainKurt
HainKurt
Flag of Canada image

create procedure ins_WorkDays()
begin
  insert into tbl_att
  select empid, getdate() from employees
end;

Open in new window



and somehow create a job and run this sp...
Avatar of Ryan Chong
you can first creating a Stored Procedure that includes the logic of adding the records and then create an automated process (such as SQL Job, or a custom ETL program that running on a specific date time) to run that Stored Procedure to create the relevant records into your table.

hope that make sense.
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial