Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converstion Failed
Message
 
 
À
24/04/2009 02:32:32
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01396197
Message ID:
01396289
Vues:
70
Why are you comparing a string value of [test ID] to a number 36? When you do that SQL Server tries to convert the string to integer and fails on the value that is not an integer. You should compare string to string.
SELECT [test ID])  FROM Data42 where [test ID] = '36'
Also, thre's no reason to use a local variable for a CURSOR name
DECLARE  testvalue CURSOR FOR
  SELECT [test ID])  FROM Data42 where [test ID] = '36'
OPEN testvalue
...
>
>I am also having same problem but its not because of the list , i am using a store proc below :
>
>
>CREATE PROC dbo.testingloop
>
>(
>
>DECLARE @testid varchar(max)
>)
>
>AS
>BEGIN
>SET NOCOUNT ON
>
>DECLARE @SQL varchar(600)
>
>SET @testvalue = CURSOR FOR
>SELECT [test ID]) FROM Data42 where [test ID] = 36
>
>OPEN @testvalue
>
> FETCH NEXT
> FROM @testvalue INTO @testid
>
> WHILE @@FETCH_STATUS = 0
>
> BEGIN
>
> ' My update statement here
>
> END
>
>END
>
>but i am getting error where there is a [test id] value 12345 - 5 , actually in Data42 table the type of [test id] is nvarchar and in my updating table is varchar , but i think the error is at line 'SET @testvalue = CURSOR FOR
>
>My Error Message 'Conversion failed when converting the varchar value '12345-2' to data type int.'
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform