-
Juan Alejandro Lam López
- PowerBuilder
- Saturday, 11 July 2026 07:57 PM UTC
I am currently working with the following environment:
PowerBuilder 2025 R2, Build 6430
Microsoft OLE DB Driver 19 for SQL Server
Microsoft SQL Server 2022 and SQL Server 2025
I have identified a possible issue when attempting to create a DataWindow based on a stored procedure that receives a UNIQUEIDENTIFIER parameter.
The table has the following structure:
CREATE TABLE [dbo].[DemoGuid]
(
[IdDemo] [uniqueidentifier] NOT NULL,
[Name] [varchar](150) NULL,
CONSTRAINT [PK_DemoGuid]
PRIMARY KEY CLUSTERED
(
[IdDemo] ASC
)
);
GO
ALTER TABLE [dbo].[DemoGuid]
ADD CONSTRAINT [DF_DemoGuid_Id]
DEFAULT (NEWSEQUENTIALID()) FOR [IdDemo];
GO
The stored procedure is defined as follows:
CREATE OR ALTER PROCEDURE dbo.USP_DemoGuid_SELECT_BY_ID
(
@IdDemo UNIQUEIDENTIFIER = NULL
)
WITH EXECUTE AS CALLER
AS
BEGIN
SET NOCOUNT ON;
SELECT
P.IdDemo,
P.Name
FROM dbo.DemoGuid AS P
WHERE P.IdDemo = @IdDemo;
END;
GO
When I try to create a DataWindow through the DataWindow Wizard and select this stored procedure as the data source, PowerBuilder displays the following error:
Cannot create DataWindow.
SQLSTATE = 22018
Microsoft OLE DB Driver 19 for SQL Server
Error converting data type nvarchar(max) to uniqueidentifier.
1 execute dbo.USP_DemoGuid_SELECT_BY_ID;1 @IdDemo = :IdDemo
The stored procedure works correctly when it is executed directly from SQL Server Management Studio using a valid UNIQUEIDENTIFIER value.
For example:
EXEC dbo.USP_DemoGuid_SELECT_BY_ID @IdDemo = '00000000-0000-0000-0000-000000000000';
The issue appears to occur during the DataWindow creation process. PowerBuilder seems to be sending or interpreting the retrieval argument :IdDemo as an NVARCHAR(MAX) value instead of handling it as a UNIQUEIDENTIFIER.
As a result, SQL Server attempts to convert an invalid NVARCHAR(MAX) value to UNIQUEIDENTIFIER, which produces SQLSTATE error 22018.
The same behavior occurs with both SQL Server 2022 and SQL Server 2025, so the issue does not appear to be related to a specific SQL Server version.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.