Klez Posted September 25, 2008 Report Share Posted September 25, 2008 (edited) Ir mssql kuram var piesleegties arii no php , bet to probleemu man liekas ka var bez php arii atrisinaat ... Vajag vienam fildam datus pamainiit. tabulaa ir lauki: nosaukums,kods,barkods lieta taada ka nosaukumiem visiem priekshaa ir arii kods dati: 123456789 kaut kaads teksts | 123456789 | 1234567890987 876456789 kaut kaads teksts | 876456789 | 8764567890987 vajadzeetu no teksta laika to kodu dabuut nost. Te mees dabuujam visus ierakstus kuriem pirmie 9 simboli ir cipari un 10-tais ir tukšums SELECT NOSAUK, KODS, BAR_KODS FROM tabula WHERE (NOSAUK LIKE '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][ ]%') vajadzeetu shitos ciparus izdzeest ... var jau ar php to izdariit, bet manupraat vai labaak nebuus proceduuru taisiit ? pagaidaam skatos uz substring fciju mssql`am ... varbuut varat kaut ko citu ieteikt ... ---- Mazliet paguugleeju un atradu sho te: CREATE TABLE #temp(stringRep VARCHAR(60)) INSERT INTO #temp(stringRep) VALUES('123456789 ale jjaaa ') INSERT INTO #temp(stringRep) VALUES('945832756 lazyCow') DECLARE @startPos INT SET @startPos = 0 UPDATE #temp SET stringRep = REPLACE(stringRep,SUBSTRING(stringRep, 0, 11),'') SELECT * FROM #temp DROP TABLE #temp Izskatās ka noderees. meeginaashu visus datus ielikt tmp tabula un paskatiishos kas notiek .. Edited September 25, 2008 by Klez Link to comment Share on other sites More sharing options...
bubu Posted September 25, 2008 Report Share Posted September 25, 2008 Pareizi skaties. Taisi vien update (pirms tam backups obligāti!), kurā laukam maini vērtību no viņa paša vērtības, kura apstrādāta ar substring. Link to comment Share on other sites More sharing options...
Klez Posted September 25, 2008 Author Report Share Posted September 25, 2008 Atradu vēl vienkāršāku variantu ... UPDATE #temp SET stringRep = substring(stringRep, 11,300) FROM #temp backup jau pats par sevi :) Link to comment Share on other sites More sharing options...
bubu Posted September 25, 2008 Report Share Posted September 25, 2008 Nu tas jau ir tieši tas, ko es tev teicu :) Link to comment Share on other sites More sharing options...
Recommended Posts