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 |
|
leone
Starting Member
6 Posts |
Posted - 2008-11-05 : 16:37:07
|
| I have a small problem with my sql database. something happen that one of my coloums got deleted, so i used backup data. Now my problem is the some data don't match. I have 2 columns one is guid other is data. How can i make a sql file that checks the guid number and then checks the first number in the data column. if the data doesn't match with guid to take the guid number and past in the dataexguid data2364 4523 0 25 0 1065353216 0 0 0 0 0 0 0 0 so need a way to copy the 2364 and replace the 4523 and leave the rest of the data. thxs |
|
|
hanbingl
Aged Yak Warrior
652 Posts |
Posted - 2008-11-05 : 16:45:37
|
| [code]update <table>set data = guidwhere guid <> data[/code] |
 |
|
|
leone
Starting Member
6 Posts |
Posted - 2008-11-05 : 18:22:18
|
| ill try it out thanksedit Hey um trying to see how this would work but dont think it would.to me it seems like if i did it it would replace everything in the data with just the guid number. The data colunm is a string of data like "111114739 0 0 0 5 3 5" so how would i replace the 111114739 in the string with the guid number? What you told me would do that?thxs |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-05 : 22:57:54
|
| use left(datacol,charindex(' ',datacol)-1) to get 111114739 from "111114739 0 0 0 5 3 5" |
 |
|
|
BigJohnDoom
Starting Member
1 Post |
Posted - 2008-11-28 : 11:27:22
|
hey guys, I need some help as I'm working on Leon's problem for him:Table name:charactersfields that need updatingGUIDDatasay for example, we need to change GUID of 10 to 999 and change the first part of the string in the data field to match the new GUID (an example of which is "10 23596 201 022 01" to "999 23596 201 022 01"), could someone give a SQL template for an update script that will change old GUID value to new GUID and to change the 1st part of the data column to also match the new GUID. I only know basic SQL and this is beyond my knowledgeI'm sure one of you clever dudes or chicks can sort me out, thanks in advance! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-28 : 11:33:39
|
quote: Originally posted by BigJohnDoom hey guys, I need some help as I'm working on Leon's problem for him:Table name:charactersfields that need updatingGUIDDatasay for example, we need to change GUID of 10 to 999 and change the first part of the string in the data field to match the new GUID (an example of which is "10 23596 201 022 01" to "999 23596 201 022 01"), could someone give a SQL template for an update script that will change old GUID value to new GUID and to change the 1st part of the data column to also match the new GUID. I only know basic SQL and this is beyond my knowledgeI'm sure one of you clever dudes or chicks can sort me out, thanks in advance! 
did you try casting it to varchar and then using replace? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-11-28 : 11:35:13
|
UPDATE Table1SET Col1 = '999' + SUBSTRING(Col1, 3, DATALENGTH(Col1))WHERE Col1 LIKE '10 %' E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|
|
|