Solved

Default column to Null value

Posted on 2013-06-14
3
574 Views
Last Modified: 2013-06-14
I want to Default my addnum column = null Where parcel.address_ID is null. Both in the same table.

In the Default Value or Binding Column properties i added this but its not working.  ('Set addnum = null Where parcel.address_ID is null')

I would like my addnum column to be populated with a Address Vale or be null.
Addnum column is nvarchar(10)
Address_ID colunm is INT

Thanks
0
Comment
Question by:PtboGiser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Expert Comment

by:Jesus Rodriguez
ID: 39248257
You need to use a trigger on Insert.
Just check to see if a value has been assigned, and if not, go grab the correct one and use it
0
 
LVL 13

Accepted Solution

by:
Jesus Rodriguez earned 500 total points
ID: 39248291
Must be something like this

USE Your_Database
GO
IF OBJECT_ID ('Parcel.CheckParcelAddress', 'TR') IS NOT NULL
   DROP TRIGGER Parcel.CheckParcelAddress;
GO
CREATE TRIGGER CheckParcelAddress
ON Your_Database.Parcel
AFTER INSERT, UPDATE
AS
  UPDATE Parcel
  SET ADDNUM=NULL
  WHERE ADDRESS_ID IS NULL
GO
0
 

Author Comment

by:PtboGiser
ID: 39248613
Thx i'll try it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question