You are here: Re: Table variables « MsSQL Server « IT news, forums, messages
Re: Table variables

Posted by Greg on 02/02/06 21:52

Hi Andrew,

You could answer the question yourself by running the queries as a
script in QA.. E.G

--START ANDREWS SCRIPT

DECLARE @workdates TABLE (
conflict CHAR(1),
workdate SMALLDATETIME
)


DECLARE @existing TABLE (
workdate SMALLDATETIME
)

insert @workdates values ('a', '2006-02-03')
insert @existing values ('2006-02-03')
insert @workdates values ('a', '2006-02-02')

--I need to do an update on the first table:
UPDATE @workdates
SET conflict = 'X'
FROM @existing s
WHERE workdate = s.workdate

-- FINISH ANDREWS SCRIPT

You'll find this error message..

Server: Msg 209, Level 16, State 1, Line 17
Ambiguous column name 'workdate'.

That answers your original post. The following is a working example -
note the syntax differences..

-- START GREGS SCRIPT
DECLARE @workdates TABLE (
conflict CHAR(1),
workdate SMALLDATETIME
)


DECLARE @existing TABLE (
workdate SMALLDATETIME
)

insert @workdates values ('a', '2006-02-03')
insert @existing values ('2006-02-03')
insert @workdates values ('a', '2006-02-02')

--I need to do an update on the first table:
UPDATE w
SET conflict = 'X'
FROM @existing s JOIN @workdates w ON w.workdate = s.workdate

-- FINISH GREGS SCRIPT

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация