| Author |
Topic |
|
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2007-03-16 : 20:05:54
|
| i found thisSET TEXTSIZE 0SET NOCOUNT ON-- Create the variables for the current character string position -- and for the character string.DECLARE @position int, @string char(15)-- Initialize the variables.SET @position = 1SET @string = 'Du monde entier'WHILE @position <= DATALENGTH(@string) BEGIN SELECT ASCII(SUBSTRING(@string, @position, 1)), CHAR(ASCII(SUBSTRING(@string, @position, 1))) SET @position = @position + 1 ENDSET NOCOUNT OFFGOIs there a way to read each column in my table and check what it has in it Im having trouble exporting some rows of data |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-17 : 02:46:20
|
| What troubles are you experiencing?Peter LarssonHelsingborg, Sweden |
 |
|
|
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2007-03-17 : 06:52:23
|
| When using BCP to export data it misses part of the table that i have data inSo i was wondering if i can check data in SQL to see if any non ascii codes The rows are about 65036 120 mg database |
 |
|
|
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2007-03-17 : 10:39:26
|
| The problem is exporting table from SQL.using bcp some of the records are not exporting.I put rowid on the table and opened in access and all records are exported...I assuming some carriage return is missing on the records perhapsWorking on command to display this...DECLARE @position int, @string char(100), @ASCII_CONCAT INT,@ASCII_CHAR CHAR,@ASCII_CONCAT_DISPLAY NVARCHAR(100),@ASCII_CHAR_DISPLAY NVARCHAR(100)-- Initialize the variables.SET @position = 1SET @string = '"00101001"'SET @ASCII_CONCAT = ''SET @ASCII_CONCAT_DISPLAY = ''SET @ASCII_CHAR_DISPLAY = ''WHILE @position <= LEN(@STRING)BEGINSET @ASCII_CONCAT = ASCII(SUBSTRING(@string, @position, 1))SET @ASCII_CHAR = CHAR(ASCII(SUBSTRING(@string, @position, 1)))--PRINT @ASCII_CHAR--PRINT @ASCII_CONCATSET @position = @position + 1Set @ASCII_CONCAT_DISPLAY = @ASCII_CONCAT_DISPLAY + @ASCII_CONCAT SET @ASCII_CHAR_DISPLAY = @ASCII_CHAR + ';' + @ASCII_CHAR_DISPLAY--SET @ASCII_CHAR_DISPLAY = @ASCII_CHAR + ';' + @ASCII_CHAR_DISPLAY--PRINT @ASCII_CONCAT_DISPLAY--PRINT @ASCII_CHAR_DISPLAY ENDPRINT @ASCII_CONCAT_DISPLAYPRINT @ASCII_CHAR_DISPLAYSET NOCOUNT OFFGOCan't get the ascii for Set @ASCII_CONCAT_DISPLAY = @ASCII_CONCAT_DISPLAY + @ASCII_CONCAT to work it add the values togetherso im getting 455 instead of 34;48 etcI think thats how i going to determine if there is something not correct at the end of the columns ? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-17 : 19:21:12
|
[code]Set @ASCII_CONCAT_DISPLAY = @ASCII_CONCAT_DISPLAY + CONVERT(VARCHAR(3), @ASCII_CONCAT) + ';'[/code] KH |
 |
|
|
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2007-03-18 : 07:16:36
|
| i used the function on the columns i get everything coming out;34;89;34 Get no additonal characters So it must be something wrong with the bcp If i add a rowid int it works the bcp exports.In sql and access. Any suggestions to why all i can think of is it knows the start and end of each row.Any thing else i can checkcreate Function dbo.udf_GetASCIIValue(@Value varchar(50))Returns varchar(150)AsBeginDeclare @CurrPos tinyint, @ValueLen tinyint, @OutputValue varchar(150)Select @CurrPos = 1, @ValueLen = LEN(@Value), @OutputValue = ''WHILE @CurrPos <= @ValueLen Begin Set @OutputValue = @OutputValue + ';' + CAST(ASCII(SUBSTRING(@Value, @CurrPos, 1)) as varchar(3)) Set @CurrPos = @CurrPos + 1 EndReturn @OutputValueEnd |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-18 : 07:26:33
|
| Do you have UNICODE column in the table?Peter LarssonHelsingborg, Sweden |
 |
|
|
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2007-03-18 : 12:19:45
|
| How do i check for this |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-18 : 12:48:11
|
You can use Enterprise Manager to do this.Or run this querySELECT *FROM INFORMATION_SCHEMA.COLUMNSWHERE TABLE_NAME = 'YourTableNameHere' And look amongthe result your column names.Peter LarssonHelsingborg, Sweden |
 |
|
|
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2007-03-18 : 14:10:02
|
| I have the table on 2000 but i have it here on 2005 so i could work with it.I gotSQL_Latin1_General_CP1_CI_AS character set iso_1TRACEY dbo ET_CHRG COL1 2 NULL YES varchar 100 100 NULL NULL NULL NULL NULL NULL iso_1 NULL NULL SQL_Latin1_General_CP1_CI_AS NULL NULL NULLAll cols are same as above |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-18 : 14:18:45
|
Ok, now we can rule that out.Have a look at this code-- Prepare invalid lookup dataDECLARE @Lookup TABLE (chr VARCHAR(1))INSERT @LookupSELECT CHAR(Number)FROM master..spt_valuesWHERE Name IS NULL AND Number BETWEEN 1 AND 31DECLARE @Data TABLE (cfg VARCHAR(20))INSERT @DataSELECT 'Peso' UNION ALLSELECT 'XXX' + CHAR(7) + CHAR(9) UNION ALLSELECT 'Good data' + CHAR(2)-- Find invalid dataSELECT DISTINCT d.*FROM @Data AS dINNER JOIN @Lookup AS l ON d.cfg LIKE '%' + l.chr + '%' It finds invalid characters in a string.Use this part of the code in your environment to find invalid rows.-- Prepare invalid lookup dataDECLARE @Lookup TABLE (chr VARCHAR(1))INSERT @LookupSELECT CHAR(Number)FROM master..spt_valuesWHERE Name IS NULL AND Number BETWEEN 1 AND 31-- Find invalid dataSELECT DISTINCT d.*FROM {YourTableNameHere} AS dINNER JOIN @Lookup AS l ON {YourTableNameHere}.{YourColumnNameHere} LIKE '%' + l.chr + '%'Peter LarssonHelsingborg, Sweden |
 |
|
|
TRACEYSQL
Aged Yak Warrior
594 Posts |
Posted - 2007-03-18 : 19:19:13
|
| Just so i understand I run this on the DATABASEAll of it at once ? -- Prepare invalid lookup dataDECLARE @Lookup TABLE (chr VARCHAR(1))INSERT @LookupSELECT CHAR(Number)FROM master..spt_valuesWHERE Name IS NULL AND Number BETWEEN 1 AND 31DECLARE @Data TABLE (cfg VARCHAR(20))INSERT @DataSELECT 'Peso' UNION ALLSELECT 'XXX' + CHAR(7) + CHAR(9) UNION ALLSELECT 'Good data' + CHAR(2)-- Find invalid dataSELECT DISTINCT d.*FROM @Data AS dINNER JOIN @Lookup AS l ON d.cfg LIKE '%' + l.chr + '%'It finds invalid characters in a string.Use this part of the code in your environment to find invalid rows.-- Prepare invalid lookup dataDECLARE @Lookup TABLE (chr VARCHAR(1))INSERT @LookupSELECT CHAR(Number)FROM master..spt_valuesWHERE Name IS NULL AND Number BETWEEN 1 AND 31-- Find invalid dataSELECT DISTINCT d.*FROM {YourTableNameHere} AS dINNER JOIN @Lookup AS l ON {YourTableNameHere}.{YourColumnNameHere} LIKE '%' + l.chr + '%' |
 |
|
|
|