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 2005 Forums
 Transact-SQL (2005)
 Error with script with more than expression

Author  Topic 

johnjh
Starting Member

4 Posts

Posted - 2007-09-21 : 14:18:43
Hi,

I try to run the script below to update data with trailing CR on QL 2005 and got this error. I remember I used the same script on SQL 2000 a while back and worked fine. What can I do to fix it?

"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS"

Thanks,
John

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-09-21 : 14:21:15
Can you post the script?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

johnjh
Starting Member

4 Posts

Posted - 2007-09-21 : 15:56:29
Oops, sorry, here is the script.

DECLARE @CR varchar (100)
SET @CR= '%'+char(13)
UPDATE SyUserValues SET FieldValue=REPLACE(FieldValue,CHAR(13),'') WHERE FieldValue IN (SELECT * FROM SyUserValues WHERE FieldValue LIKE @CR)

Go to Top of Page

johnjh
Starting Member

4 Posts

Posted - 2007-09-21 : 15:59:48
This is the correct one.

DECLARE @CR varchar (100)
SET @CR= '%'+char(13)
UPDATE SyUserValues SET FieldValue=REPLACE(FieldValue,CHAR(13),'') WHERE FieldValue IN (SELECT * FROM SyUserValues WHERE FieldValue LIKE @CR AND SyUserDictID in (1, 2, 3))
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-09-21 : 16:20:46
The problem is here: WHERE FieldValue IN (SELECT *

You need to specify a column instead of *.


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

johnjh
Starting Member

4 Posts

Posted - 2007-09-21 : 16:26:17
Awesome, it works now! Thank you so much!
Go to Top of Page
   

- Advertisement -