Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Execution plan for Insert involving Primary key

Author  Topic 

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2012-08-27 : 05:57:13
Hi All,
I created an temporary table

create table #t_inner(
customer_id INT NOT NULL primary key
,name varchar(10)
)

Now i am going to insert a row into that table with the below query.
insert into #t_inner values(2,'ms sql server')

i get the EStimated execution plan for the above insert query i got below text in the argument section.

Argument:

|--Clustered Index Insert(OBJECT:([tempdb].[dbo].[#t_inner______000000035851].[PK__#t_inner__1C5B9100]),
SET:([#t_inner].[customer_id]=RaiseIfNull(2),[#t_inner].[name]=RaiseIfNull('ms sql server'))

what is the functionality of "RaiseIfNull()" function in the above argument,And how this query paln check the uniqueness and null value check for the primary key column (customer_id)?

Thanks...

M.MURALI kRISHNA

chadmat
The Chadinator

1974 Posts

Posted - 2012-08-28 : 02:22:24
This is not really documented anywhere, but I am pretty sure it is the function called that checks if the value is null, and raises an error if it is null and the column is not nullable.

-Chad
Go to Top of Page

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2012-08-28 : 06:08:30
Hi Chadmat,

Thanks alot for your reply,
From ur words let us assume that Raiseifnull() function is used to test nullabulity of an data going to insert into key column.

Then how can our query plan(from argument section of execution plan) check whether we are entering Duplicate data values or unique values into key column?

Regards

M.MURALI kRISHNA
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2012-08-28 : 13:16:10
[PK__#t_inner__1C5B9100] is the PK (Unique) constraint I believe.

-Chad
Go to Top of Page
   

- Advertisement -