This task has been removed from NuGet package version 2.0.1.1 onwards. Use SQL.QueryData instead.
This task takes an SELECT SQL query, executes it against a given database with parameters and returns the resulting data as an XML document.
Input Parameters
SQLQuery- The SELECT query that will be executed to the database.
- The following restrictions apply to the SQL query:
- COMPUTE BY or FOR BROWSE are not allowed
- GROUP BY and aggregate functions are not allowed
- CURSOR are not allowed
- User defined functions or stored procedures are not allowed
RootElementName- The root element name of the resulting XML document of the SELECT query.
Parameters- A list of parameters to be executed in the query.
ConnectionString- The connection string of the database the query is executed to.
TimeoutS- The timeout of the query in seconds.
Output Result
String- A string containing XML document resulting from the query.
Example Usage
SQLQuery
SELECT TOP 1 [Title] ,[Artist] ,[Country] ,[Company] ,[Price] ,[Year] FROM [dbo].[CDInformation] WHERE Title = @TitleParameter
RootElementName RootElement
Parameters TitleParameter = Empire Burlesque
Returns the following XML document:
<RootElement>
<dbo.CDInformation>
<Title>Empire Burlesque</Title>
<Artist>Bob Dylan</Artist>
<Country>USA</Country>
<Company>Columbia</Company>
<Price>10.90</Price>
<Year>1985</Year>
</dbo.CDInformation>
</RootElement>
Errors
The task will return an exception The query returned no results. if the SQL query returned 0 records.