Showing posts with label statement. Show all posts
Showing posts with label statement. Show all posts

Wednesday, March 28, 2012

Multi parameter aggregate CLR-function?

In the provided CLR-function sample there is only one parameter from the SQL statement to the function. I can't find any info about how to pass more then one parameter. Is this possible somehow?

like:

Code Snippet

Select ShopCode,PickAValue(OrderDate,Article) as BestArticle

from T_Sales

Group by ShopCode

hans

I was looking at something similar recently and came across this post:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=789719&SiteID=1

It looks like you can only have one parameter in a UDA though the XML work around mentioned may be suitable (I've not tried it, mind).


HTH.

|||

Yes I have found a similar solution, by concatenating the values with a TAB as seperator, this looks like the XML variant, eg putting the values of all needed paramteres in a single string value.

hans

|||

There is a post on the .NET Framework inside SQL Server Katmai forum that says there is a strong possibility multi-input aggregates will be supported in Katmai:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1703860&SiteID=1

Wednesday, March 7, 2012

mssql: case statements with multiple columns

A standard case statement in MSSQL server looks like:
...WHERE s.idMarket =
CASE @.Mode
WHEN 'Sales' THEN 1
ELSE 2
END
but I want a similar statement to use multiple values of 'idMarket' for
each value of '@.Mode'
e.g.
...WHERE s.idMarket =
CASE @.Mode
WHEN 'Sales' THEN 1, 3, 5, 6
ELSE 2, 4, 7, 8, 9
END
is this possible through an mssql query?
cheers.
fiddlewidawiddumYou can't use case that way.
For this may be you can rephrase the where clause this way..
WHERE (@.Mode = 'Sales' and s.idMarket in (1, 3, 5, 6)) or (@.Mode <> 'Sales'
and s.idMarket in (2, 4, 7, 8, 9))
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/
"Stimp" wrote:

> A standard case statement in MSSQL server looks like:
> ...WHERE s.idMarket =
> CASE @.Mode
> WHEN 'Sales' THEN 1
> ELSE 2
> END
> but I want a similar statement to use multiple values of 'idMarket' for
> each value of '@.Mode'
> e.g.
> ...WHERE s.idMarket =
> CASE @.Mode
> WHEN 'Sales' THEN 1, 3, 5, 6
> ELSE 2, 4, 7, 8, 9
> END
> is this possible through an mssql query?
> cheers.
> --
> fiddlewidawiddum
>|||On Mon, 19 Jun 2006 Omnibuzz <Omnibuzz@.discussions.microsoft.com> wrote:
> You can't use case that way.
> For this may be you can rephrase the where clause this way..
> WHERE (@.Mode = 'Sales' and s.idMarket in (1, 3, 5, 6)) or (@.Mode <> 'Sales
'
> and s.idMarket in (2, 4, 7, 8, 9))
that actually works great.. thanks!
--
fiddlewidawiddum|||>> A standard case statement in MSSQL server looks like: <<
There is no CASE statement in SQL; there is a CASE expression. An
expression returns a scalar value of a known data type.
Again, you missed the concept "expression" and "scalar" so the
question is wrong. Then even if it would have worked, you would have
to use IN() and not = in the predicate. Besides not bothering to learn
SQL, why did you violate ISO-11179 by putting "id-" as a prefix? Why
did you use a vague nmae like "mode" --mode of what'
Try something like this:
..WHERE CASE
WHEN S.market_id IN (1, 3, 5, 6)
AND @.mode = 'sales'
THEN 'T'
WHEN S.market_id IN (2, 4, 7, 8, 9)
AND @.mode <> 'sales'--mode of what'
THEN 'T' ELSE 'F' END = 'T';

Monday, February 20, 2012

MSSQL SELECT error

I've the following Select Statement that generates errors, could someone tells me why? :(

SELECT TOP 20 * FROM tickets WHERE ticket_ID NOT IN (SELECT TOP 20 * FROM tickets ORDER BY ticket_ID DESC) ORDER BY ticket_ID DESC;

Warning: mssql_query() [function.mssql-query]: message: Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. (severity 16) in c:\Inetpub\wwwroot\schoolProject\admin\show.php on line 437Try this ??

SELECT TOP 20 * FROM tickets WHERE ticket_ID NOT IN (SELECT TOP 20 ticket_ID FROM tickets ORDER BY ticket_ID DESC) ORDER BY ticket_ID DESC

You had it checking the id against all columns - take it you are trying to get the 21st to 40th most recent??

MSSQL Select commands to FTP

Hello,

Im new to Sql Server Integration Services.

I need to get the data I get from my SQL Select statement into TXT, XML, CSV or Excel file format and then send it with FTP.

What is the easiest method that you recommend that I use?

Thank you very much!!

Data flow to select your records using an OLE DB source. Send those records to a text file (or csv) using the flat file destination.

Then in the control flow, use the FTP task to send that file.|||

Thank you very much for the reply.

I know this sounds simple, but do you know any tutorial out there that shows how to do this?

Thanks again in advance.

|||Try looking through the SSIS tutorials. What you need is pretty basic stuff.

http://msdn2.microsoft.com/en-us/library/ms167031.aspx|||

Thank you so much.

I have one complexity though.

My SSIS flow is gonna be run every day as a sceduled task.

The first time it runs, it has to send a History (Select Statement 1) but every day after that it just has to get the latest info (Select Statement 2).

How do I do this?

Thank you very much in advance!!