SQL DB Connector, GUIDs

I’m trying to execute INSERT INTO with SQL Database Connector plugin and MS SQL. The sentence is

INSERT INTO [dbo].[Term] ([Id], [LanguageId]) VALUES ( NEWID(), CONVERT(UNIQUEIDENTIFIER, @LanguageID) )

Table is defined as

CREATE TABLE [dbo].[Term] (
    [Id]           UNIQUEIDENTIFIER NOT NULL,
    [LanguageId]   UNIQUEIDENTIFIER NOT NULL,
    CONSTRAINT [PK_Term] PRIMARY KEY CLUSTERED ([Id] ASC),
    CONSTRAINT [FK_Term_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
);

If I set the parameter like this:

connector gives me error message “Conversion failed when converting from a character string to uniqueidentifier”. This works, though:

INSERT INTO [dbo].[Term] ([Id], [LanguageId]) VALUES ( NEWID(), CONVERT(UNIQUEIDENTIFIER, '8f6f178c-50b9-4d5a-9311-a2f301703f88') )

I tried all sorts of tricks and CONVERTs but nothing works.

Finally, CAST(CAST(@parameterName AS CHAR(36)) AS UNIQUEIDENTIFIER) works … uh oh …

I think its caused by Bubble’s text being of type VARCHAR

Not sure, according to this table the conversion from VARCHAR or CHAR should be pretty much the same … Maybe the number of chars is important (36) - I’ll try it out, since it would shorten my SQL statements :slight_smile:

This works now without any casting.