SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Error converting data type nvarchar to float


Error converting data type nvarchar to float

Author
Message
peter478
peter478
Old Hand
Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)

Group: General Forum Members
Points: 317 Visits: 313
Yes John, this is it, what I was looking for Smile

Thank you very much for your help!

Peter
peter478
peter478
Old Hand
Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)

Group: General Forum Members
Points: 317 Visits: 313
Hi ,

one more thing:

ALTER Procedure dbo.UPdata
(
@e_Nplan char(20),
@e_Ncas char(20)
)
As


Update Cis_OP_NO
SET N_Cas100ks = convert(float,replace(@e_Ncas,',','.'))
Where N_Kplan = @e_Nplan

return

Error message:
Subquery returned more than 1 value. This is not premitted when the subquery follows =, =! , ....

Could you give some suggests how to solve it?
Thanks
Jan Van der Eecken
Jan Van der Eecken
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2440 Visits: 6494
peter478 (5/21/2009)
Hi ,

one more thing:

ALTER Procedure dbo.UPdata
(
@e_Nplan char(20),
@e_Ncas char(20)
)
As


Update Cis_OP_NO
SET N_Cas100ks = convert(float,replace(@e_Ncas,',','.'))
Where N_Kplan = @e_Nplan

return

Error message:
Subquery returned more than 1 value. This is not premitted when the subquery follows =, =! , ....

Could you give some suggests how to solve it?
Thanks


Peter,

The code you posted above can't be the entire stored proc code, since the error message talks about a subquery. Please post the entire procedure as well as a script to create the table Cis_OP_NO and to populate it with some test data. Makes everyone's life easier and will get you proper answers much quicker.

Regards,
Jan

--------------------------------------------------------------------------
A little knowledge is a dangerous thing (Alexander Pope)

In order for us to help you as efficiently as possible, please read this before posting (courtesy of Jeff Moden)
peter478
peter478
Old Hand
Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)

Group: General Forum Members
Points: 317 Visits: 313
Hi ,

There is the only stored procedure which is called through MS access.
On this table are some triggers but I think that it should not be the problem.
Triggers provides updates of values when someone change a specific field of table.
If I update row (id = 3) from the table there is not problem ...proc works.
but when I want to update more then one row with same value (N_kplan = 112a) then appiers error.
Tbale Cis_OP_No was created manualy via MS Access

Cis_OP_No:
------------
id int
N_Kplan varchar
N_Cas100ks float
etc...

id N_kplan N_Cas100ks
----------------------------------
1 112a 15.78
2 112a 78.56
3 456b 78
4 741C 30.24
Sergiy
Sergiy
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10314 Visits: 11961
peter478 (5/23/2009)
Hi ,

On this table are some triggers but I think that it should not be the problem.

That's exactly the problem.
Badly written triggers with subqueries built with an assumption that only 1 row is updated always cause this kind of problems.
peter478
peter478
Old Hand
Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)

Group: General Forum Members
Points: 317 Visits: 313
so what would you suggest ? How to solve this problem, because I need these triggers...
Steve Jones
Steve Jones
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: Administrators
Points: 62286 Visits: 19102
You might need to rewrite the trigger. That error cannot magically go away, you need to write sub-queries that do not return more than one value.

If you need help, you need to post code.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Sergiy
Sergiy
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10314 Visits: 11961
peter478 (5/24/2009)
so what would you suggest ? How to solve this problem, because I need these triggers...

You may replace badly written triggers with better written ones.
peter478
peter478
Old Hand
Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)

Group: General Forum Members
Points: 317 Visits: 313
Here are 2 triggers which are applied on table.

ALTER TRIGGER Cis_OP_No_Trigger1
ON dbo.Cis_OP_No
FOR INSERT, UPDATE
AS
IF (UPDATE (N_Vyrobok) or UPDATE (N_Kplan))
update Cis_OP_No set N_Vyrobok2 = (select ( i.N_Vyrobok + '/' +i.N_KPlan) from Cis_OP_No p inner join inserted i on p.N_ID = i.N_ID)
from Cis_OP_No p inner join inserted i on p.N_ID = i.N_ID


ALTER TRIGGER Cis_OP_No_Trigger2
ON dbo.Cis_OP_No
FOR INSERT, UPDATE
AS
IF UPDATE (N_Cas100ks)
update Cis_OP_No set N_KS_Hod = (select (((450/i.N_Cas100ks)*100)/8) from Cis_OP_No p inner join inserted i on p.N_ID = i.N_ID)
from Cis_OP_No p inner join inserted i on p.N_ID = i.N_ID

Table Cis_OP_No:
N_ID int
N_Cas100ks float
N_Vyrobok nvarchar
N_Kplan nvarchar
N_KS_Hod int
N_vyrobok2 nvarchar
N_rucne int

N_ID N_Cas100ks N_vyrobok N_kplan N_KS_Hod N_Vyrobok2 N_rucne
1----------5.73----------456000------001------982-------------456000/001---0
2----------5.73----------123000------001------982-------------123000/001---0
3----------7.71----------888000------003b-----730-------------888000/003b--0

ALTER Procedure dbo.UPdata
(
@e_Nplan char(20),
@e_Ncas char(20)
)
As

Update Cis_OP_NO
SET N_Cas100ks = convert(float,replace(@e_Ncas,',','.'))
Where N_Kplan = @e_Nplan

return

Error message:
Subquery returned more than 1 value. This is not premitted when the subquery follows =, =! , ....

Thank you
Jan Van der Eecken
Jan Van der Eecken
SSCrazy
SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)SSCrazy (2.4K reputation)

Group: General Forum Members
Points: 2440 Visits: 6494
There is your problem. I bet you that when you run

select (((450/i.N_Cas100ks)*100)/8) from Cis_OP_No WHERE N_ID = @e_Nplan



you will get more than one row returned. As the error message tells you "This is not premitted when the subquery follows =, =! , ...."

As a matter of interest, why do you have two INSERT/UPDATE triggers, one for handling of updates to N_Vyrobok and one for N_Cas100ks? If I were you I would combine them into one.

--------------------------------------------------------------------------
A little knowledge is a dangerous thing (Alexander Pope)

In order for us to help you as efficiently as possible, please read this before posting (courtesy of Jeff Moden)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search