Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi

I am using following query for remove last latter from my column

update Table_Name set Column_Name=(select left(Column_Name,LEN(Column_Name)-1) as Lat
from Table_Name a where Column_Name like '%N') where Column_Name like '%N'



it gives an following Error
Please Help me.




<pre lang="xml">Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.&lt;/pre&gt;</pre>
Posted
Comments
Corporal Agarn 7-Apr-15 14:14pm    
The reason for the error is you are trying to put multiple values into one record. See OriginalGriff's solution for a better way to do this. If you must use an inline then there is a lot of work to get only the one value you want.
Slacker007 7-Apr-15 14:15pm    
Are there any applications that will need to be refactored, as well? I am curious as to why you have column names that need the last letter removed? Was this a test of some sort?

1 solution

Why not just use
SQL
UPDATE Table_name SET Column_Name = LEFT(Column_Name, LEN(Column_Name) - 1)
WHERE Column_Name LIKE '%N'


[edit]Missed out a "_"[/edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900