Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Update using a select for where

Author  Topic 

leahsmart
Posting Yak Master

133 Posts

Posted - 2003-08-20 : 04:57:11
Hi Reader

I am trying to do the below:


DECLARE @LibraryID as Int
SET @LibraryID = 38

UPDATE [eBenchmark].[dbo].[tblLibraryData]
SET Data = 'ABCDEFG'
WHERE DataID = SELECT CC_Package FROM tblLibrary WHERE LibraryID = @LibraryID

But I get the error
Incorrect syntax near the keyword 'SELECT'.

Is it possible to do the above?

Thanks

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2003-08-20 : 05:25:13
UPDATE [eBenchmark].[dbo].[tblLibraryData]
SET Data = 'ABCDEFG'
WHERE DataID =(SELECT CC_Package FROM tblLibrary WHERE LibraryID = @LibraryID) should work


Cheers,
Frank
Go to Top of Page

leahsmart
Posting Yak Master

133 Posts

Posted - 2003-08-20 : 05:32:32
Thanks! What a silly thing to forget!
Go to Top of Page
   

- Advertisement -