Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2010-10-07 : 07:39:50
|
Hi all, I've got a Sproc that does an insert, but when try to pass in Greek text the results are simply ????'s.The DB's collation set is SQL_Latin1_General_CP1_CI_AS, and the target column's datatype is nvarchar(4000).Any ideas?ALTER Procedure [dbo].[prInsertIntoInqueueMod] @phone char(15) ,@text nvarchar(4000) ,@processed tinyint ,@network int ,@confirmed tinyint ,@service int ,@origin tinyint ,@origin2 smallint ,@keyid int AS Declare @msgidentity int begin tran INSERT INTO Inqueue (phone, text, origintime, processed, network, confirmed, service, origin, origin2, keyid) select @phone, @text, GetDate() as origintime, @processed, @network, @confirmed, @service, @origin, @origin2, @keyid set @msgidentity = @@identity select @msgidentity as result commit tranEXECUTE prInsertIntoInqueueMod '306777567779','?ê???? ?????? ??? ',29871,8,211,0,15230,null,162271 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 08:19:52
|
Not related to the internationalisation aspect butset @msgIdentity = @@identity Isn't generally a good idea.@@identity can provide the wrong results if a trigger fires after the insert etc. Consider using IDENT_CURRENT() or @@SCOPE_IDENTITY instead. If you use @@IDENTITY generally then you should stop doing that.Are you sure the values are stored as ? or is this maybe just a display issue?Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 08:37:14
|
You could probably test what is in the table using something like this:DECLARE @foo TABLE ( [ID] INT IDENTITY(1,1) PRIMARY KEY , [value] NVARCHAR(4000) )INSERT @foo ([value]) SELECT '%TRAVEG???????' -- get some values from charmap appUNION SELECT NCHAR(765) + NCHAR(234) -- Insert some know out of code page valuesSELECT [value] FROM @fooSELECT f.[Id] , SUBSTRING(f.[value], t.N, 1) , UNICODE(SUBSTRING(f.[value], t.N, 1))FROM @foo AS f JOIN ( SELECT TOP 4000 ROW_NUMBER() OVER( ORDER BY a.[a]) AS [N] FROM (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS a CROSS JOIN (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS b CROSS JOIN (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS c CROSS JOIN (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS d CROSS JOIN (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS e CROSS JOIN (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS f CROSS JOIN (SELECT 1 AS [a] UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) AS g ) AS t ON t.[N] <= LEN(f.[value])ORDER BY f.[ID] , t.[N] (This looks complicated but only because I'm generating a tally table on the fly. If you had your own tally table then you wouldn't need the who derived table bit.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2010-10-07 : 08:43:11
|
quote: Originally posted by Transact Charlie Not related to the internationalisation aspect butset @msgIdentity = @@identity Isn't generally a good idea.@@identity can provide the wrong results if a trigger fires after the insert etc. Consider using IDENT_CURRENT() or @@SCOPE_IDENTITY instead. If you use @@IDENTITY generally then you should stop doing that.Are you sure the values are stored as ? or is this maybe just a display issue?Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Hi Charlie mate, we have a LONG list of subpar practices here I need to put right, I've been told off umpteen times for pasting other people's scripts that used (nolock)!According to the developer, the data appears as junk at the front end, too. |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 08:46:59
|
if the data is actually stored as ? then this has the UNICODE value 63. if you've actually managed to put different greek characters into the database then the UNICODE values for the individual characters should be different.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-07 : 09:00:15
|
quote: Originally posted by Jim Beam Hi all, I've got a Sproc that does an insert, but when try to pass in Greek text the results are simply ????'s.The DB's collation set is SQL_Latin1_General_CP1_CI_AS, and the target column's datatype is nvarchar(4000).Any ideas?ALTER Procedure [dbo].[prInsertIntoInqueueMod] @phone char(15) ,@text nvarchar(4000) ,@processed tinyint ,@network int ,@confirmed tinyint ,@service int ,@origin tinyint ,@origin2 smallint ,@keyid int AS Declare @msgidentity int begin tran INSERT INTO Inqueue (phone, text, origintime, processed, network, confirmed, service, origin, origin2, keyid) select @phone, @text COLLATE Greek_CS_AI , GetDate() as origintime, @processed, @network, @confirmed, @service, @origin, @origin2, @keyid set @msgidentity = @@identity select @msgidentity as result commit tranEXECUTE prInsertIntoInqueueMod '306777567779',N'?ê???? ?????? ??? ',29871,8,211,0,15230,null,162271
See if the changes above in red work?PBUH |
 |
|
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2010-10-07 : 09:03:55
|
quote: Originally posted by Transact Charlie if the data is actually stored as ? then this has the UNICODE value 63. if you've actually managed to put different greek characters into the database then the UNICODE values for the individual characters should be different.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
How would I check this? And by "data from the Charmap App" do you mean the greek characters I tried to insert? And did you mean "Known out of page code values"?Cheers, JIm |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 09:15:06
|
Sorry Jim the sql I posted will split the strings into individual characters and then report there UNICODE map number.By charmap app I just meant launch charmap - take some characters that aren't in the default codepage (standard characters like these I'm typing here) and try cut and paste themTHE NCHAR(xyz) statements insert the NCHAR value that corrosponds to that number.This was just to put some sample data into the table variable in my example script.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2010-10-07 : 09:16:51
|
quote: Originally posted by Sachin.Nand
quote: Originally posted by Jim Beam Hi all, I've got a Sproc that does an insert, but when try to pass in Greek text the results are simply ????'s.The DB's collation set is SQL_Latin1_General_CP1_CI_AS, and the target column's datatype is nvarchar(4000).Any ideas?ALTER Procedure [dbo].[prInsertIntoInqueueMod] @phone char(15) ,@text nvarchar(4000) ,@processed tinyint ,@network int ,@confirmed tinyint ,@service int ,@origin tinyint ,@origin2 smallint ,@keyid int AS Declare @msgidentity int begin tran INSERT INTO Inqueue (phone, text, origintime, processed, network, confirmed, service, origin, origin2, keyid) select @phone, @text COLLATE Greek_CS_AI , GetDate() as origintime, @processed, @network, @confirmed, @service, @origin, @origin2, @keyid set @msgidentity = @@identity select @msgidentity as result commit tranEXECUTE prInsertIntoInqueueMod '306777567779',N'?ê???? ?????? ??? ',29871,8,211,0,15230,null,162271
See if the changes above in red work?PBUH
That's still on Alter Procedure! How do I test run??!!?? |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-07 : 09:25:06
|
What is the o/p of this after you execute the stored procedure?select * from Inqueue PBUH |
 |
|
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2010-10-07 : 09:37:24
|
quote: Originally posted by Sachin.Nand What is the o/p of this after you execute the stored procedure?select * from Inqueue PBUH
What's an O/P? Does someone have a script I can JUST run? Thanks, Jim |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-10-07 : 09:45:45
|
Run this to see if the data actually corresponds to the expected hexidecimal representation of Greek characters:select convert(varbinary(max),text) as text from Inqueue CODO ERGO SUM |
 |
|
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2010-10-07 : 10:02:39
|
quote: Originally posted by Michael Valentine Jones Run this to see if the data actually corresponds to the expected hexidecimal representation of Greek characters:select convert(varbinary(max),text) as text from Inqueue CODO ERGO SUM
The results don't look like Greek characters - just 0x3C005300430052004900500054005F004500560045004E0054003E003C007500730065007200690064003E0030003C002F007500730065007200690064003E003C00610064007600650072007400690073006500720020002F003Eetc... |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-10-07 : 10:20:06
|
quote: Originally posted by Jim Beam
quote: Originally posted by Michael Valentine Jones Run this to see if the data actually corresponds to the expected hexidecimal representation of Greek characters:select convert(varbinary(max),text) as text from Inqueue CODO ERGO SUM
The results don't look like Greek characters - just 0x3C005300430052004900500054005F004500560045004E0054003E003C007500730065007200690064003E0030003C002F007500730065007200690064003E003C00610064007600650072007400690073006500720020002F003Eetc...
Of course not. That's why I said "expected hexidecimal representation of Greek characters"It's up to you to decide if that data is valid for your purpose or not, but it does tell you exactly what you have.CODO ERGO SUM |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 10:25:12
|
Jim.Take a deep breath and realise that you can't just deadlift this one right away.... Internationalisation is really awkward.Why don't you explain the chain that you've got set up here.How do you get the values in the first place / what do you do to them.... how do you store them (pretty much covered allready) / how do you display them?At any stage you can get an implicit conversion or a conversion down to a different codepage...Your fighting against a short sighted design decision from over 15 years ago and its easy to get it wrong.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 10:29:47
|
quote: Originally posted by Jim Beam
quote: Originally posted by Sachin.Nand What is the o/p of this after you execute the stored procedure?select * from Inqueue PBUH
What's an O/P? Does someone have a script I can JUST run? Thanks, Jim
I assume he means output.so -- change the proc as Sachin suggests, do what you were doing before.... still get the question marks???Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-10-07 : 10:33:43
|
This query returns actual Greek data stored in unicode (NVARCHAR) along with the hexidecimal representation.select name as language, convert(varbinary(max),name) as hex_language, months, convert(varbinary(max),months) as hex_months, shortmonths, convert(varbinary(max),shortmonths) as hex_shortmonths, days, convert(varbinary(max),days) as hex_daysfrom master.dbo.syslanguageswhere alias = 'Greek' CODO ERGO SUM |
 |
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-10-07 : 10:55:10
|
Take a look at what these conversions do:select left(name,10) as language, convert(varchar(10),name COLLATE Greek_CS_AI) as Greek_Codepage, convert(varchar(10),name) as Default_Codepage, convert(varbinary(9),convert(varchar(10),name COLLATE Greek_CS_AI)) as hex_language_varchar, convert(varbinary(17),name) as hex_language_unicodefrom master.dbo.syslanguageswhere alias = 'Greek' Results:language Greek_Codepage Default_Codepage hex_language_varchar hex_language_unicode ---------- -------------- ---------------- -------------------- ------------------------------------ e??????? e??????? e??????? 0xE5EBEBE7EDE9EADC 0xB503BB03BB03B703BD03B903BA03AC03(1 row(s) affected) CODO ERGO SUMNote: The forum does not properly display the Greek characters returned in the first two columns of the query, but you will see what it returns if you run it in a query window. |
 |
|
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2010-10-07 : 13:11:54
|
Hi Mike, that's all Greek to me - thankfully literally!!:)Jim |
 |
|
|
|
|
|
|