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

  • SEARCH
  • Home
  • 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 201429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:11:54+00:00 2026-05-11T17:11:54+00:00

Background: Visual studio fails at deploying a database project. It tries to drop functions

  • 0

Background:

Visual studio fails at deploying a database project. It tries to drop functions that are already referenced (e.g. in a check constraint), rather than just adding the new ones and updating the existing ones, so the deployment always fails.

As a result, I’m writing my own code to update the assembly and add/update any functions.

I assume the compiler/deployer uses reflection and properties of the SqlFunction attribute, so I’m also using reflection to gather a MethodInfo list of the static methods that have the SqlFunction attribute.

Question/Task:

I need to know how to translate the SqlFunctionAttribute’s properties (e.g. IsDeterministic, DataAccess, Name, IsPrecise, etc.) and the method signature of the function into an appropriate T-SQL “CREATE FUNCTION” statement.

Existing information I’ve already found to be not helpful:

The documentation for ‘create function’ is confusing and incomplete. Towards the bottom it finally mentions some of the SqlFunction properties like IsDeterministic, but it talks about them like they’re C# properties, not T-SQL parameters, so I have no idea how to use them in a create function statement.

//CLR Functions
CREATE FUNCTION [ schema_name. ] function_name 
( { @parameter_name [AS] [ type_schema_name. ] parameter_data_type 
        [ = default ] } 
    [ ,...n ]
)
RETURNS { return_data_type | TABLE <clr_table_type_definition> }
    [ WITH <clr_function_option> [ ,...n ] ]
    [ AS ] EXTERNAL NAME <method_specifier>
[ ; ]

I would expect the clr_function_option parameter to handle things like IsDeterministic, but it’s not listed as an option.

Meanwhile, in documentation for IBM DB2, I see statements like the following, which the MSDN documentation has nothing remotely similar:

  CREATE FUNCTION countUp(INTEGER) 
  RETURNS INTEGER
  LANGUAGE CLR
  PARAMETER STYLE SQL
  SCRATCHPAD 10
  FINAL CALL
  NO SQL
  FENCED
  THREADSAFE
  NOT DETERMINISTIC
  EXECUTION CONTORL SAFE
  EXTERNAL NAME 'gwenUDF.dll:bizLogic.empOps!CountUp' ;
  • 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-11T17:11:54+00:00Added an answer on May 11, 2026 at 5:11 pm

    I solved this problem eventually, after realizing that SQL Server, possessing the assembly itself, has access to the SqlFunctionAttribute’s property values. In that case, there is no need to (and is no syntax for) specifying such properties in the “CREATE FUNCTION” T-SQL statement.

    I built a utility to automatically enumerate and deploy functions and check-constraints which works like this:

    1. It enumerates all deployable static methods in classes that I specify, by searching for functions having an SqlFunction attribute using reflection. It also runs a query to enumerate all existing scalar and table-valued assembly functions already deployed. It then merges these lists into a single list, where each function either exists or does not exist. There is a button to update the assembly, and a button to toggle each function’s existence, making adding/removing/updating functions a BREEZE.

    2. In addition, I added a second tab to the interface to create/enable/check/disable check-constraints. I created a new attribute called SqlFunctionCheck, which can be applied multiple times to a function. The attribute has a “Table” property and a “Field” property, which helps the utility build the check constraints. It aggregates all the checks by table, create a check for each table named “CK_” + table_name, and creates a constraint expression joining all method calls with “and” passing the associated field name for that table to the function. It displays the generated constraint expression as well as the constraint expression queried from sql server if the constraint already exists.

    IMO, this is the ultimate solution for using SQL CLR Integration to enforce data type constraints in management studio, SQL queries in your code, and the data used throughout the code itself from a centralized data (constraint) classes.

    Interface Screenshots and Relevant Function Headers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 188k
  • Answers 188k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer ok instead of doing sampleRequest.ToString(), you should use sampleRequest.OuterXml, and… May 12, 2026 at 5:30 pm
  • Editorial Team
    Editorial Team added an answer A way I like to do it is to create… May 12, 2026 at 5:30 pm
  • Editorial Team
    Editorial Team added an answer The String primitives are immutable, they cannot be changed after… May 12, 2026 at 5:30 pm

Related Questions

I'm trying to see a form developed by someone else (ex-employee) in Visual Studio
I am looking for the best way to test if a website is alive
I have a solution with many projects. One project contain few custom components. One
Background In Visual Studio 2008 Create a new Windows Forms Application, this will create

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.