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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 problem in merge

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2008-05-20 : 16:08:54
insert #tbl_websubmissions11
select *
from #tbl_nostatements4

I got following error:
Server: Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'statementreceiveddate', table 'tempdb.dbo.#tbl_websubmissions11_______________________________________________________________________________________________00000000052C'; column does not allow nulls. INSERT fails.
The statement has been terminated.


This code used to work in sql2000, we just update our system to sql server 2005. it fails to work.
Please give suggstion how to fix this problem.
Thanks.
Jeff

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-20 : 16:19:52
You need to update the #tbl_websubmissions11 table so that the statementreceiveddate allows nulls.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2008-05-20 : 16:27:26
better yet use @TableVariables
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-20 : 16:32:05
quote:
Originally posted by yosiasz

better yet use @TableVariables



You can't make a blanket statement like this plus it doesn't solve the problem. There are times where using local temp tables are better than table variables. For instance, row count matters, whether or not you need to apply indexes, and whether or not you need to insert into these from a stored procedure.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page
   

- Advertisement -