Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Friday, March 30, 2012

how to Diff vs Sum in Group By query?

Hello,
if area 'A' contains 2 numbers in 2 rows then
Select area, Sum(number) from tbl1 where area = 'A'
Group By area
gives me the sum of these 2 numbers in area 'A'
But how can I retrieve the difference of these 2 numbers
using T-Sql?
Thanks,
RonRon wrote:
> Hello,
> if area 'A' contains 2 numbers in 2 rows then
> Select area, Sum(number) from tbl1 where area = 'A'
> Group By area
> gives me the sum of these 2 numbers in area 'A'
> But how can I retrieve the difference of these 2 numbers
> using T-Sql?
> Thanks,
> Ron
Max(number) - Min(number)
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||Thanks. That is pretty . I forgot to include a
twist in here. I also have a datefld. So num1 may be min
or num may be max. I have to show +num or -num.
select area, (First(num) - Last(num)) as num1 from tbl1
where datefld between '1/1/2005' and 1/2/2005' Group By
area having area = 'A'
I was able to use your trick to get my positive or
negative result using First and Last functions. Any
suggestions appreciated if this is incorrect usage.
Thanks again,
Ron

>--Original Message--
>Ron wrote:
>Max(number) - Min(number)
>Bob Barrows
>--
>Microsoft MVP -- ASP/ASP.NET
>Please reply to the newsgroup. The email account listed
in my From
>header is my spam trap, so I don't check it very often.
You will get a
>quicker response by posting to the newsgroup.
>
>.
>|||Ron wrote:
> Thanks. That is pretty . I forgot to include a
> twist in here. I also have a datefld. So num1 may be min
> or num may be max. I have to show +num or -num.
> select area, (First(num) - Last(num)) as num1 from tbl1
> where datefld between '1/1/2005' and 1/2/2005' Group By
> area having area = 'A'
> I was able to use your trick to get my positive or
> negative result using First and Last functions. Any
> suggestions appreciated if this is incorrect usage.
First? Last? You must be using Access ... This is a SQL Server group
Do you need a SQL Server (Transact-SQL) solution? Those fnctions do not
exist in T-SQL.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||On Fri, 25 Feb 2005 11:19:41 -0800, Ron wrote:

>Thanks. That is pretty . I forgot to include a
>twist in here. I also have a datefld. So num1 may be min
>or num may be max. I have to show +num or -num.
>select area, (First(num) - Last(num)) as num1 from tbl1
>where datefld between '1/1/2005' and 1/2/2005' Group By
>area having area = 'A'
>I was able to use your trick to get my positive or
>negative result using First and Last functions. Any
>suggestions appreciated if this is incorrect usage.
Hi Ron,
Try if this helps:
SELECT G.Area, F.num - L.num AS num1
FROM (SELECT area, MIN(datefld) AS FDate, MAX(datefld) AS LDate
FROM tbl1
WHERE datefld BETWEEN '20050101' AND '20050201'
GROUP BY area) AS G
INNER JOIN tbl1 AS F
ON F.area = G.area
AND F.datefld = G.FDate
INNER JOIN tbl1 AS L
ON L.area = G.area
AND L.datefld = G.LDate
WHERE G.area = 'A'
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||SELECT A.area, A.num-B.num
FROM Tbl1 AS A
JOIN Tbl1 AS B
ON A.datefld < B.datefld
AND A.area = 'A'
AND B.area = 'A'
David Portas
SQL Server MVP
--|||Yes, I figured that out. I was writing the sql in Access
and transferring in to Query Analyzer. Sorry bout that.
I did end up creating a udf for first and last.

>--Original Message--
>Ron wrote:
min
>First? Last? You must be using Access ... This is a SQL
Server group
>Do you need a SQL Server (Transact-SQL) solution? Those
fnctions do not
>exist in T-SQL.
>
>Bob Barrows
>--
>Microsoft MVP -- ASP/ASP.NET
>Please reply to the newsgroup. The email account listed
in my From
>header is my spam trap, so I don't check it very often.
You will get a
>quicker response by posting to the newsgroup.
>
>.
>|||Thanks. I will give that a try.

>--Original Message--
>On Fri, 25 Feb 2005 11:19:41 -0800, Ron wrote:
>
min
>Hi Ron,
>Try if this helps:
>SELECT G.Area, F.num - L.num AS num1
>FROM (SELECT area, MIN(datefld) AS FDate, MAX
(datefld) AS LDate
> FROM tbl1
> WHERE datefld BETWEEN '20050101'
AND '20050201'
> GROUP BY area) AS G
>INNER JOIN tbl1 AS F
> ON F.area = G.area
> AND F.datefld = G.FDate
>INNER JOIN tbl1 AS L
> ON L.area = G.area
> AND L.datefld = G.LDate
>WHERE G.area = 'A'
>
>Best, Hugo
>--
>(Remove _NO_ and _SPAM_ to get my e-mail address)
>.
>|||Thanks very much for your reply. I will give this a try.

>--Original Message--
>SELECT A.area, A.num-B.num
> FROM Tbl1 AS A
> JOIN Tbl1 AS B
> ON A.datefld < B.datefld
> AND A.area = 'A'
> AND B.area = 'A'
>--
>David Portas
>SQL Server MVP
>--
>.
>

Monday, March 12, 2012

How To Deploy SSRS To Production Server ?

Hi All

I am having a problem with SSRS reports which I hope you can help with.

We have a web application which contains a couple dozen reports built using SSRS. In order to do a new release I first deploy the web application and the SSRS reports to our pre-production server for testing.

Whilst testing is going on, developers are making further changes to some of the reports and also the the database structure.

My problem is that when I want to move the new release from the pre-production server to the production server, I can copy the application but not the SSRS reports. So my only choice appears to be to deploy the SSRS reports from a devlopment machien directly to the production server.

This is clearly going to cause me problems as those reports may have been further developed and the database structure may have changed sine deploying the application to the pre-production server so I am effectly releasing untested reports directly to the production srever.

So my quesiton is:

How can I copy my SSRS reports from the pre-production server to the production server? Is there another way of dong this?

Regards

Smeat

yes.....

can we just get a link to this tool pinned?

www.sqldbatips.com

has a tool called Reporting Services Scripter 2.0.0.8

1.you point it at RS, set the options, it creates the script + files
2.global find replace in the files i.e. change servernames
3.run script

I suggest you try this in some kind of development environment first to understand all the different options this tool has|||

Thanks for the info.

One of our developers is checking this out.

Smeat

|||

One way of accompishing your goal will be using a version control software like Visual Source Safe. Here's the scenario.

1. Developer develops version 1 of report and check in Visual Source Safe.

2. Designated person (configuration administrator) pushes version 1 of report to pre-production environment.

3. Report is tested by QA group & users in the pre-production environment.

4. QA group and/or users discover errors and/or updates to be done by developers on version 1 of the report.

5. Developer implements updates and fix errors found on version 1 of the report & check in new version into Visual Source Safe (version 2).

6. Repeat step 2 but this time will be version 2 of the report.

7. Repeat step 3. Move to next step (step 8) if QA group & users are OK with updates; otherwise, repeat step 5 - 7

8. Designated person (configuration administrator) pushes final version of report to production.

I hope this helps.

Sunday, February 19, 2012

How to defne a globale variable in the report

I want's to define some global contant variable which contains some values

Like Name="Abc"

Age=123

Date=12/12/2006

How can i define it on sql server reporting serices report and access it value to assign on some fields?

You could use hidden parameters with default values I guess.

1 - Add a parameter to your report and set it to the correct type (string / number etc) and mark it as hidden

2 - Set the default value that you want for it

3 - In your report, access it with something like "=Parameters!theParameter.Value"

Regards Andreas

|||

On the report properties, click on the Code tab and define it there, e.g.

Public Dim Age as Integer = 123

Then, you can reference it in the report as =Code.Age

|||

Which approach will be best for performance?

Can anybody give the pros and cons of the both approaches .

|||

If you want to be able to change the defined variables when calling a report it's good to have them as parameters. Lets say you programatically calls the report because you want to render a report in a WinForms app or something and want to be able to set the parameters from the winForms app, then the hidden parameter way is a good way I guess.

Otherwise, I suggest you do as Teo says.

Regards Andreas

|||

hi,

but parameters are readonly.

You cant set them through your custom code.

hemant

How to defne a globale variable in the report

I want's to define some global contant variable which contains some values

Like Name="Abc"

Age=123

Date=12/12/2006

How can i define it on sql server reporting serices report and access it value to assign on some fields?

You could use hidden parameters with default values I guess.

1 - Add a parameter to your report and set it to the correct type (string / number etc) and mark it as hidden

2 - Set the default value that you want for it

3 - In your report, access it with something like "=Parameters!theParameter.Value"

Regards Andreas

|||

On the report properties, click on the Code tab and define it there, e.g.

Public Dim Age as Integer = 123

Then, you can reference it in the report as =Code.Age

|||

Which approach will be best for performance?

Can anybody give the pros and cons of the both approaches .

|||

If you want to be able to change the defined variables when calling a report it's good to have them as parameters. Lets say you programatically calls the report because you want to render a report in a WinForms app or something and want to be able to set the parameters from the winForms app, then the hidden parameter way is a good way I guess.

Otherwise, I suggest you do as Teo says.

Regards Andreas

|||

hi,

but parameters are readonly.

You cant set them through your custom code.

hemant

How to define a user variable on Execute Sql Task?

Hi everyone,

How to define a Input variable in a Execute Sql Task?

I've defined a User::Inicio variable which contains 4 as value.

In Parameter Mappins it has been defined. Then, I've gone to General->Sql Statement and allocated the following SQL Statement:

UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = [Inicio]

or

UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = [User::Inicio]

Anyway, I'm stuck, both did not work

Thanks in advance for your comments

Enric,

Use an expression in SQlStatementSource property of your Execute SQL task to build your SQL statement:

"UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = " @.[User::Inicio]

Rafael Salas

|||

Hi Rafael,

Thanks for your quick answer but it doesn't work.

[Execute SQL Task] Error: Executing the query "UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = [@.User::Inicio]" failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Let me know, I can imagine that's a silly thing..

|||

Well, the error talks abour the ResulSet porperty; what is your value for that? what is you set that to None. Also i think you do not need anything in your parameter tab since the SQL statement is being created by the expression

RAfael Salas

|||Rafael is telling you to set an Expression for the SQLStatementSource property and not set the property value directly. Looks like you set the SQLStatementSource directly to "UPDATE CARGAPROCESOS SET FECHAULTIMACARGA = " + @.[User::Inicio]. To set an expression for the SQLStatementSource property click on the Expressions node on the left hand side of the Execute SQL Task Editor dialog.|||

Hi,

You mean you want to use the user variable in your query right?

Refer this:

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

|||Thanks to all of you