Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6033103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:26:05+00:00 2026-05-23T05:26:05+00:00

I am working in a DB which has about 10 DEFAULT constraints scattered by

  • 0

I am working in a DB which has about 10 DEFAULT constraints scattered by two or three different tables, and I need to write a stored procedure which receives as parameters values for all these attributes. However, if no values are received, I want these parameters to assume the default values in the corresponding table. Knowing that there is no easy way to do it, I thought about writing custom UDFs returning the default values, adding the constraints as DEFAULT (dbo.SomeFunction()) FOR [Attribute] and adding = dbo.SomeFunction() as the default value for each parameter. I would, however, like to ask what is the best way to accomplish this:

1) Write an UDF for every attribute, simplifying execution but ending up with 10 different functions; or

2) Write a single dbo.GetDefault(TableName NVARCHAR(32), AttributeName NVARCHAR(32) and use IF ... ELSE ... or SWITCH on the different table/attribute pairs.

What do you think?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:26:06+00:00Added an answer on May 23, 2026 at 5:26 am

    You should have one udf per default.

    • datatypes won’t be the same
    • as your code evolves you’ll end up with dependencies in computed columns or schemabound views: it you need another it’ll be messy to change
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on NetBeans 7.0 which has maven 3.0.3 by default.... last week
Im working at a DataGrid which has a custom itemRenderer with a checkbox and
Im working with email address which has an ampersand in it, the user wants
i am working on a simple web app which has a user model and
I'm working with an existing XML document which has a structure (in part) like
I am working on a WPF application which has a treeview that represents an
I am working with an object which has sub objects within (see example below).
I'm working on an application which has data imported from a foreign (and wholly
I'm working on a website which has advert banners which link to external pages.
I’m working on an application which has been designed using n-tire application architecture .The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.