Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Help with stored procedure

Author  Topic 

argate7
Starting Member

7 Posts

Posted - 2009-04-10 : 15:55:53
Hi, i'm new in your company and new in the SQL's company.
I need your help with a stored procedure. I'm giving you the tables...

C1:C1NO(PK),C1NAME,C1SURNAME
E2:E2NO(PK),E2NAME,E2SURNAME
O3:O3NO(PK),C1NO(FK),E2NO(FK)
I4:I4NO(PK),I4NAME,I4SURNAME
D5:O3NO(PK),D5NO(PK),I4NO(FK),D5QUANTITY

I need to write 2 stored procedures...

1)Write a stored procedure to return C1 details based on the C1NO, which will be given as a parameter.

And my answer is...

create procedure C1_details
@C1NO int
as
select *
from C1
where C1NO = @C1NO

And my question is...That's rigth??or not?and where is the problem?

2)Write a stored procedure that displays error handling techniques when inserting data into tables that are related.

Can anyone help me with this procedure? How i have to implement this one?

Thank you very muxh for your help and your time!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-10 : 16:01:16
1. Yes that looks correct.
2. Check out Try/Catch, BEGIN TRAN, COMMIT TRAN, ROLLBACK TRAN, and @@ERROR in SQL Server Books Online.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

argate7
Starting Member

7 Posts

Posted - 2009-04-10 : 16:10:53
create procedure O3_C1
@O3NO int
@C1NO int
@E2NO int
as
insert into O3(O3NO,C1NO,E2NO)
values(@O3NO,@C1NO,@E2NO)

How you see this one?? It's right or wrong?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-11 : 05:37:51
It depends on what the question is.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -