dbTalk Databases Forums  

Help parsing field

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Help parsing field in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
neolempires2@gmail.com
 
Posts: n/a

Default Help parsing field - 05-12-2007 , 07:49 PM






hi..i need help for my exam, I retrived data from my sms inbok and
insert to table.The record just like this:
ID1,12x100,56x12,90x90..,how to pars the table in to:
ID First Second
ID1 12 100
ID1 56 12
ID1 90 90

Thank for your help...

===================


Reply With Quote
  #2  
Old   
markc600@hotmail.com
 
Posts: n/a

Default Re: Help parsing field - 05-13-2007 , 03:59 AM






Using a table of numbers

http://sqlserver2000.databases.aspfa...ers-table.html


CREATE TABLE MyTable(ID VARCHAR(4), Data VARCHAR(100))
INSERT INTO MyTable(ID, Data) VALUES('ID1','12x100,56x12,90x90')

SELECT ID,
PARSENAME(REPLACE(Data,'x','.'),2) AS First,
PARSENAME(REPLACE(Data,'x','.'),1) AS Second
FROM (
SELECT ID,
SUBSTRING(Data ,
Number,
CHARINDEX(',' ,
Data+',' ,
Number)-Number) AS Data
FROM MyTable
INNER JOIN Numbers ON Number BETWEEN 1 AND LEN(Data)+1
AND SUBSTRING(','+Data,Number,1) = ',') X
ORDER BY ID



Reply With Quote
  #3  
Old   
neolempires2@gmail.com
 
Posts: n/a

Default Re: Help parsing field - 05-13-2007 , 05:59 AM



you the best ,thx.
if data inserted to table about 100 data/sec,is the script run well in
this condition, and no data lost or error??


Reply With Quote
  #4  
Old   
Ed Murphy
 
Posts: n/a

Default Re: Help parsing field - 05-13-2007 , 09:23 AM



neolempires2 (AT) gmail (DOT) com wrote:

Quote:
if data inserted to table about 100 data/sec,is the script run well in
this condition, and no data lost or error??
The best way to find out is to actually set up a test.

I've seen the following method used in production systems; it avoids
forcing the insert process to wait for an immediate response, and also
allows trying again later in case of problems.

* insert the data into an intermediate table with a column indicating
order of insertion
* separate process, launched on a schedule or by a human operator:
- note the most recent record that exists
- process all rows up to and including that one, either deleting
them or marking them as already processed
- any rows inserted mid-process are left for the next launch


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.