|
sqlstarter1
Starting Member
6 Posts |
Posted - 2009-04-27 : 11:45:49
|
| Create table myProduct (i int, j int, t text)gocreate unique index ui on myProduct(i, j)gocreate proc nr_Adtxt@i int ,@j int ,@t varchar(8000) ,@Action varchar(1) -- 'I insertasdeclare @ptr binary(16)if @Action = 'I'begininsert myProduct(i ,j ,t)select @i ,@j ,@tendif @Action = 'A'beginselect @ptr = textptr(t) from mySecondwhere i = @iand j = @jupdatetext myProduct.t @ptr null 0 @tendgoexec nr_Adtxt 1, 1, 'abc,bdes,123', 'I'--insertexec nr_Adtxt 1, 1, '678,es,123', 'A'--updateselect i,j, substring(t, 1, 8000) from myProduct--This code will replace all occurrances of a string in a text column in all rowsdelete myProductexec nr_Adtxt 1, 1, '6,bdes,123', 'I'exec nr_Adtxt 1, 1, '678,bdes,123', 'A'declare @t varchar(8000)select @t = space(6000) + 'sadf'exec nr_Adtxt 1, 1, @t, 'A'select @t = 'sadf'exec nr_Adtxt 1, 1, @t, 'A'select @t = space(6000) + 'sadf'exec nr_Adtxt 1, 1, @t, 'A'select @t = 'sadf'exec nr_Adtxt 1, 1, @t, 'A'but I dont know how can i use stored procedure for replace .No I am able to insert keyword and delete the keywords.But not able to do update function If you have any idea please let me knowThanks again dude |
|