SELECT [Id], @text FROM [dbo].[A_Stat_Connections_1x1] where [IdChain] = @IdChain 

idChain is a uniqueidentifier type field, @idChain is a variable in a program that receives this field at runtime. The data is written to it, I checked. If you remove the variable and just insert 'idchain (сам uid цепочки)' in brackets, then everything is ok and I set the variable, then I write an error

 conversion failed when converting from a character string to uniqueidentifier oktell 

tried (SELECT CONVERT(uniqueidentifier,@id_chain)) ,

Does not help. What can be done with this?

  • Did you give all the necessary code? Where are the variable definitions? - Alexander Muksimov
  • The fact is that this makes the program interface. It sets these values ​​to it without ads here in the request. When I log I see this idChain - oleg zhigulev
  • and it really coincides with idChain in the table [dbo]. [A_Stat_Connections_1x1] - oleg zhigulev

1 answer 1

In order for a string to be converted to a GUID, it must be of the form 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', where 'x' is a hexadecimal digit, and hyphens are necessarily present in their places.

  • [loc_idchain] ce1e8c4d-0e90-41ee-b8cd-026a45be54e6 is what should be recorded, loc_idchain is the name of the variable, @idChain and loc_idchain are the same, I just set the idchain value to loc_idchain - oleg zhigulev