Page 1 of 1

newsequentialid() doesn't return value on MSQuery.Post

Posted: Wed 20 Mar 2013 13:00
by Alexander_73
table:

Code: Select all

CREATE TABLE [dbo].[PrintInfo](
	[ID] [uniqueidentifier] NOT NULL,
	[FirmID] [int] NOT NULL,
	[FirstInvoiceID] [int] NULL,
	[AddDate] [datetime] NOT NULL,
	[Attributes] [int] NOT NULL,
 CONSTRAINT [PK_PrintInfo] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PrintInfo] ADD  CONSTRAINT [DF_PrintInfo_ID]  DEFAULT (newsequentialid()) FOR [ID]
Then field default is newsequentialid() it doesn't return on MSQuery.Post params (both OnBeforeUpdateExecute assigned or not) and raises exception 'field must have value',
but if field default value is newid(), it works OK.

Re: newsequentialid() doesn't return value on MSQuery.Post

Posted: Wed 20 Mar 2013 13:55
by AndreyZ
NEWSEQUENTIALID() cannot be referenced in queries, it can only be used with DEFAULT constraints on table columns of type uniqueidentifier. That is why, there is no way to obtain the value of NEWSEQUENTIALID() on the client by queries. As you use NEWSEQUENTIALID() for the PRIMARY KEY field, the only way to obtain its value is to refresh all dataset.
Another solution is to use NEWID() . NEWID() can be referenced in queries, that is why SDAC can obtain its value on the client.