Showing posts with label numbers. Show all posts
Showing posts with label numbers. Show all posts

Tuesday, March 20, 2012

Check for missing identity numbers

Is there a way to check for missing identity numbers in a Primary Key column? I have some databases that are not fully normalized and want to check on tables that might have had some records deleted. Thank you.

Do you really want to do this in SSIS? Whilst possible I think a SQL based solution would be much faster, and probably makes more sense. A quick Google will come up with plenty of script samples e.g. http://www.nigelrivett.net/FindGapsInSequence.html|||

If you just need to know the number of 'deleted' rows; you can do a simple substraction of the max identitity number minus the number of rows in the table. If you need a list of the ID's that not exists in the table; then you could use a cursor that from 1 to max identity and checks if the row exists in the table or not....anyway you may find more help in the t-sql forum that is next door Smile

Wednesday, March 7, 2012

Check 3 occurrences of double characters.

Hi all,

I need to write some sort of statement to identify which numbers from a list fall into the following pattern:

% TwoIdenticalNumbers % TwoIdenticalNumbers % TwoIdenticalNumbers %

for example:

08812355677

I thought I would be able to use a LIKE statement but I'm not sure how to write it so that double characters are used rather than single. For example if I wanted to check three numbers appear within the string I could do the following:

SELECT *

FROM Table

WHERE Number LIKE '%[0-9]%[0-9]%[0-9]%'

I think the easiest way to check the doubles would be to represent them as a string, so I want to replace each of the [0-9] above with something like the following:

['00' OR '11' OR '22' OR '33' OR '44' OR '55' OR '66' OR '66' OR '77' OR '88' OR '99']

How could I write this using proper SQL code?

Any help would be much appreciated.

Thanks very much,

Will

Thre is no predefined expressions available,

Following approach is one of the way to achive this,

Code Snippet

Create Table #data (

[Numbers] Varchar(100)

);

Insert Into #data Values('1242432');

Insert Into #data Values('242423423');

Insert Into #data Values('2332232');

Insert Into #data Values('828289');

Insert Into #data Values('99887766');

Insert Into #data Values('92829299');

select

numbers

from #data

cross join

(

select '00' n

union all

select '11'

union all

select '22'

union all

select '33'

union all

select '44'

union all

select '55'

union all

select '66'

union all

select '77'

union all

select '88'

union all

select '99' ) as d

group by numbers having sum(case when patindex('%'+ n + '%',numbers) <> 0 Then 1 Else 0 End) >= 3

|||

:-) Looks oofy, but works

SELECT * FROM sysobjects

WHERE

REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(20),ID),'00','X'),'11','X'),'22','X'),'33','X'),'44','X') ,'55','X'),'66','X'),'77','X'),'88','X'),'99','X') LIKE '%X%'

|||

The idea is good, but the following query might fit the asked requirement,(3 occurrence of …)

Code Snippet

SELECT Id FROM sysobjects

WHERE

REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(20),ID),'00','X'),'11','X'),'22','X'),'33','X'),'44','X') ,'55','X'),'66','X'),'77','X'),'88','X'),'99','X') LIKE '%X%X%X%'

|||

Very close. At least three instances are needed.

'11' -- does not qualify

'1122' -- does not qualify

'112233' -- bingo

...

SELECT

*

FROM

(select '11' as ID) as t

WHERE

REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(20),ID),'00','X'),'11','X'),'22','X'),'33','X'),'44','X') ,'55','X'),'66','X'),'77','X'),'88','X'),'99','X') LIKE '%X%'

AMB

|||

Talking about ugly. Try:

-- thanks to Manni for the sample data

select

numbers

from

#Data

where

(len(numbers) - len(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(numbers, '00', ''), '11', ''), '22', ''), '33', ''), '44', ''), '55', ''), '66', ''), '77', ''), '88', ''), '99', ''))) / 2 >= 3

AMB

|||Thanks for all the help, this has saved me a lot of time trying to figure this one out.

Friday, February 24, 2012

Chart Question

I have numbers along the side of my chart in MB's.
The numbers a large so i want to format the number with ","
ie
I currently have 200000. I want to see 200,000 along the side fo the chart.
along the y axis.
ThanksIn the format button on the x or y axis tab, enter #,00.
Hope this helps
"Fab" wrote:
> I have numbers along the side of my chart in MB's.
> The numbers a large so i want to format the number with ","
> ie
> I currently have 200000. I want to see 200,000 along the side fo the chart.
> along the y axis.
> Thanks
>
>|||Sure did! Thanks!!
Fab.
"Ramani" <Ramani@.discussions.microsoft.com> wrote in message
news:270AC95B-08CE-45DF-B7B2-471CAA4620D1@.microsoft.com...
> In the format button on the x or y axis tab, enter #,00.
> Hope this helps
> "Fab" wrote:
>> I have numbers along the side of my chart in MB's.
>> The numbers a large so i want to format the number with ","
>> ie
>> I currently have 200000. I want to see 200,000 along the side fo the
>> chart.
>> along the y axis.
>> Thanks
>>
>>|||What format button?
--
Thanks,
CGW
"Ramani" wrote:
> In the format button on the x or y axis tab, enter #,00.
> Hope this helps
> "Fab" wrote:
> > I have numbers along the side of my chart in MB's.
> >
> > The numbers a large so i want to format the number with ","
> >
> > ie
> >
> > I currently have 200000. I want to see 200,000 along the side fo the chart.
> > along the y axis.
> >
> > Thanks
> >
> >
> >
> >

chart question

I want to be able show the numbers on chart incrementally. For example,
where if i have the values as 2, 5, 8 on chart, I would like to show as 2,
7, and 15 .. and so onâ?¦ can you help me with this please?
This is my formula for the chart â?¦
=Sum(Fields!NumberOfCrs.Value)
Thank youDid you try runningValue function?
like
=runningValue(Fields!NumberOfCrs.Value,sum,"chart1_SeriesGroup1")

Chart in crystal

I want to put an asterik next to the numbers on the Group axes (i.e. the numbers on the X axis of the chart) or on the data values of the chart.
Any clues?Cant you use text object for this?|||Can't use text box since it is a dynamic chart and the positions of the data values and group axis values change at runtime.|||Couldn't you write a formula and use that in place of your datafield?

Something like

"*" + " " + {table.field} and then place that in your chart?

Don't quote me that this will work, but I like to take a stab at things to see if I can make them work.

Sunday, February 19, 2012

Chart Gridline Question

Is there a way to make Y axis gridlines intervals change dynamically?
Basically increase/decrease base on numbers being graph.Not in rs2k don't know about rs2k5. I got round this by overlaying graphs
and hiding the ones i didn't want to see depending on how much data i got
out.
Greg
"Johnny C" <JohnnyC@.discussions.microsoft.com> wrote in message
news:DD600FE2-F167-4B8E-8126-693E57B31D0B@.microsoft.com...
> Is there a way to make Y axis gridlines intervals change dynamically?
> Basically increase/decrease base on numbers being graph.

Chart Axis

I have created a bar chart with percentages as the variables. The numbers on
the chart are correct, but the scale is incorrect. The scale adjusts to 100%
for all fields.
Anyone else encountered this problem?
--
TDWhen using percentages (e.g. format code P on the Y-axis), you can either
auto-scale the axis or you can specify an explicit min/max value. If you
specify an explicit max value (e.g. 120%), you have to specify it as 1.2
rather than 120
For percentages, 1 means 100%.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"TDahlin" <TDahlin@.discussions.microsoft.com> wrote in message
news:D87A2D0A-D607-4483-A3B4-484A07B2C5AC@.microsoft.com...
>I have created a bar chart with percentages as the variables. The numbers
>on
> the chart are correct, but the scale is incorrect. The scale adjusts to
> 100%
> for all fields.
> Anyone else encountered this problem?
> --
> TD

Thursday, February 16, 2012

Chart - negative values

Hi,

I′m working with chart type bar (Simple Bar) and i received four values from stored procedure, all values are negative numbers. The Reporting Service shows the values in the chart, but, doesn't show the "bars".... If one of four values will be positive, the report shows the values and the "bars" but if all values will be negative, the report shows just de values.

What do I do for the bars appear with four negative values ?

Thanks.

Hello,

I am having the same problem, let me know if you get any answer.

Thanks

|||

Open the chart properties dialog, go to the y-axis tab and set the "Cross At" value to 0. You should then see bars from 0 to the negative value.

-- Robert