Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Determine ANSI_PADDING status in TSQL Expand / Collapse
Author
Message
Posted Friday, July 27, 2012 2:42 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, November 1, 2013 5:33 AM
Points: 9, Visits: 57
Hello SQL Gurus.

I have a situation where the production databases have ANSI_PADDING on. This is what I want, as for reasons best know to the users they need to store A [Space][Space] as exactly that.

Yesterday I found that the UAT databases have ANSI_PADDING off. This is producing inconsistent test data, as you can imagine.

I was hoping that A/P might be visible on INFORMATION_SCHEMA.COLUMNS, and I would be able to set it in code. But so far I haven't been able to find how to do this.

Please can someone tell me what level ANSI_PADDING is stored - Column, Table or DB... and furthermore, what is the best way to find this out in code?

Thanks!
Post #1336318
Posted Friday, July 27, 2012 2:54 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 2:37 AM
Points: 2,649, Visits: 4,726
SELECT	SESSIONPROPERTY('ANSI_PADDING')




Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1336326
Posted Friday, July 27, 2012 7:31 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, November 1, 2013 5:33 AM
Points: 9, Visits: 57
Many thanks :)
Post #1336499
Posted Friday, July 27, 2012 12:16 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 6:38 PM
Points: 1,371, Visits: 1,560
For checking ANSI_PADDING on columns:

SELECT name  column_name,
CASE is_ansi_padded
WHEN 1 THEN 'On'
ELSE 'Off'
AS [ANSI_PADDING]
FROM sys.all_columns
WHERE object_id = object_id(<table name>)



~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter

Post #1336699
Posted Friday, July 27, 2012 12:20 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 6:38 PM
Points: 1,371, Visits: 1,560
To further add (SQL Server 2012 BOL):

In a future version of Microsoft SQL Server ANSI_PADDING will always be ON and any applications that explicitly set the option to OFF will produce an error. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

Source: http://msdn.microsoft.com/en-us/library/ms187403.aspx


~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter

Post #1336700
Posted Friday, July 27, 2012 12:21 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:03 PM
Points: 23,341, Visits: 32,074
Lokesh Vij (7/27/2012)
For checking ANSI_PADDING on columns:

SELECT name  column_name,
CASE is_ansi_padded
WHEN 1 THEN 'On'
ELSE 'Off'
AS [ANSI_PADDING]
FROM sys.all_columns
WHERE object_id = object_id(<table name>)



Or:


SELECT
name column_name,
CASE is_ansi_padded
WHEN 1 THEN 'On'
ELSE 'Off'
AS [ANSI_PADDING]
FROM
sys.columns
WHERE
object_id = object_id(<schema.tablename>)





Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1336702
Posted Friday, July 27, 2012 12:24 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, June 24, 2014 6:38 PM
Points: 1,371, Visits: 1,560
Lynn Pettis (7/27/2012)
Lokesh Vij (7/27/2012)
For checking ANSI_PADDING on columns:

SELECT name  column_name,
CASE is_ansi_padded
WHEN 1 THEN 'On'
ELSE 'Off'
AS [ANSI_PADDING]
FROM sys.all_columns
WHERE object_id = object_id(<table name>)



Or:


SELECT
name column_name,
CASE is_ansi_padded
WHEN 1 THEN 'On'
ELSE 'Off'
AS [ANSI_PADDING]
FROM
sys.columns
WHERE
object_id = object_id(<schema.tablename>)




Great Lynn, I missed that.
Thanks


~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter

Post #1336703
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse