Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on Store Procedures!!!

Status
Not open for further replies.

job1

Technical User
Mar 12, 2004
26
US
Hi All

Is this possible to write a store procedure in SQL server or should I use a front end tool like VB to do this. My requirement is this

I have two tables

cd table
---------------
cd
ID
Desc

Area table
-----------
Parent
Child

2. To make work easier I am creating a Temp table created with fields lets say temp
cd
id
descr

3. Then loading the data to cd,id,descr from cd table into the new table temp
insert into temp
(
cd,
id,
descr
)select
distinct cd,
id,
descr
from cd

4. Select from the area table and temp table,the parent,temp.id,test_temp.desc where temp.cd equals to
area.child.
select area.parent,temp.id, temp.desc from temp, area
where temp.bu = area.child
Ex: 210(cd)
200(parent).

5. Now the descr and ID of 200(cd) is inserted into test_temp.

6.Repeat steps 3 & 4 till pf_bu reaches 100.

Please let me know if I am not clear.

-TIA
 
As there is no reply I am presenting the same in different format, I tried doing this in Cursor but ended in different result, cud anyone help me in this.

I have a table with fields table1

col1 col2
--------------------
A Object1
B Object2
C Object3
D Object4
E Object5
F Object6

I have another table sectable

fld1 fld2
----------------
G A
H A
I B
J B
K B
A A
L G
M H
N I

all the fld1 values must be given col2 value based on fld2... for example

G should get the value Object1 and as G is also in fld 2 L should also get the value Object1... and so as the other fields

-Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top