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

How to check column name in case sensitive? Expand / Collapse
Author
Message
Posted Monday, April 21, 2014 8:53 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 20, 2014 6:58 AM
Points: 138, Visits: 195
Hi Friends,

I have a table called SrcReg which is having a column name called IsSortSeqNo smallint. I am mapping this column in SSIS and the problem comes when I try to execute against different database which has this table but the column name as ISSortSeqNo. I mean both databases having same name but one with upper case. So SSIS fails executing due to meta validation issue.

Is there any way to check whether the column name is in small case or upper case through query?

Thanks for the suggestions in advance.
Post #1563508
Posted Monday, April 21, 2014 9:08 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 4:10 PM
Points: 33,095, Visits: 15,202
You can use the UPPER() or LOWER() functions to force case for a comparison.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1563514
Posted Monday, April 21, 2014 9:50 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 20, 2014 6:58 AM
Points: 138, Visits: 195
NO Steve, the problem is one field is IsSortSeqNo and another one named like ISSortSeqNo...

If you noticed, the second letter of the field name is upper and lower case.
So SSIS has problem in mapping when execute with different databases. I know we can change the filed name in database itself, but I am just curious, whether there is any way to check through scripts ? So that I would use the script in Execute SQL task...
Post #1563533
Posted Monday, April 21, 2014 10:16 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 4:10 PM
Points: 33,095, Visits: 15,202
You could still use UPPER or LOWER (or their equivalent in SSIS Expression) to compare.

What you'd need to do is alter the mapping in the package by looking to see if the case insensitive comparison was valid, then take the new value from the database and use that in the mapping.

It's a mess, for sure. I don't know if SSIS can compare mapping fields in a CI manner.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1563543
Posted Monday, April 21, 2014 2:34 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 9:50 PM
Points: 1,318, Visits: 3,771
If I understand the question correctly, you can use the UNICODE function to determine the case if the characters, even if the column/db is case insensitive.
Post #1563612
Posted Tuesday, April 22, 2014 2:58 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 20, 2014 6:58 AM
Points: 138, Visits: 195
Yes Steve, It's mess...but I had no idea so I am just asking if we have any way to do that
Post #1563724
Posted Tuesday, April 22, 2014 2:59 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 20, 2014 6:58 AM
Points: 138, Visits: 195
Eirik, Could you please elaborate me ?
Post #1563725
Posted Tuesday, April 22, 2014 3:37 AM This worked for the OP Answer marked as solution
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 9:50 PM
Points: 1,318, Visits: 3,771
prakashr.r7 (4/22/2014)
Eirik, Could you please elaborate me ?


Firstly, the character code for upper and lower cases are different, even on a case insensitive system:
;WITH NB(N) AS (SELECT N FROM (VALUES (1),
(1),(1),(1),(1),(1),(1),(1),(1),(1)) AS NN(N))
,NUMS(N) AS (SELECT ROW_NUMBER() OVER
(ORDER BY (SELECT NULL)) AS N FROM NB N1,NB N2,NB N3)
SELECT
NM.N AS CHAR_CODE
,NCHAR(NM.N) COLLATE SQL_Latin1_General_CP1_CI_AS AS THE_CHARACTER
,UNICODE(NCHAR(NM.N) COLLATE SQL_Latin1_General_CP1_CI_AS) AS CHAR_UNICODE
FROM NUMS NM
WHERE NM.N < 256;

Secondly, you can use the COLLATION to do a case sensitive comparison on a case insensitive system:
DECLARE @STR_1 NVARCHAR(MAX) = N'ThisIsStringOne';
DECLARE @STR_2 NVARCHAR(MAX) = N'ThiSIsStringOne';

SELECT
CASE
WHEN @STR_1 COLLATE SQL_Latin1_General_CP1_CS_AS = @STR_2 COLLATE SQL_Latin1_General_CP1_CS_AS THEN 'THE SAME!'
ELSE 'NOT THE SAME!'
END AS STRING_COMPARISON
;


Post #1563732
Posted Wednesday, April 23, 2014 2:48 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 20, 2014 6:58 AM
Points: 138, Visits: 195
Thank you Eirik....I really appreciate your help.
Post #1564155
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse