Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Text Field Handling
Message
From
03/06/2003 05:12:41
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Text Field Handling
Miscellaneous
Thread ID:
00795559
Message ID:
00795559
Views:
51
Dear SQL Experts:

I have Four Tables In My Database with the following Fields:

Table 1: NewCategories with Fields:
CatId Int, CatName Varchar(100), Condition text

Table 2: Categories with Fields:
CatId Int, CatName Varchar(100)

Table 3: Items with Fields:
ItemId int, CatId Int, ItemName Varchar(100), Description Text

Table 4: NewItems with Fields:
ItemId int, CatId Int, ItemName Varchar(100), Description Text


For Each CatId in NewCategories Table I must run a select statement (written in the Condition Field) To get Items From the Items Table.

E.g

NewCategories

CatID CatName Condition
1 ONE select * from Items where Catid=34 or CatId=35
2 TWO select * from Items Where CatId=76 or ItemId=4


Categories
.....
34 Old34
35 Old35
...
76 Old76


Items
ItemId CatId ItemName Description
..................
4 12 Item4
..................
10 34 Item10 Item Description
11 34 Item11 Item Description
12 34 Item12 Item Description
..................
53 35 Item53 Item Description
54 35 Item54 Item Description
55 35 Item55 Item Description
..................
86 76 Item86 Item Description
87 76 Item87 Item Description
88 76 Item88 Item Description


For Each New Category I must Run The Condition (text field) to Get Records From Items and Insert Them in Table NewItems.

The Result will Be:

NewItems
ItemId CatId ItemName Description
..................
4 2 Item4
..................
10 1 Item10 Item Description
11 1 Item11 Item Description
12 1 Item12 Item Description
..................
53 1 Item53 Item Description
54 1 Item54 Item Description
55 1 Item55 Item Description
..................
86 2 Item86 Item Description
87 2 Item87 Item Description
88 2 Item88 Item Description


What I did Is to get CatId into a scroll cursor and to fetch each time the catid. Then I must execute a statement to Insert or to Bring in a temporary table/table variable/cursor the result of executing the statement contained in the Condition (text Field) From NewCategories Table.

Can You provide any ideas on how to achieve it?


Thanks in advance,

Spyros Christodoulou
Reply
Map
View

Click here to load this message in the networking platform