Showing posts with label contract. Show all posts
Showing posts with label contract. Show all posts

Monday, March 26, 2012

How to alter the table with delete/update cascade without recreating the table

I have contract table which has built in foreign key constrains. How can I alter this table for delete/ update cascade without recreating the table so whenever studentId/ contactId is modified, the change is effected to the contract table.

Thanks

************************************************** ******
Contract table DDL is

create table contract(
contractNum int identity(1,1) primary key,
contractDate smalldatetime not null,
tuition money not null,
studentId char(4) not null foreign key references student (studentId),
contactId int not null foreign key references contact (contactId)
);http://www.schemamania.org/jkl/booksonline/SQLBOL70/html/7_design_41.htm for detailed explanation.


Also refer to books online for additional information.|||guys,
the earlier response was not helping. Does anyone have better help?
I tryed the new DDL but not working either. How can I alter my table or create new one to make the cascading working.

thanks in advance!

************************************************** *
My original contract table DDL is

create table contract(
contractNum int identity(1,1) primary key,
contractDate smalldatetime not null,
tuition money not null,
studentId char(4) not null foreign key references student (studentId)
contactId int not null foreign key references contact (contactId)
);

************************************************** ***
My modified contract table DDL is

create table contract(
contractNum int identity(1,1) primary key,
contractDate smalldatetime not null,
tuition money not null,
studentId char(4) not null foreign key
references student (studentId)
on update cascade
on delete cascade,
contactId int not null foreign key
references contact (contactId)
on update cascade
on delete cascade
);|||set nocount on
begin tran
if object_id('dbo.t1') is not null drop table dbo.t1
go
if object_id('dbo.t2') is not null drop table dbo.t2
go
create table dbo.t1 (f1 int not null primary key, f2 char(1) null)
go
create table dbo.t2 (f0 int not null primary key, f1 int not null constraint fk_t2 foreign key references dbo.t1(f1))
go
insert t1 select 1, 'A'
go
insert t2 select 1, f1 from t1
go
select * from t2
go
alter table t2 drop constraint fk_t2
go
alter table t2 add constraint fk_t2 foreign key (f1) references t1(f1) on update cascade
go
update t1 set f1 = 2
go
select * from t2
go
rollback tran
go
set nocount off

Friday, February 24, 2012

How to add a group header and footer for a report

I have a report that is being called via stored proc, and i want to group by contract. when report gets generated i get multiple contracts info. but will be grouped/sorted by contract.

please how can i have a group header and also a group footer to show a summary of each contract information with some calculated fields in it.

i may get 100 records related to 10 contracts , 10 rows for each contract.

as soon as the first contract info is shown on the report it has to show a summary related to the first contract in the group footer, and then continue populating the second contract info and so on.

Please i am totally new to reporting and help would be appreciated. thank you all.

Here's what you can do:

Click anywhere on your table while in Layout.
Right click on the box next to your details row (it has 3 horizontal bold bars on it), and select 'Insert Group'.
On the 'General' tab, make sure 'Include group header' and 'Include group footer' are both checked.
In the 'Group on:' section, drop down the box and select your contract field. (Or you can type: =Fields!contract.Value)
On the 'Sorting' tab, again, pick or type your contract field as above.
On the 'Visibility' tab, make sure that the 'Visible' radio button is selected.
Hit 'OK' and now you can add your fields to the group header and footer.

Hope this helps.

Jarret

|||

Did this work for you Reddymade?

Jarret