Thanks, I was able to get it and it looks like it is working correctly. I need to do further testing on it, but it appears now that it is working. I had to modify the query a bit for my purposes but finally got it. Thanks again.
When I take your query and paste it into SQL analyzer I get the following 3 errors
Msg 8156, Level 16, State 1, Line 1
The column 'Id' was specified multiple times for 'TB'.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "TableB.Id" could not be bound.
Msg 8156, Level 16, State...
This helps me with the sub select structure, thanks a lot. When I break the query down and run it piece by piece, I notice the the inner most select statement
Select Id, max(Update_date) As UpdateDate
From TableC
Group By Id
returns the single record like I am anticipating. When I add the...
Thanks kaht. That is currently what I have, but table B and table C have the capability to have multiple rows for each parent record. I need to return every row in the parent table (table A) and then a single element in table B based on the most current row (determined by date column in the...
Sorry, max record should be defined as the record with the most current date in each of the child tables. So something like select max(update_date) from table B, etc.
Hello,
I have 3 tables
Table A - Parent Table
Table B - Child of A with a 1...n relationship
Table C - Child of A with a 1...n relationship
When I do a simple select
SELECT *
FROM table A x left outer JOIN
table B y on x.id = y.id left outer JOIN
table C z on x.id = z.id
It will return...
Just a question for all of you gurus out there. I am currently running insert and update SQL statements similar to the following:
PRINT 'UPDATING Table1
UPDATE Table1
SET val1 = X.val1,
val2 = X.val2
FROM XML_Table1 X
WHERE Table1.VIN=X.VIN
PRINT 'INSERTING INTO Table1...
I understand that, but is there a way to take a browser action like a button click or a key stroke and execute a task on an object that I have created server side?
I have created and opened and executed a task on an object in my asp code like below
set obj = Server.CreateObject("....")
obj.Open (... , ...)
obj.Exec (task1)
I need the user to be able to click a button or perform a keystroke that will execute "task2" on that same object. I am having...
Excellent, that works great. I appreciate all of your help on this. It was very helpful for me. One last question, how do I release the #del_t4 ... variable so taht I can run the procedure over and over. Right now, unless I rename the variables, I get a SQL error saying it already exists...
That won't work. I have tried that. SQL 3 works fine, SQL 1 works fine, but then SQL 2 (which contains a join to t1) returns 0 rows affected and does not delete the record needed due to the join it has to t1 who's record was deleted in the previous step (SQL 1). Any other ideas?
Okay, the selects work fine when I run them but the deletes give me a foreign key constraint error on the second SQL. The other problem I have is after I run teh first SQL, the other 2 SQL's don't delete anything because there is nothing to join to. Any ideas?
These return me a null set when I run them. I modified them slightly to perform a select rather than a delete so I could see the record results. In my test database I have 2 records, one of which I need to clean up because it has an older update date. The first query I am running is as...
I have a very complex problem that I need some assistance with for anyone willing to tackle this. Here is the situation.
I have 4 relational tables (T1, T2, T3, T4). T1 is the parent table with the PK being v_seq_num. T3 has a pk of l_seq_num. T2 contains an update_date field that I need to...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.