Don't call me a geek!

A Systems Analyst's blog

Running total with if statement – Reporting services

leave a comment »

 

=Count(iif(Trim(Fields!FoodPurch.Value)=”Dog Food”,Fields!FoodPurch.Value, Nothing))

Written by Linda P.

October 20, 2009 at 11:15 am

SQL – delete duplicate (similar) records

leave a comment »

delete

updated_date

(

from cstd_company_seg where inselect min(updated_date) from cstd_company_seg group

by company_id having count(*)>1)

Written by Linda P.

October 12, 2009 at 2:39 pm

Posted in SQL

Tagged with , ,

SQL Display duplicate (similar) records

leave a comment »

select(

 

* from cstd_company_seg where company_id inselect company_id from cstd_company_seg group

by company_id having count(*)>1)order

by 2

Written by Linda P.

October 12, 2009 at 2:09 pm

Posted in SQL

Tagged with ,

SQL – Merge data from 2 tables

leave a comment »

SELECT
    company,
    account,
    year,
    month,
    sum(actual) as actual,
    sum(budget) as budget
FROM
(
    SELECT
      company, account, year, month, amount as actual, 0 as budget
    FROM
      Actuals
    UNION ALL
    SELECT
      company, account, year, month, 0 as actual, amount as budget
    FROM
      Budgets
) x
GROUP BY
    company, account, year, month

Written by Linda P.

September 4, 2009 at 3:47 pm

Posted in SQL

SQL Strip time off of timedate field

leave a comment »

The following will return the timedate field with the time set back to 00:00 

SELECT DATEADD(DAY,DATEDIFF(DAY,0,[DateTime]),0)

Written by Linda P.

September 1, 2009 at 1:38 pm

Posted in SQL

SQL Display all foreign keys

leave a comment »

Use this system stored procedure to find all foreign keys linked to a table

EXEC sp_fkeys Products

Written by Linda P.

August 31, 2009 at 8:13 am

Posted in SQL

Tagged with ,

Microsoft Reporting services RTF data

leave a comment »

One of the most irritating shortcomings of Microsoft Reporting services 2005 is the inability to display RTF fields.

I found a solution here.  http://blogs.msdn.com/bimusings/archive/2005/12/14/503648.aspx

To get around this you’ll need to strip out all of the formatting.

Create a function and add it to the Report Properties –> Code

Function RtfToText(ByVal value As String) As String

       If value.Contains(“rtf1″) Then

           Return System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.Regex.Replace(value,”[\n\r\f]“, “”), “({\\)(.+?)(})|(\\)(.+?)(\b)”, “”), “{“, “”), “}”, “”).Trim()

       End If

       Return value

   End Function

This method is then called by the text box as below:

=Code.RtfToText(Fields!PrintName.Value)

Written by Linda P.

August 28, 2009 at 2:56 pm

Crystal reports – Format date in formula

leave a comment »

Try creating a formula using:

 DateValue({datefieldname}).
 
This will just return the date from the datetime field.
 

Written by Linda P.

August 25, 2009 at 9:23 am

SQL – find records by field length >x

leave a comment »

SELECT *
  FROM tablename
WHERE len(fieldname) > 20

Written by Linda P.

July 30, 2009 at 2:02 pm

Posted in SQL

Tagged with ,

Report Builder – users unable to save reports

leave a comment »

I ran into a problem that admins could save reports, but limited users could not.  It ended up that I had to give the users at least view access to the model directory.  I did verify that they could not change anything in the directory, but they had to at least be able to browse.

Written by Linda P.

July 29, 2009 at 2:06 pm