Solved

Default column to Null value

Posted on 2013-06-14
3
568 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
  • 2
3 Comments
 
LVL 13

Expert Comment

by:Jesus Rodriguez
Comment Utility
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
Comment Utility
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
Comment Utility
Thx i'll try it.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now