Child,chid Of Child ,child Of Child Of Child

Oct 22, 2007

 

 

............
child  |parent|
.............
a1     |a     |
.............
a2     |a     |
.............
a11   |a1    |
.............
b1     |b     |
.............
b11   |b1    |
.............
b111 |b1    |
.............

Here is my table
I want to get all childs of "a" ie {a1,a11,a2}
I mean recursively
ie child,chid of child ,child of child of child ........etc up to any extentet the table contain
How can i for mulate the select   querry
?

View 3 Replies


ADVERTISEMENT

SQL 2012 :: Group By Parent With One Child And Multiple Child Information?

Jul 25, 2014

Basically i have three Tables

Request ID Parent ID Account Name Addresss
1452 1254789 Wendy's Atlanta Georgia
1453 1254789 Wendy's Norcross Georgia
1456 1254789 Waffle House Atlanta Georgia

Bid_ID Bid_Type Bid_Volume Bid_V Bid_D Bid_E Request_ID Parent ID
45897 Incentive 10 N/A N/A N/A 1452 1254789
45898 Incentive 10 N/A N/A N/A 1453 1254789
45899 Incentive 10 N/A N/A N/A 1456 1254789

Bid_Number Bid_Name Request_ID Parent ID
Q789456 Wendy'Off 1452 1254789
Q789457 Wendy'Reba 1452 1254789
Q789456 Wendy'Off 1453 1254789
Q789457 Wendy'Reba 1453 1254789
Q789456 Wendy'Off 1456 1254789

I want the Result

Parent ID Bid_Type Bid_Volume Bid_V Bid_D Bid_E AutoGeneratedCol
1254789 Incentive 10 N/A N/A N/A 1
1254789 Incentive 10 N/A N/A N/A 2
Bid Number AutoGeneratedCol_Link
Q789456 1
Q789457 1
Q789456 2
Request ID AutoGeneratedCol_Link
1452 1
1453 1
1456 2

View 1 Replies View Related

Transact SQL :: To Get Parent / Child / Grand Child Row On Various Order?

Jun 26, 2015

I have a table with below kind of data,

DECLARE @TBL TABLE (ItemId INT IDENTITY(1,1), ItemName NVARCHAR(20), ItemDate DATE, ParentItemName NVARCHAR(20), ItemOrder INT, ReportId INT)
INSERT INTO @TBL (ItemName, ItemDate, ParentItemName, ItemOrder, ReportId)
VALUES ('Plan', '2015-06-01', NULL, 1, 20),('Design', '2015-06-01', NULL, 2, 20),('Test', '2015-06-20', NULL, 3, 20),('Complete', '2015-06-30', NULL, 4, 20),
('Design child A', '2015-06-02', 'Design', 1, 20), ('Design child B', '2015-06-01', 'Design', 2, 20),
('Test child A', '2015-06-10', 'Test', 1, 20), ('Test child B', '2015-06-09', 'Test', 2, 20), ('Test child C', '2015-06-08', 'Test', 3, 20),
('Test grand child A', '2015-06-08', 'Test child B', 1, 20), ('Test grand child B', '2015-06-08', 'Test child B', 2, 20)
select * from @TBL

Here I want,

1. to display all parent with ORDER BY ItemOrder (no need to sort by ItemDate)
2. display all child row right after their parent (ORDER BY ItemOrder if ItemDate are same, else ORDER BY ItemDate)
3. display all grand child row right after their parent (ORDER BY ItemOrder if ItemDate are same, else ORDER BY ItemDate)

Looking for below output ...

View 3 Replies View Related

Trying To Return A Single Record For Each Client From Child Table Based Upon A Field Of Date Type In Child Table

Nov 1, 2007

I have table "Clients" who have associated records in table "Mailings"
I want to populate a gridview using a single query that grabs all the info I need so that I may utilize the gridview's built in sorting.
I'm trying to return records containing the next upcoming mailing for each client.
 
The closest I can get is below:
I'm using GROUP BY because it allows me to return a single record for each client and the MIN part allows me to return the associated record in the mailings table for each client that contains the next upcoming 'send_date' 
 
SELECT MIN(dbo.tbl_clients.client_last_name) AS exp_last_name, MIN(dbo.tbl_mailings.send_date) AS exp_send_date, MIN(dbo.tbl_mailings.user_id) AS exp_user_id, dbo.tbl_clients.client_id, MIN(dbo.tbl_mailings.mailing_id) AS exp_mailing_idFROM dbo.tbl_clients INNER JOIN
dbo.tbl_mailings ON dbo.tbl_clients.client_id = dbo.tbl_mailings.client_idWHERE (dbo.tbl_mailings.user_id = 1000)GROUP BY dbo.tbl_clients.client_id
The user_id set at 1000 part is what makes it rightly pull in all clients for a particular user. Problem is, by using the GROUP BY statement I'm just getting the lowest 'mailing_id' number and NOT the actual entry associated with mailing item I want to return.  Same goes for the last_name field.   Perhaps I need to have a subquery within my WHERE clause?Or am I barking up the wrong tree entirely..

View 7 Replies View Related

Transact SQL :: Parent / Child Tables - Pivot Child Data To Parent Row

May 19, 2015

Given the sample data and query below, I would like to know if it is possible to have the outcome be a single row, with the ChildTypeId, c.StartDate, c.EndDate being contained in the parent row.  So, the outcome I'm hoping for based on the data below for ParentId = 1 would be:

1 2015-01-01 2015-12-31 AA 2015-01-01 2015-03-31 BB 2016-01-01 2016-03-31 CC 2017-01-01 2017-03-31 DD 2017-01-01 2017-03-31

declare @parent table (Id int not null primary key, StartDate date, EndDate date)
declare @child table (Id int not null primary key, ParentId int not null, ChildTypeId char(2) not null, StartDate date, EndDate date)
insert @parent select 1, '1/1/2015', '12/31/2015'
insert @child select 1, 1, 'AA', '1/1/2015', '3/31/2015'

[Code] .....

View 6 Replies View Related

CHILD Functions?

Jan 17, 2007

How can I pick out a "top child" in SQL Server 2000?

Example:

---------------------------------
| Employee || code || action date |
---------------------------------
| 00000001 || AAA || 01/02/2005 |
| 00000001 || DDD || 01/02/2001 |
| 00000001 || CCC || 01/06/2000 |
| 00000002 || AAA || 01/02/2006 |
| 00000002 || CCC || 01/10/2004 |
| 00000003 || DDD || 05/12/2001 |
| 00000004 || AAA || 09/09/2006 |
| 00000004 || SSS || 09/06/2000 |
---------------------------------

I want to pick out the record with the latest date for every employee so I end up with something like this:

---------------------------------
| Employee || code || action date |
---------------------------------
| 00000001 || AAA || 01/02/2005 |
| 00000002 || AAA || 01/02/2006 |
| 00000003 || DDD || 05/12/2001 |
| 00000004 || AAA || 09/09/2006 |
---------------------------------

Any ideas?
Thanks in advance!

-GeorgeV

View 3 Replies View Related

Bcp In Child Before Parent

May 19, 2004

Huh?

I've got good RI data...BUT..a developer loaded the tables in alpha table order....

Such that the child loaded BEFORE the parent....

Huh?

Got a test being set up now to mess with the child file to add a key that doesn't exist in the parent...

But Why is this allowed?

In DB2 you can specify

LOAD DATA REPLACE NO CHECK....

On the load card...you then need to run a check after to verify the data...

Is that what's going on? Is there such a utility in SQL Server to run a check post load?

I'm confused....

Any comments appreciated.

Thanks



Brett

8-)

View 2 Replies View Related

Insert Into Parent/child

Feb 25, 2008

hi,
i have two tables i want the identity value of the parent table to be inserted into the chile table
here is my code,but i don't know why it isn't working !
protected void Button1_Click(object sender, EventArgs e)    {        string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;        string pcontent = TextBox1.Text;        string data = TextBox2.Text;        addtopic(pcontent,connectionString);        addfile(data, connectionString);                    }    public void addtopic(string subject,string connstring)    {         using (SqlConnection connection = new SqlConnection(connstring))        {                        SqlCommand command = new SqlCommand("INSERT INTO parent" + "(content)" +              "Values(@content)", connection);            command.Parameters.Add("@content", SqlDbType.Text).Value = subject;            connection.Open();            command.ExecuteNonQuery();                    }    }    public void addchild(string name, string connstring)    {                using (SqlConnection connection = new SqlConnection(connstring))        {Guid id = Guid.NewGuid();           SqlCommand commandd = new SqlCommand("INSERT INTO child" + "(parentid,data,uniqueid)" +              "Values(@@IDENTITY,@data,@uid)", connection);            commandd.Parameters.Add("@data", SqlDbType.NVarChar, 50).Value = name;            commandd.Parameters.Add("@uid", SqlDbType.UniqueIdentifier).Value = id;           
 
thanks in advance :)
           
            connection.Open();            commandd.ExecuteNonQuery();        }
    }

View 2 Replies View Related

Parent Child Transversing

Jul 16, 2005

I have a parent/child relationship in a relational database broken out like this:
Table Name: categories[category_id]         int            (primary_key NOT NULL),[category_name]       varchar(50),[parent_fk]           int
The parent references the category_id in the same table to create the parent/child relationships. I can get all the bottom level categories by doing this:
select category_id, category, parent_fk from categories where  category_id not in (  select parent_fk from categories)
Each bottom-level category has a count attached to it.
The problem I have is getting the counts rolled up for each parent of the bottom level. A parent could/will have multiple bottom-level categories (and counts).
My sql is a little weak, could you help me out?  I can utilize everying in SQL 2000 (stored proc, UDF, anything).
Thanks!

View 3 Replies View Related

How To Update Child Table Using The PK And A Seq #

Jun 17, 2002

Good morning,
I have two tables PARENTTBL which is a parent table and CHILDTBL which is a
Child table . For each insert in the Parent table i want to insert values in the child Table but (when inserting in child table) i want the Field FILED2 which is a varchar one will receive the value of the PKEY int cancatenated with a sequnetial value for each new PKEY
FILED2 = Rtrim(LTreim(Str(PKEY))+ Sequential # . which is a
Sequential # by PKEY value .

Exemple : If i insert
100,A,B in PARENTTBL (100 is a PK value)
i want to insert in CHILDTBL the following data :
125,100-1
126,100-2
300,100-3
452,100-4
The first column is the Child PK and the second column is the FILED2
I want to do this in one insert instead of insert then Update.

I don't find the equivalent of Number(*) of SYBASE or ROWNUM of Oracle in order to do This .

Thinks to help me

View 3 Replies View Related

Update Child Records Help

Oct 5, 2004

Please help

I have table1 which has many unique ID numbers and table2 that has many records for each ID. some of the ID numbers in table1 have changed and I have created a translation table (table3) that links the old and new ID numbers.

What I need to do is some sort of update sql statement that updates all the records in table2 changing all the oldID numbers to the new ones using the translation table.

Table1 and table2 are not linked...can anyone help me with the sql statement

example

Table 1
IDNUM NAME
12345 Joe
12346 Mary
12347 David

Table2
IDNUM FIELD1
12345 hello
12345 goodbye
12346 hello
12347 goodbye
12346 hello
12346 goodbye

Table3
OLDID NEW ID
12345 54321
12347 74321

need to change the IDNUM in Table2 to 54321 where IDNUM = 12345 and same with 12347..Need to do this for many many IDs but not all.

Thanks very much

View 1 Replies View Related

Rollup Child Rows?

Sep 26, 2005

Is it possible to roll up all child records into one comma delimited field? For example, if the parent table is league info, and the child table is team info, I would be looking to return results like this:

Field 1 Field 2
NFL Bears, Browns, Saints, etc
NBA Bulls, Celtics, Lakers, etc

TIA,

Rob

View 4 Replies View Related

Getting A Tree Using Parent-child

Sep 27, 2013

Here is the table - Company with fields:

CompanyID, ParentCompanyID (both integers)

Given a CompanyID - I want to get all the children for the Company.

I did similar procedures but somehow, could not get this to work.

View 4 Replies View Related

Insert Child Record

Mar 22, 2006

George writes "SQL server 2005 Express, Windows XP Pro SP2

I want to create a stored procedure that will insert a record in a child table (tblcontproj)propulating two columns with columns from the parent (InterestListoriginal)and two columns with user selected values. I created an insert select statement that looks like ..

" INSERT INTO tblcontproj(proj_rpt_id, proj_name) SELECT proj_rpt_id, project_name FROM InterestListoriginal WHERE (proj_rpt_id = @proj_rpt_id)"

This works great! Now can I add two columns to the INTO clause for projcontshortname and projconttye and use a VALUE clause that sets tblcontproj.projcontshortname and tblcontproj.projconttype to @projcontshortname and @projconttype which are user selected values from a downdownlist.

Or add an UPDATE query?

Thanks "

View 1 Replies View Related

Parent Child Problem In Sql

Jul 1, 2007

I want to find all the child of a node in a tree . A child can have multiple parent i.e 2 can be place under multiple parent . The folling is the data:

ParentID ChildID
-------------------------
10 8
8 6
8 7
7 2
7 5
5 1
5 2
6 2

child of parent if input 10
8
7
6
2
2
5
1
(2) can be neglected

input 7
2
5
1
(2) can be neglected

input 8
7
2
5
(2) can be neglected


Plz help we to write the sql statements

Thanks

View 2 Replies View Related

Hierarchy – Parent And Child

Aug 2, 2007

I am designing a table to represent data in hierarchy structure, I use id and parent id to represent the data in hierarchy form:

Id | parent_id
---+-----------
1 | 0
2 | 0
3 | 0
4 | 1
5 | 1
6 | 4
7 | 4
8 | 7
9 | 7


This structure requires complicated queries (recursive call) to find out all the child of a root node, so I have added another field for the root id.
Is this a good relational database design ? kindly suggest.

Id | parent_id | root_id
---+-----------+---------
1 | 0 |
2 | 0 |
3 | 0 |
4 | 1 | 1
5 | 1 | 1
6 | 4 | 1
7 | 4 | 1
8 | 7 | 1
9 | 7 | 1
10 | 2 | 2
11 | 2 | 2
12 | 10 | 2
13 | 10 | 2

Rgds
Vijay

View 3 Replies View Related

Parent Child Tables

Jul 20, 2005

In our database we have a list of devices in a "Device" Table, eachhaving one or more IP's located in the "IP" Table linked through aforein key on the DeviceID Column.I would like to retrieve this information as SuchDeviceID IpAddress1 10.0.0.1, 10.0.0.2, 10.0.0.32 ...345etc.Is it possible to do that without using cursors? Through a query?

View 1 Replies View Related

Get One Row From Detail/child Table

Jul 20, 2005

Hi,-- ddl/*create table #tmp (col1 int);insert into #tmp values(1);insert into #tmp values(2);insert into #tmp values(3);create table #tmpChild (col1 int, fkCol int, Num int);insert into #tmpChild values(1,1,3);insert into #tmpChild values(2,1,2);insert into #tmpChild values(3,2,1);*/-- get parent and child data (outer join)select *from #tmp t Left Outer JOIN #tmpChild tCON t.col1 = tC.fkCol-- resultset/*/col1 col1 fkCol Num----------- ----------- ----------- -----------1 1 1 31 2 1 22 3 2 13 NULL NULL NULL(4 row(s) affected)*/-- desired resultset/*/col1 col1 fkCol Num----------- ----------- ----------- -----------1 1 1 3-- eleminate next row, want only Max(Num) row from the child tbl withsame FK (parentID)-- 1 2 1 22 3 2 13 NULL NULL NULL*/In other words, desired results is as follows:/*/col1 col1 fkCol Num----------- ----------- ----------- -----------1 1 1 32 3 2 13 NULL NULL NULL*/How to accomplish this task? ENV: MS SQL Server 2000TIA

View 1 Replies View Related

Run Child Package Independently

Jul 27, 2006

Hi there

I have a parent package which execute a child package. But when the child package is run from the parent not all of the tools inside is executed. I have a variable "ExecuteStep" from the parent that gives information about which tools, that needs to be executed.

BUT

The child package should be able to run independently also. In this case all tools inside the package should execute.
This is however not possible because my variable "ExecuteStep" does not exist inside the package, it is inheritage from my parent.

If I create a variable with exactly the same name inside my child package, I can run the child independently, but when executed from the parent the value from the parent package is now overwritten by the child variable.

How can I get around this problem?

bjarne

View 1 Replies View Related

RetainSameConnection And Child Package

Apr 11, 2008



Hi all,

I am a little bit confused about Transactions, the connection string parameter "RetainSameConnection" and the execution of a child package...

I have a parent package, which should execute some child packages in a loop depending on a sql dataset. doing this using variables works fine. I am setting the variables for Source and Destination also and I am having a connection manager for source and destination in the parent package.

The child packages alos have source and destination connection managers depending on variables coming from the parent package.

I am forced to use transactions on the destination, to be able to rollback if an error occurs.

When I initiate the transaction in my parent, call the child package with its own connection manager depending on the variables coming from the parent package will it be the same Transaction in my child and will it be possible to commit the transaction?

If this is not a proper way to do it is there another way to handle this?

Any help appriciated!
Thanks in advice"

cheers
Markus

View 1 Replies View Related

Using Configurations On Child Packages

Feb 8, 2008

I searched for an answer for this, and found a few good threads, but none of them seem to be doing quite the same thing I'm trying to do.

I have two packages, parent and child. Parent does basic file manipulation -- encrypting/decrypting, moving from server to server, backing up to archive, pulling/pushing to external server via FTP, etc. It is completely dumb to what child does. Child is the guts of the data work -- the ETL package.

The goal is to have this one parent package be used by several ETL child packages. But not only can parent use different children (depending on which config is used when executing parent), but child can also handle different tasks, depending on a configuration it uses.

Let me break it down further.

Three packages:

ParentPackage - Used by all jobs
ChildPackage1 - Used for processing orders
ChildPackage2 - Used for processing inventory

Four configurations (thus four jobs):

Job1Configuration - Used for processing orders for ClientA
Job2Configuration - Used for processing orders for ClientB
Job3Configuration - Used for processing inventory for ClientA
Job4Configuration - Used for processing inventory for ClientB


Job1Configuration is set up to tell ParentPackage to use ChildPackage1, and to provide ChildPackage1 w/ various data for ClientA -- and so forth.

To my understanding, there is no passthrough of the config data from parent to child. A child package doesn't "inherit" or otherwise receive the information from the parent package, unless explicit variables are set up. This won't work for us, because ParentPackage is dumb of any data that the child packages may need. In other words, we don't want to set up ParentPacakge with every possible variable that every child package may need.

Also, I'm not aware of a way of setting up a job to provide a child package directly w/ a package configuration.

Is there any way to do what I'm trying to accomplish?

If I didn't explain something clearly, let me know and I will try to clarify.

Thanks in advance for your help.
Jerad

View 8 Replies View Related

Configurations And Child Packages

Aug 29, 2006



Hello,

I was hoping someone might be able to clarify how configuartions work with child packages. My process has 3 levels of packages. The main packages called two child packages each of which calls more child packages.

I'm using Configurations to pass variables from parent packages to child packages. But each level of packages contains Data Flow Source/Destination connections. I was planning on having only 1 XML Configuration file in the main package that would allow the data connections for the main package to be configured for the target enviornment. When the job is scheduled I will be able to point a configuration file for use with the main packages. But will that configuration file be applied to all child packages that will run? All of the Connections Managers have the same name so I'd like to make the change in one file.

If not, am I forced to define a parent/child variable to pass the Connection String from the parent to each of the child packages? Use an expression to set the Connection String dynamically? This seems like a lot of extra work, so I'd really like to see if there is a way to do it with an XML configuration file. Even if I have to definte the same config file for each of my 20+ packages.

Thanks

-Dan

View 5 Replies View Related

Master/Child Deployment

Jun 29, 2007

Hi Guru's,



I am facing a problem in deploying the SSIS packages.



My Scenario is like this



1. Have one Master SSIS Package.

2. Master SSIS Package inturn calls 3 Different packages using execute package task.

3. I have a common Configuration file for all these packages.

4. I am using File System deployment.

5. I have imported all the packages i.e master and the 3 child packages using SQL Server management studio.

6. Now i have created a job, and added the master package as a step.

7. I have a variable declared in the configuration file and the child packages will be getting their path from this variable.



The problem since i know the imported packages lies in "C:Program FilesMicrosoft SQL Server90DTSPackages<<Folder Name>>" i have poited the child package variable to point to this directory.



I still want to import all the packages and want to get this directory info dynamically thorugh the script so that i can assign this at run time.



I am using "Directory.GetCurrentDirectory" But it's giving me a different location when we run the master package.



Can any one has any idea or comments how to retrive the path of the master package?



Even a work around or any other option is also fine....



Regads,

Dev

View 1 Replies View Related

Can't Decrypy The Child Package?

Aug 25, 2006

I had a child package AAA

The ProtectLevel of AAA is "EncryptAllWithPassword" and PackagePassword is "passtest"



now I put a Execute Package Task on Control Flow TAB of Package BBB

in this task I want to Execute package AAA,after set Password "passtest" of Execute Package Task ,I execute package in command line

DTExec.exe /F BBB.dtsx



I get error message,

can't decrypt package AAA



Where can I set the PackagePassword of AAA in Execute Package Task.

View 6 Replies View Related

Share Variable With Child

Feb 22, 2007

How a parent package can share its variables with child when calling it using Execute Package Task ?

View 5 Replies View Related

Bulk Insertion In Child Tables???

Oct 23, 2007

Hi guys iam working on Sales Force Automation Application in which i have a senario where i create team (base table) and team users (child table) one team can have many users and so user can be in one or more team.
My question is what will be the best practise (performance wise) to add let suppose 100 users in a team in one go for example user can create of any number users present in the user list or How to insert bulk of records in child table .>>
iam using sql server 2000 +Asp.net 2005 (c#)
 

View 1 Replies View Related

Child Nodes Not Allowed. Web,config

Oct 25, 2007

Hi,
 I have a wierd error occuring here.
 <compilers>Line 95: <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/warnaserror-">Line 96: <providerOption name="CompilerVersion" value="v3.5"/></compiler>Line 97: <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/optioninfer+">Line 98: <providerOption name="CompilerVersion" value="v3.5"/></compiler></compilers></system.codedom>
 
Can someone help me about this one

View 2 Replies View Related

Selecting Parent / Child Relationships

Jun 28, 2004

Hello all, I'm having a real hard time trying to figure this one out. I'm trying to create a sql query that selects both the parent name and it's children, but it's got to loop through all the record sets to populate a drop down as an end result.

I think I thought this out correctly:
I have 2 tables

category
relationship

tbl category
cat_id //auto int
cat_name // varchar

relationship
r_id // auto int
parent_id // int
child_id // int

both the parent_id and child_id are associated with the cat_id
in my category table I could have
1cars // this is parent
2 audi
3 bmw
4 chevy

Table data example

r_id parent_id child_id
****************************
1 1 15
2 1 16
3 1 17
4 2 55
5 2 56
etc...
I want to select both the parent cat_name from category and also select the child cat_name where the parent_id = #

I can do it manaully like this
select cat_name, cat_id, parent_id , child_id from category, relationships where child_id = cat_id and parent_id = 1

what is the best way to loop through all the parent ids to find child category?
Could this be done in a stored procedure?

thanks in advance.

View 3 Replies View Related

Retrieve Values From Child Table

Feb 2, 2005

Hello there,

I need to get the last value (status) from a child table. I try to simplify the problem with the following example.

Create Table Users
(
UserId int,
Lastname nvarchar(50)
)

Create Table UserStatus
(
UserId int,
Date datetime,
StatusId int
)

Create Table Status
(
StatusId int
Status nvarchar(50)
)

A user will go through all Status one by one. (1) Registered -> (2) In progress -> (3) authorized.
Now I want to know which users are in progress (2) but a simple select statement like:

Select LastName from Users Inner Join Users.UsersId = UserStatus.UserId Where UsersStatus.StatusId = 2

Will not return the wanted records because all authorized Users have been in this status.

I hope you understand the problem and can help me out.

Thx in advance.

Etinuz

View 3 Replies View Related

Insert Trigger For Parent/Child

May 9, 2006

I am having problems creating a trigger in SQL Server? I have 2 tables (parent and child) with one to many relationship. When I save a record, one row gets inserted in the parent and one to many gets inserted in the child. The trigger is on the parent table and it is trying to select the number of new records just inserted in the child table that meets a certain criteria. Since the transaction hasn't been committed I can not select the number of records from the child. Does anyone know how to handle this? My manager insists this be done in a trigger.
Thanks, James

View 1 Replies View Related

SP Skips Execution Of Child SP When Called From C#

Sep 14, 2005

Hello all. I have a stored procedure that seems to skip the execution of an entire line of code (which happens to be a call to execute another stored procedure), but ONLY if it is being used from C# (using the System.Data.SqlClient namespace... object: SqlCommand, etc).

Basic structure:

Event SP: top-most parent
-->Calls UpdateXs SP: This is the SP that will not call his child SP
----->Calls UpdateX: This is the SP that is being ignored when called from .NET (In a loop, each iteration, max iterations 10).

(1) I can call the top-most stored procedure (Event SP) with the same arguments in Query Analyzer and all SP's will execute.
(2) I can call UpdateXs SP with the same arguments that are being passed to it from Event SP in the Query Analyzer, and again, it's child sp executes (UpdateX).
(3) I can also call the last child (UpdateX) directly in Query Analyzer with the same arguments that are passed in production (from executing the top-most parent in C#), and it executes correctly.

I'm positive that at no point the last child (UpdateX) is being passed NULL values. I made debug tables and before execution of an SP from within another SP, I store all the arguments in a debug table--none are null. Also, to figure out what was wrong with the last child (UpdateX) , the first statement in inserts into another debug table, just to show that that execution has made it into the sp--when the top parent is called from C#, it doesn't insert into my table (doesn't execute).

There are statements inside Event SP that execute after the sp call to UpdateXs SP. These statement always execute. Also, there are statements inside UpdateXs SP that execute after the sp call to the last child. These statement always execute too.

I am now clueless. I had developed & debugged all sp's in Query Analyzer before trying to use it live (with the C#). It's always fine in Query Analyzer, but ALWAYS skips the last sp in production.

Is there some fundamental principle I am missing here in MS SQL stored procedures? I am only 3 levels deep in SP calls, so I didn't think that would be an issue (I have made SP's that went a LOT deeper in calls than that in the past with no issues).

Any insight much appreciated. Thanks in advance.

View 2 Replies View Related

Inserting Master And Child Records

Nov 5, 2004

Hi,

I need to insert a record in a master table and 20 records in a child table. I want to do this using stored procedure. Is it better to do it in stored procedure? Have somebody already tried this? Or is there any sample that I can use?

Thanks a lot!

View 1 Replies View Related

Passing Variables In Dts From Parent Dts To Child Dts

Dec 24, 2004

Any one have any ideas or links to point me to ???

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved