Showing posts with label type. Show all posts
Showing posts with label type. Show all posts

Friday, March 30, 2012

replacing nodes and sub-trees

Hi,

I have an table where I use XML data type to store documents. The following is an example of original document:

<!ORIGINAL DOCUMENT>

<ABC>

<xyz>.....</xyz>

<xyz>.....</xyz>

<gef>.....</gef>

<qew>....</qew>

</ABC>

<!NEW DOCUMENT>

<ABC>

<xyz>.....</xyz>

<gef>.....</gef>

<reb>....</reb>

</ABC>

My question is how to update the original document so that the two previous instances of xyz tag are replaced by the new single xyz tag, the original gef tag is replaced by the new gef tag, and the reb tag is added to the original document as it is not not present in the original document. The qew will not be updated. I can do this using DOM but I am looking to accomplish this using xquery and xml dml. Is this possible ? I appreciate help on this.

Thanks

It sounds like your algorithm is

For each element name in the NEW document, delete all the elements of that name in the OLD document and insert the new element into the OLD document.

You could do this w/ XQuery DML by generating a DML statement based on the NEW document.

replacing join operation in XML

is it possible to replace join type ( for eg. nested loop with hash
join and so on) in xml plan...
we will fst take plan in xml format ( show xml plan ) and then we will
replace join with other one .. and then execute this plane .. to see
the effect...
for this we need to understand the way join information get stored in
xml ...and then replace...
for any extra info we can put garbage .. which will be filled by
actual value while execution...
so my question is : is it possible...( i think it is very much
possible)
and if yes then guide me... from where i can get these join
format .. so that i can replace...
or just running query on some dataset for both join type and thn
comparing the way the get stored .. is sufficient to convert...
thankx
Can you be a bit more precise what you want to do? You want to change the
showplan to then force a different plan? You can try, but you should be
careful.
Best regards
Michael
<Preeti.s83@.gmail.com> wrote in message
news:1170427166.173456.152840@.j27g2000cwj.googlegr oups.com...
> is it possible to replace join type ( for eg. nested loop with hash
> join and so on) in xml plan...
> we will fst take plan in xml format ( show xml plan ) and then we will
> replace join with other one .. and then execute this plane .. to see
> the effect...
> for this we need to understand the way join information get stored in
> xml ...and then replace...
> for any extra info we can put garbage .. which will be filled by
> actual value while execution...
> so my question is : is it possible...( i think it is very much
> possible)
> and if yes then guide me... from where i can get these join
> format .. so that i can replace...
> or just running query on some dataset for both join type and thn
> comparing the way the get stored .. is sufficient to convert...
> thankx
>

replacing join operation in XML

is it possible to replace join type ( for eg. nested loop with hash
join and so on) in xml plan...
we will fst take plan in xml format ( show xml plan ) and then we will
replace join with other one .. and then execute this plane .. to see
the effect...
for this we need to understand the way join information get stored in
xml ...and then replace...
for any extra info we can put garbage .. which will be filled by
actual value while execution...
so my question is : is it possible...( i think it is very much
possible)
and if yes then guide me... from where i can get these join
format .. so that i can replace...
or just running query on some dataset for both join type and thn
comparing the way the get stored .. is sufficient to convert...
thankx
Hi
"Preeti.s83@.gmail.com" wrote:

> is it possible to replace join type ( for eg. nested loop with hash
> join and so on) in xml plan...
> we will fst take plan in xml format ( show xml plan ) and then we will
> replace join with other one .. and then execute this plane .. to see
> the effect...
You can use JOIN hints to force a specific type of join.
e.g.
USE ADVENTUREWORKS
GO
DBCC DROPCLEANBUFFERS
GO
DBCC FREEPROCCACHE
GO
SET SHOWPLAN_XML ON
GO
SELECT *
FROM HumanResources.Employee E
INNER JOIN HumanResources.EmployeeAddress A ON E.EmployeeID = A.EmployeeID
/* Should be merge join */
SELECT *
FROM HumanResources.Employee E
INNER HASH JOIN HumanResources.EmployeeAddress A ON E.EmployeeID =
A.EmployeeID
/* Will be hash join */
SET SHOWPLAN_XML OFF

> for this we need to understand the way join information get stored in
> xml ...and then replace...
> for any extra info we can put garbage .. which will be filled by
> actual value while execution...
Showing the plan is not the same as storing it. You can not change the
output from the SHOWPLAN to effect the way a query is executed.

> so my question is : is it possible...( i think it is very much
> possible)
> and if yes then guide me... from where i can get these join
> format .. so that i can replace...
> or just running query on some dataset for both join type and thn
> comparing the way the get stored .. is sufficient to convert...
> thankx
>
Hopefully I have understood your question!
John
sql

replacing join operation in XML

is it possible to replace join type ( for eg. nested loop with hash
join and so on) in xml plan...
we will fst take plan in xml format ( show xml plan ) and then we will
replace join with other one .. and then execute this plane .. to see
the effect...
for this we need to understand the way join information get stored in
xml ...and then replace...
for any extra info we can put garbage .. which will be filled by
actual value while execution...
so my question is : is it possible...( i think it is very much
possible)
and if yes then guide me... from where i can get these join
format .. so that i can replace...
or just running query on some dataset for both join type and thn
comparing the way the get stored .. is sufficient to convert...
thankxHi
"Preeti.s83@.gmail.com" wrote:

> is it possible to replace join type ( for eg. nested loop with hash
> join and so on) in xml plan...
> we will fst take plan in xml format ( show xml plan ) and then we will
> replace join with other one .. and then execute this plane .. to see
> the effect...
You can use JOIN hints to force a specific type of join.
e.g.
USE ADVENTUREWORKS
GO
DBCC DROPCLEANBUFFERS
GO
DBCC FREEPROCCACHE
GO
SET SHOWPLAN_XML ON
GO
SELECT *
FROM HumanResources.Employee E
INNER JOIN HumanResources.EmployeeAddress A ON E.EmployeeID = A.EmployeeID
/* Should be merge join */
SELECT *
FROM HumanResources.Employee E
INNER HASH JOIN HumanResources.EmployeeAddress A ON E.EmployeeID =
A.EmployeeID
/* Will be hash join */
SET SHOWPLAN_XML OFF

> for this we need to understand the way join information get stored in
> xml ...and then replace...
> for any extra info we can put garbage .. which will be filled by
> actual value while execution...
Showing the plan is not the same as storing it. You can not change the
output from the SHOWPLAN to effect the way a query is executed.

> so my question is : is it possible...( i think it is very much
> possible)
> and if yes then guide me... from where i can get these join
> format .. so that i can replace...
> or just running query on some dataset for both join type and thn
> comparing the way the get stored .. is sufficient to convert...
> thankx
>
Hopefully I have understood your question!
John

replacing join operation in XML

is it possible to replace join type ( for eg. nested loop with hash
join and so on) in xml plan...
we will fst take plan in xml format ( show xml plan ) and then we will
replace join with other one .. and then execute this plane .. to see
the effect...
for this we need to understand the way join information get stored in
xml ...and then replace...
for any extra info we can put garbage .. which will be filled by
actual value while execution...
so my question is : is it possible...( i think it is very much
possible)
and if yes then guide me... from where i can get these join
format .. so that i can replace...
or just running query on some dataset for both join type and thn
comparing the way the get stored .. is sufficient to convert...
thankxCan you be a bit more precise what you want to do? You want to change the
showplan to then force a different plan? You can try, but you should be
careful.
Best regards
Michael
<Preeti.s83@.gmail.com> wrote in message
news:1170427166.173456.152840@.j27g2000cwj.googlegroups.com...
> is it possible to replace join type ( for eg. nested loop with hash
> join and so on) in xml plan...
> we will fst take plan in xml format ( show xml plan ) and then we will
> replace join with other one .. and then execute this plane .. to see
> the effect...
> for this we need to understand the way join information get stored in
> xml ...and then replace...
> for any extra info we can put garbage .. which will be filled by
> actual value while execution...
> so my question is : is it possible...( i think it is very much
> possible)
> and if yes then guide me... from where i can get these join
> format .. so that i can replace...
> or just running query on some dataset for both join type and thn
> comparing the way the get stored .. is sufficient to convert...
> thankx
>

replacing join operation in XML

is it possible to replace join type ( for eg. nested loop with hash
join and so on) in xml plan...
we will fst take plan in xml format ( show xml plan ) and then we will
replace join with other one .. and then execute this plane .. to see
the effect...

for this we need to understand the way join information get stored in
xml ...and then replace...
for any extra info we can put garbage .. which will be filled by
actual value while execution...

so my question is : is it possible...( i think it is very much
possible)
and if yes then guide me... from where i can get these join
format .. so that i can replace...
or just running query on some dataset for both join type and thn
comparing the way the get stored .. is sufficient to convert...

thankx(Preeti.s83@.gmail.com) writes:

Quote:

Originally Posted by

is it possible to replace join type ( for eg. nested loop with hash
join and so on) in xml plan...
we will fst take plan in xml format ( show xml plan ) and then we will
replace join with other one .. and then execute this plane .. to see
the effect...
>
for this we need to understand the way join information get stored in
xml ...and then replace...
for any extra info we can put garbage .. which will be filled by
actual value while execution...
>
so my question is : is it possible...( i think it is very much
possible)
and if yes then guide me... from where i can get these join
format .. so that i can replace...
or just running query on some dataset for both join type and thn
comparing the way the get stored .. is sufficient to convert...


You don't say what the purpose would be to change the XML document. When
you talk about "join information get stored in xml" I get a bit nervous.
The XML document is just a representation of the query plan; it's not
a storage of its own.

That said, there is a point with retrieving a query plan and modify it
since you can use it in a plan guide, or with the query hint USE PLAN.
This is quite an advanced feature, and requires good understanding
of query plans to be successful. There is no risk that you will
cause incorrect results with a plan guide, the optimizer still
validates that the plan is correct, in which case it discards the
plan.

I have tried this sort of operation myself, and all I can recommend
is that you look at plans of the type you want to achieve and
play around. It will probably take some time, but you learn a lot
along the way. To get started, you can use query hints to force a
certain type of join, so you get to see different types of joins.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

replacing join operation in XML

is it possible to replace join type ( for eg. nested loop with hash
join and so on) in xml plan...
we will fst take plan in xml format ( show xml plan ) and then we will
replace join with other one .. and then execute this plane .. to see
the effect...
for this we need to understand the way join information get stored in
xml ...and then replace...
for any extra info we can put garbage .. which will be filled by
actual value while execution...
so my question is : is it possible...( i think it is very much
possible)
and if yes then guide me... from where i can get these join
format .. so that i can replace...
or just running query on some dataset for both join type and thn
comparing the way the get stored .. is sufficient to convert...
thankxHi
"Preeti.s83@.gmail.com" wrote:
> is it possible to replace join type ( for eg. nested loop with hash
> join and so on) in xml plan...
> we will fst take plan in xml format ( show xml plan ) and then we will
> replace join with other one .. and then execute this plane .. to see
> the effect...
You can use JOIN hints to force a specific type of join.
e.g.
USE ADVENTUREWORKS
GO
DBCC DROPCLEANBUFFERS
GO
DBCC FREEPROCCACHE
GO
SET SHOWPLAN_XML ON
GO
SELECT *
FROM HumanResources.Employee E
INNER JOIN HumanResources.EmployeeAddress A ON E.EmployeeID = A.EmployeeID
/* Should be merge join */
SELECT *
FROM HumanResources.Employee E
INNER HASH JOIN HumanResources.EmployeeAddress A ON E.EmployeeID =A.EmployeeID
/* Will be hash join */
SET SHOWPLAN_XML OFF
> for this we need to understand the way join information get stored in
> xml ...and then replace...
> for any extra info we can put garbage .. which will be filled by
> actual value while execution...
Showing the plan is not the same as storing it. You can not change the
output from the SHOWPLAN to effect the way a query is executed.
> so my question is : is it possible...( i think it is very much
> possible)
> and if yes then guide me... from where i can get these join
> format .. so that i can replace...
> or just running query on some dataset for both join type and thn
> comparing the way the get stored .. is sufficient to convert...
> thankx
>
Hopefully I have understood your question!
John

Wednesday, March 28, 2012

Replacing all occurrences of a string in a VARCHAR column?

Hi All
I have table Tab1 with a column Col1 of data type VARCHAR. I want to
replace every "Kop " string in that column with "HY". Is there an easy way to
do this. Below is an example with column Col1 with 2 rows of data:
Col1
---
J Dixion
K Kop
I got some helpful scripts on replacing a string within a TEXT column last
time like the one below. I have tried those scripts on other data types of
data like VARCHAR and it did not work.
http://aspfaq.com/show.asp?id=2445
Thank you in advance.MittyKom,
Try the T-SQL REPLACE function.
HTH
Jerry
"MittyKom" <MittyKom@.discussions.microsoft.com> wrote in message
news:8F17586A-F6F6-46D1-A47D-5C85F3D36E9D@.microsoft.com...
> Hi All
> I have table Tab1 with a column Col1 of data type VARCHAR. I want to
> replace every "Kop " string in that column with "HY". Is there an easy way
> to
> do this. Below is an example with column Col1 with 2 rows of data:
> Col1
> ---
> J Dixion
> K Kop
> I got some helpful scripts on replacing a string within a TEXT column last
> time like the one below. I have tried those scripts on other data types of
> data like VARCHAR and it did not work.
> http://aspfaq.com/show.asp?id=2445
> Thank you in advance.
>

Replacing all occurrences of a string in a VARCHAR column?

Hi All
I have table Tab1 with a column Col1 of data type VARCHAR. I want to
replace every "Kop " string in that column with "HY". Is there an easy way to
do this. Below is an example with column Col1 with 2 rows of data:
Col1
J Dixion
K Kop
I got some helpful scripts on replacing a string within a TEXT column last
time like the one below. I have tried those scripts on other data types of
data like VARCHAR and it did not work.
http://aspfaq.com/show.asp?id=2445
Thank you in advance.
MittyKom,
Try the T-SQL REPLACE function.
HTH
Jerry
"MittyKom" <MittyKom@.discussions.microsoft.com> wrote in message
news:8F17586A-F6F6-46D1-A47D-5C85F3D36E9D@.microsoft.com...
> Hi All
> I have table Tab1 with a column Col1 of data type VARCHAR. I want to
> replace every "Kop " string in that column with "HY". Is there an easy way
> to
> do this. Below is an example with column Col1 with 2 rows of data:
> Col1
> J Dixion
> K Kop
> I got some helpful scripts on replacing a string within a TEXT column last
> time like the one below. I have tried those scripts on other data types of
> data like VARCHAR and it did not work.
> http://aspfaq.com/show.asp?id=2445
> Thank you in advance.
>

Replacing all occurrences of a string in a VARCHAR column?

Hi All
I have table Tab1 with a column Col1 of data type VARCHAR. I want to
replace every "Kop " string in that column with "HY". Is there an easy way t
o
do this. Below is an example with column Col1 with 2 rows of data:
Col1
---
J Dixion
K Kop
I got some helpful scripts on replacing a string within a TEXT column last
time like the one below. I have tried those scripts on other data types of
data like VARCHAR and it did not work.
http://aspfaq.com/show.asp?id=2445
Thank you in advance.UPDATE tab1
SET col1 = REPLACE(col1,'Kop','HY')
WHERE col1 LIKE '%Kop%' ;
David Portas
SQL Server MVP
--|||Thank you Dave. It got the job. Thank you once again.
--
5 years experience with SQL Server 2000 and SAP BW/SEM
"David Portas" wrote:

> UPDATE tab1
> SET col1 = REPLACE(col1,'Kop','HY')
> WHERE col1 LIKE '%Kop%' ;
> --
> David Portas
> SQL Server MVP
> --
>
>

Replacing all occurrences of a string in a VARCHAR column?

Hi All
I have table Tab1 with a column Col1 of data type VARCHAR. I want to
replace every "Kop " string in that column with "HY". Is there an easy way t
o
do this. Below is an example with column Col1 with 2 rows of data:
Col1
---
J Dixion
K Kop
I got some helpful scripts on replacing a string within a TEXT column last
time like the one below. I have tried those scripts on other data types of
data like VARCHAR and it did not work.
http://aspfaq.com/show.asp?id=2445
Thank you in advance.MittyKom,
Try the T-SQL REPLACE function.
HTH
Jerry
"MittyKom" <MittyKom@.discussions.microsoft.com> wrote in message
news:8F17586A-F6F6-46D1-A47D-5C85F3D36E9D@.microsoft.com...
> Hi All
> I have table Tab1 with a column Col1 of data type VARCHAR. I want to
> replace every "Kop " string in that column with "HY". Is there an easy way
> to
> do this. Below is an example with column Col1 with 2 rows of data:
> Col1
> ---
> J Dixion
> K Kop
> I got some helpful scripts on replacing a string within a TEXT column last
> time like the one below. I have tried those scripts on other data types of
> data like VARCHAR and it did not work.
> http://aspfaq.com/show.asp?id=2445
> Thank you in advance.
>

Replacing a character

Hi

I have a table with column type as ntext. I need to modify the column value. I wanted to replace a given character\string with another one in this column. Any assistance on this is highly appreciated.

Thanks!

Santhosh

Santhosh,

1) If the text in the column is not too long, you can cast ntext to nvarchar and use replace function.

2) check this link http://www.webpowersoftware.co.uk/FORUMS/ShowPost.aspx?PostID=336

rgds,

v r kumar

Friday, March 23, 2012

Replace on a text field.

I need to search for all occurances of particular string within a column on a table. The column has a data type of Text. It will not allow me to use the replace function on a Text field only on varchars or chars. Does anybody have any ideas of how I can do this?njjones,

Look at Full Text Indexing in Books Online (BOL).

If however you can guarantee that none of the fields exceed 8000 characters you could CAST the TEXT field to a VARCHAR(8000). ie.

REPLACE(CAST(yourtextcolumn AS VARCHAR(8000)),'ABC','DEF')

macka.|||I have done that however quite a lot of the fields I need to affect are greater than 8000 characters (hence using the text datatype). I wanted to run a query to find out how many were longer but you can't use Len on a text field either - is there an easy way of finding the character length of text in a text column?|||Chances are not many will be exactly 8000 in length, so the following query gives you a rough idea of how many are bigger than 8k, but truncating all fields to 8000 characters.

SELECT COUNT(*)
FROM yourtable
WHERE LEN((CAST(yourtextcolumn AS VARCHAR(8000)))) = 8000

macka.|||The following works - seems a little heavy handed for a replacement of a one line function, but any:

declare datacursor cursor
for
select
dataid, TEXTPTR(description)
from
tbl_data
where
description like '%25.224.8.30%'
declare @.ptrval binary(16)
declare @.dataid int
declare @.pos1 int
open datacursor
fetch next from datacursor
into @.dataid, @.ptrval
while @.@.fetch_status = 0
begin
select @.pos1 = patindex('%25.224.8.30%',tbl_data.description) from
tbl_data where dataid = @.dataid
while @.pos1 <> 0
begin
set @.pos1 = @.pos1-1
updatetext tbl_data.description @.ptrval @.pos1 11
'modconnect1.qinetiq.r.mil.uk'
select @.pos1 =
patindex('%25.224.8.30%',tbl_data.description) from tbl_data where dataid =
@.dataid
end
fetch next from datacursor
into @.dataid, @.ptrval
end
close datacursor
deallocate datacursor|||njjones,

Did you ever get the 'replace' issue resolved in a Text field? I need to do a similar action, finding all the commas in a text field and replacing it with a semi-colon.

Thanks.|||The answer is above, however I have recopied and pasted it below and updated it so that it should work for , and ; - probably could have parameterised this and turned it in a user defined function but it is not something I have needed to do often enough to bother with:

declare datacursor cursor
for
select
dataid, TEXTPTR(description)
from
tbl_data
where
description like '%,%'
declare @.ptrval binary(16)
declare @.dataid int
declare @.pos1 int
open datacursor
fetch next from datacursor
into @.dataid, @.ptrval
while @.@.fetch_status = 0
begin
select @.pos1 = patindex('%,%',tbl_data.description) from
tbl_data where dataid = @.dataid
while @.pos1 <> 0
begin
set @.pos1 = @.pos1-1
updatetext tbl_data.description @.ptrval @.pos1 1
';'
select @.pos1 =
patindex('%,%',tbl_data.description) from tbl_data where dataid =
@.dataid
end
fetch next from datacursor
into @.dataid, @.ptrval
end
close datacursor
deallocate datacursor|||Nicky, thanks. A couple of quick modifications and I had this working well for my table. I appreciate it.

RY

Wednesday, March 21, 2012

REPLACE function needed to remove single quotes from an output

I have a variable @.var1 of type varchar(100) which captures the following
error message, which is produced by executing a sql statement:
Incorrect syntax near the keyword 'where'.
Please pay special attention to the single quotes around the word where.
These single quotes are causing a lot of problems when I include the above
error message as-is in XML processing.
If I remove both the above single quotes manually, things work fine.
Also, if I change them to two single quotes, things also work fine. But
since this message is captured programatically, I cannot manipulate it in
these two ways.
Alternatively, I decided to remove these two single quotes around the word
where. I tried using the following but did not succeed.
I am using the REPLACE function, which has the following syntax: REPLACE (
'string_expression1' , 'string_expression2' , 'string_expression3' )
So, in my case: select REPLACE(@.var1, '', ' ')
In the above expression, I am basically attempting to replace the single
quotes with a space.
Please note that the string_expression2 is two single quotes.
string_expression3 is a single quote followed by a space and then followed
by single quote.
This statement produces another error: An expression of non-boolean type
specified in a context where a condition is expected, near 'select'.
Basically, if re-run this same replace by changing single quotes to two
single quotes, the above replace statement does not produce an error.
Could somebody help me get a working REPLACE statement which will give me my
original error message free of single quotes in the following form.
Incorrect syntax near the keyword where.
Appreciate your help.
ThanksHB
Can you show us @.var1 ?
"HB" <nospam@.microsoft.com> wrote in message
news:%232SpQF5qFHA.1788@.tk2msftngp13.phx.gbl...
>I have a variable @.var1 of type varchar(100) which captures the following
> error message, which is produced by executing a sql statement:
> Incorrect syntax near the keyword 'where'.
> Please pay special attention to the single quotes around the word where.
> These single quotes are causing a lot of problems when I include the above
> error message as-is in XML processing.
> If I remove both the above single quotes manually, things work fine.
> Also, if I change them to two single quotes, things also work fine. But
> since this message is captured programatically, I cannot manipulate it in
> these two ways.
> Alternatively, I decided to remove these two single quotes around the word
> where. I tried using the following but did not succeed.
> I am using the REPLACE function, which has the following syntax: REPLACE (
> 'string_expression1' , 'string_expression2' , 'string_expression3' )
> So, in my case: select REPLACE(@.var1, '', ' ')
> In the above expression, I am basically attempting to replace the single
> quotes with a space.
> Please note that the string_expression2 is two single quotes.
> string_expression3 is a single quote followed by a space and then followed
> by single quote.
> This statement produces another error: An expression of non-boolean type
> specified in a context where a condition is expected, near 'select'.
> Basically, if re-run this same replace by changing single quotes to two
> single quotes, the above replace statement does not produce an error.
> Could somebody help me get a working REPLACE statement which will give me
> my
> original error message free of single quotes in the following form.
> Incorrect syntax near the keyword where.
> Appreciate your help.
> Thanks
>|||Hello, HB
To remove the single quotes from a string, use:
REPLACE(@.var1, '''', ' ')
(there are 4 quotes as the second parameter; that is because to specify
a single quote in a string, you have to type a quote twice, for
example: 'McDonald''s')
A better idea would be to properly use XML escape sequences for any
special characters, i.e: instead of "<" use "<", instead of a single
quote, use "'", etc. If we consider only the standard special
characters, we can use:
SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
@.var,
'&','&'),'<','<'),'>','>'),'"','"'),'''',''')
But we must also consider that there are accented characters, which
should also be escaped in an XML string, so the best way would be to
construct the XML string using a XML parser (like MSXML), using the
DOM, for example.
Razvan|||Razvan,
Thanks so much for your suggestions.
I am trying to construct the XML string in SQL. Given that SQL is limited
(as far as processing strings) compared to pure programming languages (C++,
C# etc.), what do you suggest I should do to accomplish the escaping of
various characters, including the special ones, like you wrote in your post?
Like I mentioned in my previous post, I am capturing the error in a SQL
stored procedure and want to ship out that error message as a valid (free
from the characters you mentioned) XML string. So, if possible I would like
to accomplish your suggestions in SQL itself. If you can provide help as to
how to achieve escaping various characters using a general purpose approach
(using DOM or otherwise), that will be great.
Reply appreciated
Thanks again Razvan
"Razvan Socol" <rsocol@.gmail.com> wrote in message
news:1125210516.602885.58280@.g43g2000cwa.googlegroups.com...
> Hello, HB
> To remove the single quotes from a string, use:
> REPLACE(@.var1, '''', ' ')
> (there are 4 quotes as the second parameter; that is because to specify
> a single quote in a string, you have to type a quote twice, for
> example: 'McDonald''s')
> A better idea would be to properly use XML escape sequences for any
> special characters, i.e: instead of "<" use "<", instead of a single
> quote, use "'", etc. If we consider only the standard special
> characters, we can use:
> SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
@.var,
> '&','&'),'<','<'),'>','>'),'"','"'),'''',''')
> But we must also consider that there are accented characters, which
> should also be escaped in an XML string, so the best way would be to
> construct the XML string using a XML parser (like MSXML), using the
> DOM, for example.
> Razvan
>

REPLACE Function for Bad Characters?

I need to know if I can use the REPLACE function to remove bad characters from a data column. The data type is text and I would like to remove any comma's or quotes from the data. I assume that this would be the best way to remove these characters.

I've not been able to find much information on the REPLACE function so I'm not sure if the data can be replaced in the same column or if the
replacement data has to be placed in another column.

Any insight into this matter would be appreciated.

TechRickupdate yourtable
set textcol = replace(replace(textcol,','),'''')

if there is no replacement character, the search character is removed

i'm pretty sure you can nest oracle functions (i can't test it because i don't gots no oracle database)

to create a string consisting of a single quote, i think you have to code two consecutive ones, hence the four of them in a row like that

rudy
http://rudy.ca/|||Thanks for the reply.

I think there is a difference however in the SQL that I'm using verses yours. I'm running on SQL 2000 and doing my queries through the Query Analyzer.

The format for the function command you suggested doesn't seem to work properly for me.

In my SAM's Learn SQL in 21 Days book I have this format given:

SELECT LASTNAME, REPLACE(LASTNAME, 'ST') REPLACEMENT
FROM CHARACTERS;

OUTPUT:
LASTNAME REPLACEMENT
----- -----
CHRISTINE CHRIINE
ADAMS ADAMS
COSTALES COALES

------------------

The problem I have with this is that it takes the replacement data and puts it into another column. I want to keep the updated data in the same column. I guess I may need to live with a 'replacement' column and disregard the original?

Thanks again for your help.

TechRick|||dude, you posted in the "SQL and PL/SQL" forum, you should've posted in the "Microsoft SQL/Server" forum

i naturally assumed oracle, since REPLACE is an oracle function

in sql.server, the replacement string is not optional, so you have to specify it as a zero-length string

see http://msdn.microsoft.com/library/en-us/tsqlref/ts_ra-rz_76lh.asp

so try

update yourtable
set textcol = replace(replace(textcol,',',''),'''','')

:cool:|||Sorry for the confusion. I didn't realize I was in the wrong place.

I'm a newbie to SQL and have only been using it for less than 2 weeks. I'm not yet familiar with all the differences in SQL formats.

I'll try to find my way to the correct forum in the future.

Thanks again for your help.

TechRick|||hey, no problem, i just thought i'd mention why you got an oracle answer instead of an sql/server answer the first time (i am not the moderator of either of these two forums)

so, did the sql/server version work?|||Rudy,

I just finished testing it and sure enough it did the trick! Thanks much for all the help.

One more question, why did you structure it this way:

replace(replace(textcol,',',''),'''','')

I thought it would need to be replace (texcol, ",", " ")

Why the extra replace and the added ),'''','')?

Just wondering.

Thanks again,
TechRick|||one removes commas, the other removes quotes

nesting them passes the result of one into the other

beats using two update stements, eh

rudy|||Very nice.

I should have guessed that was the case.

Thanks again for all your help.

Best Regards,
TechRick|||I think we can also do this using TRANSLATE Function. I tested this one only in ORACLE and not in SQL-Server. I dont know whether we have one similar funtion in SQL-Server.

SELECT emp_id ,
emp_name,
TRANSLATE( emp_name, '%!@.#$^', ' ' )
FROM employee_table ;

Regards,
Sreekon.

Friday, March 9, 2012

repeat group header at top of new page

I have a report of addresses, grouped by Street Name.
Output type is PDF.
When the report breaks onto a new page, I would like the Group Header - the Street Name last listed on the previous page - to repeat at the top.
Currently it seems to only repeat when the Street Name changes.
Is that possible? If so, how?The grouping and sorting properties dialog has an option to repeat the group
header. Setting this option should do the trick for you. Assuming you are
using a table you can reach this feature by opening the table properties
dialog. Next you would click on the Groups tab. Finally you will need to
edit the Streets Name group.
--
Bruce Johnson [MSFT]
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Greg Anderson" <GregAnderson@.discussions.microsoft.com> wrote in message
news:EA1A1F82-AA0D-4445-AC4E-C88C9EDB0444@.microsoft.com...
> I have a report of addresses, grouped by Street Name.
> Output type is PDF.
> When the report breaks onto a new page, I would like the Group Header -
the Street Name last listed on the previous page - to repeat at the top.
> Currently it seems to only repeat when the Street Name changes.
> Is that possible? If so, how?|||Let me also say that I have gone into the Table Properties and set the "Repeat header rows on each page"
This works when I send it a parameter to sort one way - by street name - but not when I send the sort parameter of "sequence" which is another column in my report.
Any ideas?
"Greg Anderson" wrote:
> I have a report of addresses, grouped by Street Name.
> Output type is PDF.
> When the report breaks onto a new page, I would like the Group Header - the Street Name last listed on the previous page - to repeat at the top.
> Currently it seems to only repeat when the Street Name changes.
> Is that possible? If so, how?