Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

Default column to Null value

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
PtboGiser
Asked:
PtboGiser
  • 2
1 Solution
 
Jesus RodriguezIT ManagerCommented:
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
 
Jesus RodriguezIT ManagerCommented:
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
 
PtboGiserAuthor Commented:
Thx i'll try it.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now