473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Left Joins and record insert problem



I have a situation where I'm trying to add a text field to allow
large Notes to be linked to record in an existing table (rather than
simply adding the new field into the table since relatively few
records will have the Note)

Tables are basically:

T1
ID InvNumFK
----------------------
40 | 1
42 | 2
43 | 2
44 | 1

T2
MatDetId EqpNote
-------------------------------------------------
40 | text
44 | additional Note

I'm trying to create a subform that will allow the user to view/update
records in T1 (there are other fields in T1 that aren't relevant to
the problem) and also add a record into the T2.EqpNote field or edit a
record that already exists.

This query works in Access (allows me to type in text into the EqpNote
field and automatically create a new record in T2 with the T1.Id value
in the T2.MatDetId field) :
SELECT T1.ID, T1.InvNumFK, T2.EqpNote, T2.MatDetId
FROM T1 LEFT JOIN T2 ON T1.ID = T2.MatDetId
WHERE (((T1.ID)=10230));

but when I try to 'translate' it into a version that I can use for the
subform in the adp (it's an Access 2000 project with a SQL Server 2000
backend) the 'child' record does not get added into T2.

Here's the record source I'm using for the form in the adp
SELECT T1.ID, T1. InvNumFK, T2.MatDetId, T2.EqpNote FROM T1 LEFT
OUTER JOIN dbo.T2
ON T1.ID =T2.MatDetId
WHERE T1.InvNumFk = XX
--'master' table
CREATE TABLE [dbo].[T1] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[InvNumFK] [int] NOT NULL

) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tblBSMaterialDet] WITH NOCHECK ADD
CONSTRAINT [PK_T1] PRIMARY KEY NONCLUSTERED
(
[ID]
) ON [PRIMARY]
GO

--Sub table
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[T2]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T2]
GO

CREATE TABLE [dbo].[T2] (
[MatDetId] [int] NOT NULL ,
[EqpNote] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[T2] WITH NOCHECK ADD
CONSTRAINT [PK_T2] PRIMARY KEY CLUSTERED
(
[MatDetId]
) ON [PRIMARY]

Apr 13 '06 #1
2 1872
My hunch is that your problem is with the text field. Sql server is
very touchy with text fields. I do know that the data in a text field
does not reside in the table that the text field is defined in.

If it is possible in your design, you might try changing the field to
nvarchar(8000) if that is enough chars for your needs.
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 13 '06 #2
Hello,

This question is more about Access ADP-s than about SQL Server. The
easiest way to solve this is to use another subform for the T2 table
(linked to the parent form by the MatDetId column, using
LinkChildFields/LinkMasterFields), so that each form is bound to
exactly one table. As long as you are not using datasheets (and since
we are talking about large notes, I suppose that datasheets are out of
the question), you can use a subform with a transparent border so the
user won't even notice that there is a subform.

Razvan

Apr 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Marek Kotowski | last post by:
In MySQL online documentation there are some examples with multi-tables left joins. But all of them are like this (taken from the documentation): SELECT ... FROM table1 LEFT JOIN table2 on...
1
by: Quarco | last post by:
Hey, Suppose you have a table_ex like: id nuber1 chr ( = a or b) 1 1000 a 2 1001 a 3 1002 b 4 1003 a etc..
4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
7
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins"...
3
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
9
by: Alan Lane | last post by:
Hello world: Background: Yesterday, January 21, Doug Steele was kind enough to help me out on a Left Join problem. I was trying to return all stores and their Gross Adds for December, 2004...
1
by: ckirby | last post by:
I have a situation where I'm trying to add a text field to allow large Notes to be linked to record in an existing table (rather than simply adding the new field into the table since relatively...
3
by: nico3334 | last post by:
I currently have a query that Joins 2 Tables (Table1 and Table2) using LEFT OUTER JOIN. Here is an example of that query: SELECT a.supply, a.state, b.cost FROM Table1 a LEFT...
9
by: shapper | last post by:
Hello, I am used to SQL but I am starting to use LINQ. How can I create Left, Right and Inner joins in LINQ? How to distinguish the different joins? Here is a great SQL example:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.