If will execute
following sql query in sql server:
SELECT NEWSEQUENTIALID()
We will get error
message :
The
newsequentialid() built-in function can only be used in a DEFAULT expression
for a column of type 'uniqueidentifier' in a CREATE TABLE or ALTER TABLE
statement. It cannot be combined with other operators to form a complex scalar
expression.
Cause: Function NEWSEQUENTIALID() can only be used in the expression of
default value of any column of a table. For example:
CREATE TABLE OrderHistory(
OrderId BIGINT PRIMARY KEY,
OrderKey UNIQUEIDENTIFIER DEFAULT(NEWSEQUENTIALID())
)
Insert statement:
INSERT INTO
OrderHistory(OrderId,OrderKey) VALUES(100,DEFAULT)
INSERT INTO
OrderHistory(OrderId) VALUES(100)
Solution:
There is another
function NEWID() which we can use instead of NEWSEQUENTIALID(). For example:
SELECT NEWID()
2 comments:
This blog post is really great; the standard stuff of the post is genuinely amazing.
web design agency
They developed an effective workflow for best design agencies which contributed to a smooth engagement. Their team's personable approach was impressive.
Post a Comment