Unix Technical Forum

QA tells me my table is ambiguous

This is a discussion on QA tells me my table is ambiguous within the SQL Server forums, part of the Microsoft SQL Server category; --> Can someone help with this syntax? I have a non-sensicle example below, but it illustrates the problem if you ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 07:08 AM
john.livermore@inginix.com
 
Posts: n/a
Default QA tells me my table is ambiguous

Can someone help with this syntax? I have a non-sensicle example
below, but it illustrates the problem if you copy/paste into QA.

**********************************

use pubs
go

update authors set address = 'some address'
from authors a
inner join authors a2 on a.zip = a2.zip

---------------------------------------------

Server: Msg 8154, Level 16, State 1, Line 2
The table 'authors' is ambiguous.


**********************************

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 07:09 AM
Jackie Brophy
 
Posts: n/a
Default Re: QA tells me my table is ambiguous

It needs to know which alias to update a or a2.

update a set address = 'some address'
from authors a
inner join authors a2 on a.zip = a2.zip

Jackie

<john.livermore@inginix.com> wrote in message
news:1114025028.974990.86780@o13g2000cwo.googlegro ups.com...
> Can someone help with this syntax? I have a non-sensicle example
> below, but it illustrates the problem if you copy/paste into QA.
>
> **********************************
>
> use pubs
> go
>
> update authors set address = 'some address'
> from authors a
> inner join authors a2 on a.zip = a2.zip
>
> ---------------------------------------------
>
> Server: Msg 8154, Level 16, State 1, Line 2
> The table 'authors' is ambiguous.
>
>
> **********************************
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 07:09 AM
john.livermore@inginix.com
 
Posts: n/a
Default Re: QA tells me my table is ambiguous

thx!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 07:09 AM
Gert-Jan Strik
 
Posts: n/a
Default Re: QA tells me my table is ambiguous

Of course, instead of the Microsoft proprietary syntax, you could also
write this statement with the ANSI SQL compliant syntax, as follows:

-- Note: The update is still non-sensicle...
UPDATE Authors
SET Address = (
SELECT 'some address'
FROM Authors A2
WHERE A2.zip = Authors.zip
)

HTH,
Gert-Jan


john.livermore@inginix.com wrote:
>
> Can someone help with this syntax? I have a non-sensicle example
> below, but it illustrates the problem if you copy/paste into QA.
>
> **********************************
>
> use pubs
> go
>
> update authors set address = 'some address'
> from authors a
> inner join authors a2 on a.zip = a2.zip
>
> ---------------------------------------------
>
> Server: Msg 8154, Level 16, State 1, Line 2
> The table 'authors' is ambiguous.
>
> **********************************

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com