My project is halted on 2 niggling problems, any help would be much appreciated from those to which this is childsplay:
Problem 1: ______________________
I have a table with employee data, and another table containing their pay information.
Create table Payroll_tbl
(payroll_no char(6),
employee_no char(6),
Weekends integer not null default 0,
constraint pay_key primary key (payroll_no, employee_no),
constraint maintain_pay foreign key (employee_no) references employee_tbl on update cascade on delete cascade,
constraint chk_weekend check (Weekends in (0, 1)),
);
the line above regarding on update and on delete does not seem sufficient so that when I add a new employee to the employee_tbl that the new employee's number appears automatically as a new record in Payroll_tbl, with the weekends field defaulting as 0, and to generate a new payroll_no accordingly. This is what I desire, is there any simple way of achieveing this? I would also like to add their employee no to another table about projects in a similar manner.
Is it something called a trigger? i am new to sql :|
Problem 2: _______________________
I have defined something as 'Expense smallmoney,' in my table, no constraints. And then I add a value like '217' or '725.00' when inserting data. Yet the query analyser returns an error saying 'Disallowed implicit conversion from data type varchar to data type smallmoney, table '. I'm not telling it to do so! It also says use the convert function to run this query. I really dont understand I just want some currency values to appear. ie 259.85
Thanks In Advance