Showing posts with label xml. Show all posts
Showing posts with label xml. Show all posts

Tuesday, March 20, 2012

Query Parameter Value Type

What is the attribute/element (such as ValuesTypes, ParameterValuesType..) I should refer to Query Parameter - Value according to the RDL XML Schema Definition as the following example?

<QueryParameters>

<QueryParameter Name="@.CompanyName">

<Value>=Parameters!CompanyName.Value</Value>

</QueryParameter>

</QueryParameters>

Thanks a lot.

Where exactly do you want to refer to the QueryParameter?

I'm not really sure what you are asking. However, if you are wondering where to define the attribute/element of the parameter. You can use this as an example. It is a parameter I created for filtering by Year.

<ReportParameter Name="WHSEDateDimCalendarYear">

<DataType>Integer</DataType>

<Prompt>CalendarYear</Prompt>

<ValidValues>

<DataSetReference>

<DataSetName>WHSEDateDimCalendarYear</DataSetName>

<ValueField>ParameterValue</ValueField>

<LabelField>ParameterCaptionIndented</LabelField>

</DataSetReference>

</ValidValues>

</ReportParameter>

|||Thanks for reply to my post. What I am looking for, is the type of Attribute/Element I should refer to, for QueryParamater -Value. In your post, for example, your ValueField (attribute? or element? i'm not sure about it well) is refer to ItemChoiceType31.ValueField, and DatasetName is refer to ItemChoiceType31.DatasetName according to RDL Report Definition XML Schema. I tried to look for the same as for the QueryParameter -Value, cause there are so many Value type defined in the Schema that I did not know what type of Value i should refer to it.

Monday, March 12, 2012

query output as XML

Hi

Can I have my query output returned as XML (FOR XML AUTO) in SQL Mobile ?

thanks
Bruce

no, not directly from SQL Mobile. you can fill a DataSet with your query results using the adapter or data reader and then convert the DataSet into XML....

-Darren

query out to XML

hi,
i need to write a query and export the result to an xml file. how would I
do that?
thanksHave a look at the 'FOR XML AUTO' extension to the select statement i.e.
select * from yourTable for xml auto
Peter
"Denial ain't just a river in Egypt."
Mark Twain
"Rafael Chemtob" wrote:

> hi,
> i need to write a query and export the result to an xml file. how would I
> do that?
> thanks
>
>

Query out an xml element from a field containing xml data

'message' Field Data:
<xml>
...
<test>ABC</test>
...
</xml
How do I query out 'ABC' from this xml field data in a SQL Server?

Assume message field is in table 'Persons'What you could do, is write a user defined function. Something like

create function [dbo].[fn_GetText]
(
@.Text as XML
)
returns varchar(50)
begin
declare @.Result as varchar(50)
declare @.Count as int
declare @.Start as int

set @.Count = 1
set @.Start = 0

while @.Count <= len(@.Text)
begin
if substring(@.Text, @.Count, 6) = '<test>'
set @.Start = @.Count + 6

if substring(@.Text, @.Count, 7) = '<\test>' and @.Start <> 0
set @.Result = substring(@.Text, @.Start, @.Count - @.Start - 1)

set @.Count = @.Count + 1
end

return @.Result
end

go|||Hi Mike,

thanks for the reply.

As my comfort level is much higher with C#, I just wrote some string
parsing code and got my result :)

Next time I need to spin off a UDF, I will remember this.

Ranjith|||Ranjith (ranjithvenkatesh@.hotmail.com) writes:
> 'message' Field Data:
><xml>
> ...
> <test>ABC</test>
> ...
></xml>
> How do I query out 'ABC' from this xml field data in a SQL Server?
> Assume message field is in table 'Persons'

create table Persons (message xml NOT NULL)
go
insert Persons (message) VALUES('<xml><test>ABC</test></xml>')
go
select message.value(N'(/xml/test)[1]', 'varchar(10)')
from Persons
go
Drop table Persons

This is for SQL 2005. You did not mention which server of SQL Server
you are using. This matters a lot when XML is involved, as the XML
support in SQL 2005 is greatly extended over what is in SQL 2000,
including a new query language, XQuery which I'm using above.

--
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

Wednesday, March 7, 2012

Query on XML column: fn:lower-case not working?

Hi everybody, I'm looking to issue a query to an XML column like this:
SELECT *
FROM dbo.ContactRecords
WHERE XmlContent.exist(
'declare namespace
my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-03-09T14-09
-40";
// my:myFields[my:AddressInfo[fn:contains(f
n:lower-case(my:Company[1]),"lego"
)]]')
= 1
(i skipped some other conditions, but they are working)
--> SQL 2005 tells me: There is no function
'{http://www.w3.org/2004/07/xpath-functions}:lower-case()'
however, there is one...
How can I compare string values in SQL 2005 case-insensitive?
I appreciate your help, have a good day,
MichaelHello michael.hofer@.getronics.com,
Well, you've stumbled into the chasm caused by Microsoft trying to get a
product released and the W3C XQuery WG trying to get things perfect the firs
t
time. There's a number of functions that just aren't implemented in MS's
XQuery heap but are in the spec. We might get them in service packs, or we
might get them in the next version of SQL Server. String-Upper and String-L
ower
are a couple of the common ones that we'd like to have but don't.
Interestingly enough, I see that contains() has a optional collation pattern
.
I try to find a collation that ignored case to test with but didn't have
much immediate luck. If you might want to go down that path. Or not. No prom
ises.
I'd like to offer a suggestion other than .value(path,'varchar(n)') like
'%pattern%' (e.g., do the comparsion in T-SQL as shown below) since this
is fairly ugly for the kind of stuff you're doing. But it does work.
declare @.x xml
set @.x = '<book>Ender''s Game</book><book>Xenocide</book><book>Children of
the Mind</book><book>The Hive Queen</book><book>The Hegemon</book>'
select p.x.value('.','varchar(100)')
from @.x.nodes('/book') as p(x)
where p.x.value('.','varchar(100)') like '%the%'
Thank you,
Kent Tegels
DevelopMentor
http://staff.develop.com/ktegels/