Skip to content

Instantly share code, notes, and snippets.

@swaters86
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swaters86/da10dad981a5f9911c58 to your computer and use it in GitHub Desktop.
Save swaters86/da10dad981a5f9911c58 to your computer and use it in GitHub Desktop.
/*
select *
from web.dbo.Artikkler_tekst (nolock)
where Avis='la' and Lopenr='150309826' and Dato='20150303' and blokk=1
*/
/* Declare Site Code Variable */
declare @ASite varchar(2)
/* Declare story id variable */
declare @LStoryId int
/* Declare story date */
declare @LStoryDate varchar(8)
/* Stores the character position number after >> in a string */
declare @AsubstringNumTable table (substringNum int)
/*
Declaring a variable so we can assign it to the value in the substringNum column
in the @AsubstirngNumTable temp table
*/
declare @AsubstringNumVal int
/*
Stores the original tekst data , this is used beacause text data types
can't be used in REPLACE() functions
*/
declare @AparagraphText1 varchar(5000)
/* Stores the result of the replacement */
declare @AparagraphText2 varchar(5000)
set @LStoryId = 150309826
set @ASite = 'la'
set @LStoryDate = '20150303'
/* inserting the position number after the >> chracters in a string into this table*/
insert into @AsubstringNumTable (substringNum)
select patindex('%>>%', Tekst)
from web.dbo.artikkler_tekst (nolock)
where Avis=@ASite
and Lopenr=@LStoryId
and Dato=@LStoryDate
and blokk=1
/*
Assigning the value of the substringNum column in the AsubstringNumTable
to this variable
*/
select @AsubstringNumVal =
substringNum
from @AsubstringNumTable
/*
Assinging the original text in the Tekst column for the artikkler_tekst table
to this variable
*/
select @AparagraphText1 =
Tekst
from web.dbo.artikkler_tekst (nolock)
where Avis=@ASite
and Lopenr=@LStoryId
and Dato=@LStoryDate
and blokk=1
/* Assinging the replacement result to this variable */
select @AparagraphText2 =
REPLACE
(
@AparagraphText1,
REPLACE(SUBSTRING(@AparagraphText1,0,@AsubstringNumVal),'<hardreturn>',''),
UPPER(REPLACE(SUBSTRING(@AparagraphText1,0,@AsubstringNumVal),'<hardreturn>',''))
)
/*
Updating the artikkler_tekst table by setting the Tekst column
to the data that's assigned to the AparagraphText2 variable
*/
/*
update web.dbo.Artikkler_tekst
set Tekst = @AparagraphText2
where Avis=@ASite
and Lopenr=@LStoryId
and Dato=@LStoryDate
and blokk=1
*/
select @AparagraphText2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment