SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Execution plan for Insert involving Primary key
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mmkrishna1919
Yak Posting Veteran

India
54 Posts

Posted - 08/27/2012 :  05:57:13  Show Profile  Reply with Quote
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

USA
1958 Posts

Posted - 08/28/2012 :  02:22:24  Show Profile  Visit chadmat's Homepage  Reply with Quote
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

India
54 Posts

Posted - 08/28/2012 :  06:08:30  Show Profile  Reply with Quote
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

USA
1958 Posts

Posted - 08/28/2012 :  13:16:10  Show Profile  Visit chadmat's Homepage  Reply with Quote
[PK__#t_inner__1C5B9100] is the PK (Unique) constraint I believe.

-Chad
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000