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 6546583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:43:30+00:00 2026-05-25T11:43:30+00:00

I am using indexed views in my database. So client should have some session

  • 0

I am using indexed views in my database. So client should have some session connection setting to call them. I am using ado.net connection, command to call stored procedures.
Every time I have to call a stored procedure I create connection (I hope connection pool allows me to do this quickly) and execute a command to apply these settings to current connection.

// some code to create a new connection
 //...
 //... 

 if (connection.State != ConnectionState.Open)
 {
     connection.Open();
 }



    using (var cmd = connection.CreateCommand())
    {
        cmd.CommandType = CommandType.Text;
        cmd.CommandText =
                            @"
                    SET ANSI_NULLS ON
                    SET ANSI_PADDING ON
                    SET ANSI_WARNINGS ON
                    SET ARITHABORT ON
                    SET CONCAT_NULL_YIELDS_NULL ON
                    SET QUOTED_IDENTIFIER ON
                    SET NUMERIC_ROUNDABORT OFF";
        cmd.ExecuteNonQuery();
    }

Other thought: adding these settings before every call of stored procedure:

command.CommandText = 'SET....';
command.CommandText += ' EXEC MyStroredProc @...'; 

This solution causes some performance issues, isn’t it?

How can I avoid so extra work if I have to create a new connection every time? How to apply these setting automatically?

SOLUTION:

ALTER DATABASE [MyDB] 
    SET 
    ANSI_NULLS ON,
    ANSI_PADDING ON,
    ANSI_WARNINGS ON,
    ARITHABORT ON,
    CONCAT_NULL_YIELDS_NULL ON,
    QUOTED_IDENTIFIER ON,
    NUMERIC_ROUNDABORT OFF
  • 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-25T11:43:30+00:00Added an answer on May 25, 2026 at 11:43 am

    According the documentation, you can set these settings on the Database level:

    Database settings set by using ALTER DATABASE are valid only at the database level and take effect only if explicitly set. Database settings override instance option settings that are set by using sp_configure.

    Did you try that?

    Unfortunately, this properties can’t be set in connection string, so use this sql:

    ALTER DATABASE dbname SET ANSI_NULLS ON
    -- etc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm setting up a database using phpMyAdmin. I have two tables ( foo and
I am using a DBD::SQLite in memory database. I have defined the following indexes
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
OK, I'm confused about sql server indexed views(using 2008) I've got an indexed view
I have created views on the SQL Server 2005 database and this view is
I'm using SQL Server 2008. I have a database table that looks like this
I am using the Advantage Database Server from Sybase and have for the moment
I have database project in visual studio 2010. It has tables views stored procedures
I'm using VB9 (VS2008). I've created a Windows Service that indexes some folders regularly.
I'm developing a Desktop Search Engine using VB9 (VS2008) and Lucene.NET. The Indexer in

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.