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
 General SQL Server Forums
 New to SQL Server Programming
 create a store proc

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-03-22 : 08:39:31
samir khatri writes "hello sir,

i m new in the world of database so please help me to create a perticular store proc

i want to get data from 3 tables and 2 field of a table is match with the same field of another table and it cant work
i write that code so u can understand easily but it dont work so please modify that and make it workable

select a.a_dis_id,b.name as fromname,b.name as toname,a.a_dis_km,c.a_all_name,c.a_all_rate from
a_distance a,levels b,a_allowance c where
a.a_dis_from=b.cid and a.a_dis_to=b.cid and c.a_all_id=a.a_all_id

Thank You
Waiting for yur reply....."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-22 : 08:44:15
You should give some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-22 : 09:02:49
samir khatri,

What is your real question?

Do you want to learn how to write a stored procedure?
Do you want to learn how to write a Query that gives the results u expect and incorporate that in Stored Procedure? [In this case you have to comply with the above answer of Madhivanan]


Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-03-23 : 07:42:11
select a.a_dis_id,b.name as fromname,b.name as toname,a.a_dis_km,c.a_all_name,c.a_all_rate
from a_distance a,levels b,a_allowance c
where a.a_dis_from=b.cid
and a.a_dis_to=b.cid
and c.a_all_id=a.a_all_id

where a.a_dis_from=b.cid
and a.a_dis_to=b.cid
This doesn't look like join fields.
I would expect a_distance to have two id's and a distance between them - could be wrong though.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -