473,786 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MULTI-Table Update Queries

I'm new to adp w/ sql server but I have to use it on a project i'm
doing...
One of the MUSTS for this project is the ability to update a 00 - 09
text value with the appropriate text description from another table...
Easy as pie in .mdb. Of course In the stored procedure it barks at me
and tells me that an update query can only have one table.. ouch that
hurts...
I'm currently reading on the subject but this group has been very
helpful in the past.....

I found this link...
http://www.sqlservercentral.com/colu...theeasyway.asp

Unfortunetly I'm using MSDE not Enterprise so I don't think I can use
the query analyser.. But I tryed it in my Access ADP anyway
it barked at me..

I tried to go from this....

SELECT dbo.LU_SEX.SEX_ CODE, dbo.TEST.DEFECT S_DP1
FROM dbo.TEST INNER JOIN
dbo.LU_SEX ON dbo.TEST.SEX_DP 1 =
dbo.LU_SEX.SEX_ DEC

To this...

UPDATE dbo.TEST.SEX_DP 1
SET dbo.TEST.SEX_DP 1 = dbo.LU_SEX.SEX_ CODE
FROM dbo.LU_SEX INNER JOIN
dbo.TEST ON dbo.LU_SEX.SEX_ DEC =
dbo.TEST.SEX_DP 1

Maybe I need a good book on this?

Thanks,
Charles

Jul 23 '05 #1
2 8313
It looks like you wanted:

UPDATE dbo.TEST
SET dbo.TEST.SEX_DP 1 = dbo.LU_SEX.SEX_ CODE
FROM dbo.LU_SEX
JOIN dbo.TEST
ON dbo.LU_SEX.SEX_ DEC = dbo.TEST.SEX_DP 1

The table name follows the UPDATE keyword, not the column name.

This is the MS proprietary syntax for an UPDATE statement. There is a
potential problem with that method if you try to update using a join
that doesn't return a unique value for each row. No error is returned
but the result is undefined and may be unreliable. This is one reason I
prefer the ANSI Standard UPDATE syntax, which SQL Server also supports:

UPDATE Test
SET sex_dp1 =
(SELECT sex_code
FROM LU_Sex
WHERE sex_dec = Test.sex_dp1)

I'm guessing this will be the equivalent of what you posted. It will be
so long as sex_dec is unique in LU_Sex and all the values of sex_dp1
also exist in that table.

Presumably you ultimately intend to use one set of codes througout the
database. There is in fact an International standard for gender codes
(0=not known 1=male 2=female 9=not specified). You could also use views
to convert the codes if you need to do so for display for example.

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
(me*****@yahoo. com) writes:
I tried to go from this....

SELECT dbo.LU_SEX.SEX_ CODE, dbo.TEST.DEFECT S_DP1
FROM dbo.TEST INNER JOIN
dbo.LU_SEX ON dbo.TEST.SEX_DP 1 =
dbo.LU_SEX.SEX_ DEC

To this...

UPDATE dbo.TEST.SEX_DP 1
You have a database dbo with a schmea TEST and table SEX_DP1?
Drop SEX_DP1 to start with.
SET dbo.TEST.SEX_DP 1 = dbo.LU_SEX.SEX_ CODE
And here drop dbo.TEST on the left-hand side. You can uses prefixes on
the left-hand side, but I don't recall under which circumstances. In any
case, since you can only update one table at a time, it's redundant.
FROM dbo.LU_SEX INNER JOIN
dbo.TEST ON dbo.LU_SEX.SEX_ DEC =
dbo.TEST.SEX_DP 1
This should be fine, although I recommend you to use aliases to make
your queries less verbose.

Maybe I need a good book on this?


Books Online, see signature.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3

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

Similar topics

37
4899
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours, Pujo
4
4677
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
3880
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
0
3789
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black and white CCITT4 compressed files (frames) inside the tiff. Every now and then I receive a mixture of black and white CCITT4 and JPEG compressed files, and sometimes just multi-page tiffs with JPEG only. The code runs great when dealing with the...
6
8183
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
17878
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
5
6000
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a TIFF to several PNG files this causes a problem, becuase the resulting image is (the page to the far left and a lot of black space surrounding it and a filesize that is larger than needed. Any ideas?
5
3287
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify this? Private Sub cmdPreview_Click() On Error GoTo Err_Handler 'Purpose: Open the report filtered to the items selected in the list box. 'Author: Allen J Browne, 2004. http://allenbrowne.com Dim varItem As Variant 'Selected items
0
2329
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing Systems (MuCoCoS'08) Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08. <http://www.par.univie.ac.at/~pllana/mucocos08> *********************************************************************** Context
2
4658
by: Aussie Rules | last post by:
Hi, I have a site that Iwant to either display my text in english or french, based on the users prefernces ? I am new to webforms, but I know in winforms, this is pretty easy with a resource file. What is the best way to acheive this with webforms ?
0
9650
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8992
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.