SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to check column name in case sensitive?


How to check column name in case sensitive?

Author
Message
prakashr.r7
prakashr.r7
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 Visits: 197
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.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: Administrators
Points: 64053 Visits: 19117
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
My Blog: www.voiceofthedba.com
prakashr.r7
prakashr.r7
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 Visits: 197
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...
Steve Jones
Steve Jones
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: Administrators
Points: 64053 Visits: 19117
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
My Blog: www.voiceofthedba.com
Eirikur Eiriksson
Eirikur Eiriksson
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15376 Visits: 18613
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.
Cool
prakashr.r7
prakashr.r7
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 Visits: 197
Yes Steve, It's mess...but I had no idea so I am just asking if we have any way to do that
prakashr.r7
prakashr.r7
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 Visits: 197
Eirik, Could you please elaborate me ?
Eirikur Eiriksson
Eirikur Eiriksson
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15376 Visits: 18613
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
;


Cool
prakashr.r7
prakashr.r7
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 Visits: 197
Thank you Eirik....I really appreciate your help.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search