Big Monty
asked on
sql server - retrieve all records that contain multi-byte data
is there a way to determine all rows in my table that contain multi-byte data? this is for MS Sql Server 2008 / 2012
What does "multi-byte" data mean? Do you mean unicode strings?
ASKER
yes. for example, any records that have chinese / japanese characters in them
Please rephrase your question..
But I guess you should take a look at LEN vs. DATALENGTH:
But I guess you should take a look at LEN vs. DATALENGTH:
DECLARE @Sample TABLE ( Test NVARCHAR(255) );
INSERT INTO @Sample
VALUES ( N'1' ),
( N'क्षि' );
SELECT LEN(Test),
DATALENGTH(Test),
Test
FROM @Sample;
SELECT O.name AS TableName, C.name AS ColumnName,
T.name AS TypeName, C.max_length
FROM sys.objects AS O
INNER JOIN sys.columns AS C
ON O.object_id = C.object_id
INNER JOIN sys.types AS T
ON C.user_type_id = T.user_type_id
WHERE O.type = 'U'
AND C.user_type_id = 231
T.name AS TypeName, C.max_length
FROM sys.objects AS O
INNER JOIN sys.columns AS C
ON O.object_id = C.object_id
INNER JOIN sys.types AS T
ON C.user_type_id = T.user_type_id
WHERE O.type = 'U'
AND C.user_type_id = 231
ASKER
@Brian - I'm looking for a query to tell me if certain records in my table contains any multi-byte chars, i.e. chinese chars. Most of the records contains plain english, but i have a few that contain those special chars. Your query tells me the data type for each field, which is not what I'm looking for.
@st5an - not sure how you else you want me to re-phrase the question...the query you gave me doesn't really differentiate from the two conditions I'm looking for
@st5an - not sure how you else you want me to re-phrase the question...the query you gave me doesn't really differentiate from the two conditions I'm looking for
What conditions?? What about a concise and complete example as runnable T-SQL script... I don't like guessing that much..
ASKER
in pseudo code, it would be something like:
select * from table where field contains any multi-byte char
the field in question would contain something like
シュアビード レデュースドキャビティ(RC) アプリケーター
select * from table where field contains any multi-byte char
the field in question would contain something like
シュアビード レデュースドキャビティ(RC) アプリケーター
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i get a zero returned from the function when I run the query (after creating the function).
SELECT Cache_Obj_Filename, dbo.HasDoubleByte(Cache_Ob j_Filename ) FROM Data where .......
the record shows up, but so do all of the other records
SELECT Cache_Obj_Filename, dbo.HasDoubleByte(Cache_Ob
the record shows up, but so do all of the other records
The function was updated in the meantime...