Showing posts with label number. Show all posts
Showing posts with label number. Show all posts

Friday, March 30, 2012

layout problem

hi all,

i got a table which shows me the number of transfers of a store on everyday day together with the summed amount the store gained. my table looks like this:

store day transfers amount

1 1 1 2.50

1 2 5 3.50

2 1 2 1

and i want to put it in a report like this

store monday tuesday

1 1 / 2.50 5 / 3.50

2 2 / 1

i tried with a matrix but the the result wasnt satisifiying. the best one looked like this:

store monday tuesday

1 1 / 2.50

1 5 / 3.50

2 2 / 1

anyone can give a solution or atleast some hints?

drop store to the row group and day to the column group should satisfy your need.

Wednesday, March 28, 2012

latest order date

Hi,
I have an order table which contains the following fielde: 1). orderid (this
is the order number 2). clientid 3). orderdate.
I need to script so that I can find out those clientids which do not have
place an order for at least 90 days.
Can you tell me how to program it?Read the documentation. You want to select clientids which are NOT IN a
subquery that selects all clients that have ordered in the last 90 days. You
could also use a join where max order date is less than 90 days ago.
RR
"qjlee" <qjlee@.discussions.microsoft.com> wrote in message
news:B84E46A2-9291-4D17-A625-3DBADD9746B1@.microsoft.com...
> Hi,
> I have an order table which contains the following fielde: 1). orderid
(this
> is the order number 2). clientid 3). orderdate.
> I need to script so that I can find out those clientids which do not have
> place an order for at least 90 days.
> Can you tell me how to program it?
>
>|||Something like this should give you the client and their last order date.
declare @.DaysSinceOrder as numeric
set @.DaysSinceOrder = 90
select
clientid ,
max(orderdate)
from "YourTableHere"
group by clientid
having max(orderdate) < getdate()-@.DaysSinceOrder
"qjlee" wrote:

> Hi,
> I have an order table which contains the following fielde: 1). orderid (th
is
> is the order number 2). clientid 3). orderdate.
> I need to script so that I can find out those clientids which do not have
> place an order for at least 90 days.
> Can you tell me how to program it?
>
>|||Please post DDL, sample data and expected results
(http://www.aspfaq.com/etiquette.asp?id=5006 )
Since you have a ClientID column in your Orders table, I am guessing that
you have a Clients table somewhere. Here is a complete guess:
SELECT ClientID, ClientName
FROM Clients
WHERE ClientID NOT IN (SELECT ClientID FROM Orders WHERE DATEDIFF(d,
OrderDate, CURRENT_TIMESTAMP) <= 90)
"qjlee" <qjlee@.discussions.microsoft.com> wrote in message
news:B84E46A2-9291-4D17-A625-3DBADD9746B1@.microsoft.com...
> Hi,
> I have an order table which contains the following fielde: 1). orderid
> (this
> is the order number 2). clientid 3). orderdate.
> I need to script so that I can find out those clientids which do not have
> place an order for at least 90 days.
> Can you tell me how to program it?
>
>

latest build number for Yukon

does anyone know what is the latest build number of yukon?
thanx..
Bhavtosh
Hi
April 2005 CTP, IDW14, v9.00.1116.08
Regards
Mike
"Bhavtosh" wrote:

> does anyone know what is the latest build number of yukon?
> --
> thanx..
> Bhavtosh
|||mike, thanx for prompt reply. just one more question:
"do u have any idea of the build versions of whidbey and yukon where
framework will going to be compatible?"
thanx
bhavtosh
"Mike Epprecht (SQL MVP)" wrote:
[vbcol=seagreen]
> Hi
> April 2005 CTP, IDW14, v9.00.1116.08
> Regards
> Mike
> "Bhavtosh" wrote:
|||Beta 2 of Whidbey with April CTP of SQL Server are compatible and are the
only comination supported. They have identical build numbers for the .NET CLR.
Regards
Mike
"Bhavtosh" wrote:
[vbcol=seagreen]
> mike, thanx for prompt reply. just one more question:
> "do u have any idea of the build versions of whidbey and yukon where
> framework will going to be compatible?"
> thanx
> bhavtosh
> "Mike Epprecht (SQL MVP)" wrote:
|||can u pls share the whidbey build version which is compatible with latest SQL
CTP IDW?
thanx
bhavtosh
"Mike Epprecht (SQL MVP)" wrote:
[vbcol=seagreen]
> Beta 2 of Whidbey with April CTP of SQL Server are compatible and are the
> only comination supported. They have identical build numbers for the .NET CLR.
> Regards
> Mike
> "Bhavtosh" wrote:
|||Hi
Beta 2 of Whidbey, as in the build that was released last Friday, and SQL
Server April CTP, that was released Monday.
http://weblogs.asp.net/denisb/archiv...18/402509.aspx
Please keep the Beta posts to the Beta newsgroups:
Regards
Mike
"Bhavtosh" wrote:
[vbcol=seagreen]
> can u pls share the whidbey build version which is compatible with latest SQL
> CTP IDW?
> thanx
> bhavtosh
> "Mike Epprecht (SQL MVP)" wrote:

latest build number for Yukon

does anyone know what is the latest build number of yukon?
thanx..
BhavtoshHi
April 2005 CTP, IDW14, v9.00.1116.08
Regards
Mike
"Bhavtosh" wrote:

> does anyone know what is the latest build number of yukon?
> --
> thanx..
> Bhavtosh|||mike, thanx for prompt reply. just one more question:
"do u have any idea of the build versions of whidbey and yukon where
framework will going to be compatible?"
thanx
bhavtosh
"Mike Epprecht (SQL MVP)" wrote:
[vbcol=seagreen]
> Hi
> April 2005 CTP, IDW14, v9.00.1116.08
> Regards
> Mike
> "Bhavtosh" wrote:
>|||Beta 2 of Whidbey with April CTP of SQL Server are compatible and are the
only comination supported. They have identical build numbers for the .NET CL
R.
Regards
Mike
"Bhavtosh" wrote:
[vbcol=seagreen]
> mike, thanx for prompt reply. just one more question:
> "do u have any idea of the build versions of whidbey and yukon where
> framework will going to be compatible?"
> thanx
> bhavtosh
> "Mike Epprecht (SQL MVP)" wrote:
>|||can u pls share the whidbey build version which is compatible with latest SQ
L
CTP IDW?
thanx
bhavtosh
"Mike Epprecht (SQL MVP)" wrote:
[vbcol=seagreen]
> Beta 2 of Whidbey with April CTP of SQL Server are compatible and are the
> only comination supported. They have identical build numbers for the .NET
CLR.
> Regards
> Mike
> "Bhavtosh" wrote:
>|||Hi
Beta 2 of Whidbey, as in the build that was released last Friday, and SQL
Server April CTP, that was released Monday.
http://weblogs.asp.net/denisb/archi.../18/402509.aspx
Please keep the Beta posts to the Beta newsgroups:
Regards
Mike
"Bhavtosh" wrote:
[vbcol=seagreen]
> can u pls share the whidbey build version which is compatible with latest
SQL
> CTP IDW?
> thanx
> bhavtosh
> "Mike Epprecht (SQL MVP)" wrote:
>

latest build number for Yukon

does anyone know what is the latest build number of yukon?
--
thanx..
BhavtoshHi
April 2005 CTP, IDW14, v9.00.1116.08
Regards
Mike
"Bhavtosh" wrote:
> does anyone know what is the latest build number of yukon?
> --
> thanx..
> Bhavtosh|||mike, thanx for prompt reply. just one more question:
"do u have any idea of the build versions of whidbey and yukon where
framework will going to be compatible?"
thanx
bhavtosh
"Mike Epprecht (SQL MVP)" wrote:
> Hi
> April 2005 CTP, IDW14, v9.00.1116.08
> Regards
> Mike
> "Bhavtosh" wrote:
> > does anyone know what is the latest build number of yukon?
> >
> > --
> > thanx..
> > Bhavtosh|||Beta 2 of Whidbey with April CTP of SQL Server are compatible and are the
only comination supported. They have identical build numbers for the .NET CLR.
Regards
Mike
"Bhavtosh" wrote:
> mike, thanx for prompt reply. just one more question:
> "do u have any idea of the build versions of whidbey and yukon where
> framework will going to be compatible?"
> thanx
> bhavtosh
> "Mike Epprecht (SQL MVP)" wrote:
> > Hi
> >
> > April 2005 CTP, IDW14, v9.00.1116.08
> >
> > Regards
> > Mike
> >
> > "Bhavtosh" wrote:
> >
> > > does anyone know what is the latest build number of yukon?
> > >
> > > --
> > > thanx..
> > > Bhavtosh|||can u pls share the whidbey build version which is compatible with latest SQL
CTP IDW?
thanx
bhavtosh
"Mike Epprecht (SQL MVP)" wrote:
> Beta 2 of Whidbey with April CTP of SQL Server are compatible and are the
> only comination supported. They have identical build numbers for the .NET CLR.
> Regards
> Mike
> "Bhavtosh" wrote:
> > mike, thanx for prompt reply. just one more question:
> > "do u have any idea of the build versions of whidbey and yukon where
> > framework will going to be compatible?"
> >
> > thanx
> > bhavtosh
> >
> > "Mike Epprecht (SQL MVP)" wrote:
> >
> > > Hi
> > >
> > > April 2005 CTP, IDW14, v9.00.1116.08
> > >
> > > Regards
> > > Mike
> > >
> > > "Bhavtosh" wrote:
> > >
> > > > does anyone know what is the latest build number of yukon?
> > > >
> > > > --
> > > > thanx..
> > > > Bhavtosh|||Hi
Beta 2 of Whidbey, as in the build that was released last Friday, and SQL
Server April CTP, that was released Monday.
http://weblogs.asp.net/denisb/archive/2005/04/18/402509.aspx
Please keep the Beta posts to the Beta newsgroups:
Regards
Mike
"Bhavtosh" wrote:
> can u pls share the whidbey build version which is compatible with latest SQL
> CTP IDW?
> thanx
> bhavtosh
> "Mike Epprecht (SQL MVP)" wrote:
> > Beta 2 of Whidbey with April CTP of SQL Server are compatible and are the
> > only comination supported. They have identical build numbers for the .NET CLR.
> >
> > Regards
> > Mike
> >
> > "Bhavtosh" wrote:
> >
> > > mike, thanx for prompt reply. just one more question:
> > > "do u have any idea of the build versions of whidbey and yukon where
> > > framework will going to be compatible?"
> > >
> > > thanx
> > > bhavtosh
> > >
> > > "Mike Epprecht (SQL MVP)" wrote:
> > >
> > > > Hi
> > > >
> > > > April 2005 CTP, IDW14, v9.00.1116.08
> > > >
> > > > Regards
> > > > Mike
> > > >
> > > > "Bhavtosh" wrote:
> > > >
> > > > > does anyone know what is the latest build number of yukon?
> > > > >
> > > > > --
> > > > > thanx..
> > > > > Bhavtosh

Monday, March 26, 2012

Latest and next-to-latest query?

I use a number of queries where I get the "latest" price/quantity/whatever. I
rely on the id's being in order (they are for us) and do this...
SELECT p.name, p.price
FROM tblPrices p
WHERE p.PriceID IN
(SELECT MAX(priceid) FROM tblprices GROUP BY
name)
Now I need to change this slightly, in addition to the latest price, I need
to get the "next-to-latest". My first attempt...
SELECT p1.name, p1.Price1 AS latestPrice, p2.Price1 AS olderPrice,
p1.Price1 - p2.Price1 AS diff
FROM tblPrices p1, tblPrices p2
WHERE p1.PriceID IN
(SELECT MAX(priceid)
FROM tblprices
GROUP BY accountid) AND (p2.PriceID IN
(SELECT MAX(priceid)
FROM tblprices
WHERE priceid NOT IN
(SELECT
MAX(priceid)
FROM
tblprices
GROUP BY accountid)
GROUP BY accountid))
This works, and I can live with that, but its very slow. Can anyone suggest
another way to go about this?
Maury
Hi
I meant PK--Primary Key
SELECT p.name, p.price
FROM tblPrices p
WHERE p.PriceID =(SELECT MAX(priceid) FROM tblprices
tp WHERE tp.PK=p.PK)
--OR
SELECT p.name, p.price
FROM tblPrices p
join
(SELECT MAX(priceid),name FROM tblprices GROUP BY name) AS D
ON d.PK=p.pk
"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:14FBC159-36EA-4460-8CBE-BE7C9035AFF0@.microsoft.com...
>I use a number of queries where I get the "latest" price/quantity/whatever.
>I
> rely on the id's being in order (they are for us) and do this...
> SELECT p.name, p.price
> FROM tblPrices p
> WHERE p.PriceID IN
> (SELECT MAX(priceid) FROM tblprices GROUP BY
> name)
> Now I need to change this slightly, in addition to the latest price, I
> need
> to get the "next-to-latest". My first attempt...
> SELECT p1.name, p1.Price1 AS latestPrice, p2.Price1 AS olderPrice,
> p1.Price1 - p2.Price1 AS diff
> FROM tblPrices p1, tblPrices p2
> WHERE p1.PriceID IN
> (SELECT MAX(priceid)
> FROM tblprices
> GROUP BY accountid) AND (p2.PriceID IN
> (SELECT MAX(priceid)
> FROM tblprices
> WHERE priceid NOT IN
> (SELECT
> MAX(priceid)
> FROM
> tblprices
> GROUP BY
> accountid)
> GROUP BY accountid))
> This works, and I can live with that, but its very slow. Can anyone
> suggest
> another way to go about this?
> Maury

Latest and next-to-latest query?

I use a number of queries where I get the "latest" price/quantity/whatever. I
rely on the id's being in order (they are for us) and do this...
SELECT p.name, p.price
FROM tblPrices p
WHERE p.PriceID IN
(SELECT MAX(priceid) FROM tblprices GROUP BY
name)
Now I need to change this slightly, in addition to the latest price, I need
to get the "next-to-latest". My first attempt...
SELECT p1.name, p1.Price1 AS latestPrice, p2.Price1 AS olderPrice,
p1.Price1 - p2.Price1 AS diff
FROM tblPrices p1, tblPrices p2
WHERE p1.PriceID IN
(SELECT MAX(priceid)
FROM tblprices
GROUP BY accountid) AND (p2.PriceID IN
(SELECT MAX(priceid)
FROM tblprices
WHERE priceid NOT IN
(SELECT
MAX(priceid)
FROM
tblprices
GROUP BY accountid)
GROUP BY accountid))
This works, and I can live with that, but its very slow. Can anyone suggest
another way to go about this?
MauryHi
I meant PK--Primary Key
SELECT p.name, p.price
FROM tblPrices p
WHERE p.PriceID =(SELECT MAX(priceid) FROM tblprices
tp WHERE tp.PK=p.PK)
--OR
SELECT p.name, p.price
FROM tblPrices p
join
(SELECT MAX(priceid),name FROM tblprices GROUP BY name) AS D
ON d.PK=p.pk
"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:14FBC159-36EA-4460-8CBE-BE7C9035AFF0@.microsoft.com...
>I use a number of queries where I get the "latest" price/quantity/whatever.
>I
> rely on the id's being in order (they are for us) and do this...
> SELECT p.name, p.price
> FROM tblPrices p
> WHERE p.PriceID IN
> (SELECT MAX(priceid) FROM tblprices GROUP BY
> name)
> Now I need to change this slightly, in addition to the latest price, I
> need
> to get the "next-to-latest". My first attempt...
> SELECT p1.name, p1.Price1 AS latestPrice, p2.Price1 AS olderPrice,
> p1.Price1 - p2.Price1 AS diff
> FROM tblPrices p1, tblPrices p2
> WHERE p1.PriceID IN
> (SELECT MAX(priceid)
> FROM tblprices
> GROUP BY accountid) AND (p2.PriceID IN
> (SELECT MAX(priceid)
> FROM tblprices
> WHERE priceid NOT IN
> (SELECT
> MAX(priceid)
> FROM
> tblprices
> GROUP BY
> accountid)
> GROUP BY accountid))
> This works, and I can live with that, but its very slow. Can anyone
> suggest
> another way to go about this?
> Maurysql

Latest and next-to-latest query?

I use a number of queries where I get the "latest" price/quantity/whatever.
I
rely on the id's being in order (they are for us) and do this...
SELECT p.name, p.price
FROM tblPrices p
WHERE p.PriceID IN
(SELECT MAX(priceid) FROM tblprices GROUP BY
name)
Now I need to change this slightly, in addition to the latest price, I need
to get the "next-to-latest". My first attempt...
SELECT p1.name, p1.Price1 AS latestPrice, p2.Price1 AS olderPrice,
p1.Price1 - p2.Price1 AS diff
FROM tblPrices p1, tblPrices p2
WHERE p1.PriceID IN
(SELECT MAX(priceid)
FROM tblprices
GROUP BY accountid) AND (p2.PriceID IN
(SELECT MAX(priceid)
FROM tblprices
WHERE priceid NOT IN
(SELECT
MAX(priceid)
FROM
tblprices
GROUP BY accountid)
GROUP BY accountid))
This works, and I can live with that, but its very slow. Can anyone suggest
another way to go about this?
MauryHi
I meant PK--Primary Key
SELECT p.name, p.price
FROM tblPrices p
WHERE p.PriceID =(SELECT MAX(priceid) FROM tblprices
tp WHERE tp.PK=p.PK)
--OR
SELECT p.name, p.price
FROM tblPrices p
join
(SELECT MAX(priceid),name FROM tblprices GROUP BY name) AS D
ON d.PK=p.pk
"Maury Markowitz" <MauryMarkowitz@.discussions.microsoft.com> wrote in
message news:14FBC159-36EA-4460-8CBE-BE7C9035AFF0@.microsoft.com...
>I use a number of queries where I get the "latest" price/quantity/whatever.
>I
> rely on the id's being in order (they are for us) and do this...
> SELECT p.name, p.price
> FROM tblPrices p
> WHERE p.PriceID IN
> (SELECT MAX(priceid) FROM tblprices GROUP BY
> name)
> Now I need to change this slightly, in addition to the latest price, I
> need
> to get the "next-to-latest". My first attempt...
> SELECT p1.name, p1.Price1 AS latestPrice, p2.Price1 AS olderPrice,
> p1.Price1 - p2.Price1 AS diff
> FROM tblPrices p1, tblPrices p2
> WHERE p1.PriceID IN
> (SELECT MAX(priceid)
> FROM tblprices
> GROUP BY accountid) AND (p2.PriceID IN
> (SELECT MAX(priceid)
> FROM tblprices
> WHERE priceid NOT IN
> (SELECT
> MAX(priceid)
> FROM
> tblprices
> GROUP BY
> accountid)
> GROUP BY accountid))
> This works, and I can live with that, but its very slow. Can anyone
> suggest
> another way to go about this?
> Maury

Friday, March 23, 2012

last tsql command

hi, how can i obtain the info of the last tsql command executed?, in the table sysprocess i only have the number of spid
thanks so much...have you tried double-clicking the spid in Enterprise Manager->Management->Current Activity->Process Info?

...might give you what you're looking for...|||hi, yes, but sql save it in someplace? i need to extract it to a table|||Not that I'm aware of, you'd have to run profiler to capture the sql (even then I am not sure you can save it to a table...)|||(even then I am not sure you can save it to a table...)Yes you can though MS recommend you write to a trace file and insert this into a table when you want to analyse. More efficient to write to a file at trace time basically.

HTH|||@.Mvrg76: Why have you opened a new thread?
See http://www.dbforums.com/showthread.php?t=1613810sql

Wednesday, March 21, 2012

Last report item or RowNumber for details grouping

I have a report with details grouping on table. What i need to do is put row number only on Parent row and skip the child row. When i use RowNumber("GroupName") of course it gives me a current RowNumber. Is there a way to count only parents?

This post may help.

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

cheers,

Andrew

|||

Hello,

Try putting this in the same row as your parent group row:

=RunningValue(Fields!GroupFieldName.Value, CountDistinct, nothing)

Jarret

Monday, March 19, 2012

Last Modified Date

I have a number of tables in a database that have 0 records. Some tables are
purged frequently. I am trying to determine which tables are truly in use
versus those tables that are not being used at all. Where or how might I
obtain the last date/time a table was modifed?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200510/1Robert,
You would need to have had Profiler or some third-party auditing tool
running to determine this. Another option would be to use some extra
auditing code in the tables or use triggers. C2 is probably overkill for
something like this.
Read these:
http://www.microsoft.com/technet/security/prodtech/sqlserver/sql2kaud.mspx
and
http://www.akadia.com/services/sqlsrv_table_auditing.html
HTH
Jerry
"Robert R via SQLMonster.com" <u3288@.uwe> wrote in message
news:55d4d8776aa3c@.uwe...
>I have a number of tables in a database that have 0 records. Some tables
>are
> purged frequently. I am trying to determine which tables are truly in use
> versus those tables that are not being used at all. Where or how might I
> obtain the last date/time a table was modifed?
>
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200510/1

Last Modified Date

I have a number of tables in a database that have 0 records. Some tables are
purged frequently. I am trying to determine which tables are truly in use
versus those tables that are not being used at all. Where or how might I
obtain the last date/time a table was modifed?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200510/1Robert,
You would need to have had Profiler or some third-party auditing tool
running to determine this. Another option would be to use some extra
auditing code in the tables or use triggers. C2 is probably overkill for
something like this.
Read these:
http://www.microsoft.com/technet/se...r/sql2kaud.mspx
and
http://www.akadia.com/services/sqls...e_auditing.html
HTH
Jerry
"Robert R via droptable.com" <u3288@.uwe> wrote in message
news:55d4d8776aa3c@.uwe...
>I have a number of tables in a database that have 0 records. Some tables
>are
> purged frequently. I am trying to determine which tables are truly in use
> versus those tables that are not being used at all. Where or how might I
> obtain the last date/time a table was modifed?
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200510/1

Last Modified Date

I have a number of tables in a database that have 0 records. Some tables are
purged frequently. I am trying to determine which tables are truly in use
versus those tables that are not being used at all. Where or how might I
obtain the last date/time a table was modifed?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...erver/200510/1
Robert,
You would need to have had Profiler or some third-party auditing tool
running to determine this. Another option would be to use some extra
auditing code in the tables or use triggers. C2 is probably overkill for
something like this.
Read these:
http://www.microsoft.com/technet/sec.../sql2kaud.mspx
and
http://www.akadia.com/services/sqlsr..._auditing.html
HTH
Jerry
"Robert R via droptable.com" <u3288@.uwe> wrote in message
news:55d4d8776aa3c@.uwe...
>I have a number of tables in a database that have 0 records. Some tables
>are
> purged frequently. I am trying to determine which tables are truly in use
> versus those tables that are not being used at all. Where or how might I
> obtain the last date/time a table was modifed?
>
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forums...erver/200510/1

Monday, March 12, 2012

Last Day of Month Schedule

Hi,
Can anyone tell me how i can create a schedule for the last calendar day of
the month.
Surely I dont have to create a number of different schedules.
ThankyouHi tango:
you can try to set up at the first day of each month, like 2 am .
"Tango" wrote:
> Hi,
> Can anyone tell me how i can create a schedule for the last calendar day of
> the month.
> Surely I dont have to create a number of different schedules.
> Thankyou|||thanks nick
i ended up doing that & modifying my report to look at the previous months
data
"Nick" wrote:
> Hi tango:
> you can try to set up at the first day of each month, like 2 am .
>
> "Tango" wrote:
> > Hi,
> > Can anyone tell me how i can create a schedule for the last calendar day of
> > the month.
> >
> > Surely I dont have to create a number of different schedules.
> >
> > Thankyou

Last 90 Days For a Variable

I triyng to generate a table with the last 90 days for a Part number, I have
a table with data for the last 7 years, and I need to complie the last 90
days of data for all the parts, but if I use the date as a criteria it will
only give the last 90 days, so I need to generate a query that will give all
the parts with only the last 90 days of data for all parts.
If you have any idea or suggestion are more than welcome
Thanks
Can you post DDL (CREATE TABLE statements), some sample data (INSERT
statements), and some sample output?
I'm confused by why using the date to get the last 90 days will not give you
all of the data for all of the parts over the last 90 days.
"sanvaces" <sanvaces@.discussions.microsoft.com> wrote in message
news:3EDCA8EF-D432-47BD-9EE1-CABE20168D20@.microsoft.com...
> I triyng to generate a table with the last 90 days for a Part number, I
have
> a table with data for the last 7 years, and I need to complie the last 90
> days of data for all the parts, but if I use the date as a criteria it
will
> only give the last 90 days, so I need to generate a query that will give
all
> the parts with only the last 90 days of data for all parts.
> If you have any idea or suggestion are more than welcome
> Thanks
|||SELECT <columns> FROM <table>
WHERE <datetime_column> >= GETDATE()-90
If you want 90 days from midnight this AM:
SELECT <columns> FROM <table>
WHERE <datetime_column> >= DATEADD(DAY, -90, CONVERT(CHAR(8), GETDATE(),
112))
If you want 90 days from midnight tomorrow AM:
SELECT <columns> FROM <table>
WHERE <datetime_column> >= DATEADD(DAY, -90, CONVERT(CHAR(8),
GETDATE()+1, 112))
http://www.aspfaq.com/
(Reverse address to reply.)
"sanvaces" <sanvaces@.discussions.microsoft.com> wrote in message
news:3EDCA8EF-D432-47BD-9EE1-CABE20168D20@.microsoft.com...
> I triyng to generate a table with the last 90 days for a Part number, I
have
> a table with data for the last 7 years, and I need to complie the last 90
> days of data for all the parts, but if I use the date as a criteria it
will
> only give the last 90 days, so I need to generate a query that will give
all
> the parts with only the last 90 days of data for all parts.
> If you have any idea or suggestion are more than welcome
> Thanks
|||Aaron,
Some parts did not ran for the last 90 days, so I need to create a query
that will search the last 90 days for any part, here is an example assuming
the following results
Part Start Date End Date
ABC 1/4/04 7/3/04
CDB 11/1/03 5/4/04
DCB 5/4/04 8/8/04
So as you could see some parts ran in a differnts period of time and I need
to collect information for the latest 90 days for all parts regarding of the
date they ran.
Thanks
"Aaron [SQL Server MVP]" wrote:

> SELECT <columns> FROM <table>
> WHERE <datetime_column> >= GETDATE()-90
> If you want 90 days from midnight this AM:
> SELECT <columns> FROM <table>
> WHERE <datetime_column> >= DATEADD(DAY, -90, CONVERT(CHAR(8), GETDATE(),
> 112))
> If you want 90 days from midnight tomorrow AM:
> SELECT <columns> FROM <table>
> WHERE <datetime_column> >= DATEADD(DAY, -90, CONVERT(CHAR(8),
> GETDATE()+1, 112))
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "sanvaces" <sanvaces@.discussions.microsoft.com> wrote in message
> news:3EDCA8EF-D432-47BD-9EE1-CABE20168D20@.microsoft.com...
> have
> will
> all
>
>
|||Adam,
If I request the last 90 days, it'll only give those parts that ran in that
time interval, and I need the last 90 days for all the parts, regarding the
dates that they ran.
Thaks
"Adam Machanic" wrote:

> Can you post DDL (CREATE TABLE statements), some sample data (INSERT
> statements), and some sample output?
> I'm confused by why using the date to get the last 90 days will not give you
> all of the data for all of the parts over the last 90 days.
>
> "sanvaces" <sanvaces@.discussions.microsoft.com> wrote in message
> news:3EDCA8EF-D432-47BD-9EE1-CABE20168D20@.microsoft.com...
> have
> will
> all
>
>
|||Can you tell us which of these rows satisfy your requirements? Can you
please let us know if those dates are m/d/y or d/m/y?
Please see http://www.aspfaq.com/5006 for information on giving us usable
specifications to help solve your issue...
http://www.aspfaq.com/
(Reverse address to reply.)
"sanvaces" <sanvaces@.discussions.microsoft.com> wrote in message
news:7D125639-DDFA-4836-A755-BC35E7969B78@.microsoft.com...
> Aaron,
> Some parts did not ran for the last 90 days, so I need to create a query
> that will search the last 90 days for any part, here is an example
assuming
> the following results
> Part Start Date End Date
> ABC 1/4/04 7/3/04
> CDB 11/1/03 5/4/04
> DCB 5/4/04 8/8/04
> So as you could see some parts ran in a differnts period of time and I
need
> to collect information for the latest 90 days for all parts regarding of
the[vbcol=seagreen]
> date they ran.
> Thanks
> "Aaron [SQL Server MVP]" wrote:
GETDATE(),[vbcol=seagreen]
I[vbcol=seagreen]
90[vbcol=seagreen]
give[vbcol=seagreen]
|||Your narrative does not make sense. Please supply real requirements with
CREATE TABLE statements, sample data in the form of INSERT statements, and
desired output.
See http://www.aspfaq.com/5006
http://www.aspfaq.com/
(Reverse address to reply.)
"sanvaces" <sanvaces@.discussions.microsoft.com> wrote in message
news:B1666113-0BA6-4893-9C1F-A7ED897FA7A1@.microsoft.com...
> Adam,
> If I request the last 90 days, it'll only give those parts that ran in
that
> time interval, and I need the last 90 days for all the parts, regarding
the[vbcol=seagreen]
> dates that they ran.
> Thaks
> "Adam Machanic" wrote:
you[vbcol=seagreen]
I[vbcol=seagreen]
90[vbcol=seagreen]
give[vbcol=seagreen]
|||Aaron,
Here is
Insert <Table Name>
Select actcycle,actcav,actqty,actlab,slot,part,hrsran,hrs ava,hrsava-hrsran
as downtime
From Tbl_History
Where Pdate >= getdate()-90
by doing this I'll only get those parts that have ran in the last 90 days,
and I need the last 90 days of history for every part that we have in the
table Tbl_History. So in others words I need the last 2160 hours of ran data
for every part in the Tbl_History table and then insert this data into
different table (90*24)
"sanvaces" wrote:
[vbcol=seagreen]
> Aaron,
> Some parts did not ran for the last 90 days, so I need to create a query
> that will search the last 90 days for any part, here is an example assuming
> the following results
> Part Start Date End Date
> ABC 1/4/04 7/3/04
> CDB 11/1/03 5/4/04
> DCB 5/4/04 8/8/04
> So as you could see some parts ran in a differnts period of time and I need
> to collect information for the latest 90 days for all parts regarding of the
> date they ran.
> Thanks
> "Aaron [SQL Server MVP]" wrote:
|||More narrative doesn't help. I have no idea what "last 2160 hours of ran
data for every part" means. Please see http://www.aspfaq.com/5006 and give
us REAL REQUIREMENTS.
http://www.aspfaq.com/
(Reverse address to reply.)
"sanvaces" <sanvaces@.discussions.microsoft.com> wrote in message
news:79E6CB0F-501C-4643-B3AD-F9DA40E15190@.microsoft.com...
> Aaron,
> Here is
> Insert <Table Name>
> Select actcycle,actcav,actqty,actlab,slot,part,hrsran,hrs ava,hrsava-hrsran
> as downtime
> From Tbl_History
> Where Pdate >= getdate()-90
> by doing this I'll only get those parts that have ran in the last 90 days,
> and I need the last 90 days of history for every part that we have in the
> table Tbl_History. So in others words I need the last 2160 hours of ran
data[vbcol=seagreen]
> for every part in the Tbl_History table and then insert this data into
> different table (90*24)
> "sanvaces" wrote:
query[vbcol=seagreen]
assuming[vbcol=seagreen]
need[vbcol=seagreen]
the[vbcol=seagreen]
GETDATE(),[vbcol=seagreen]
number, I[vbcol=seagreen]
last 90[vbcol=seagreen]
it[vbcol=seagreen]
give[vbcol=seagreen]

Friday, February 24, 2012

Large selection in multiple parameters

I have a problem and was wondering if someone might have some good
suggestions. I've created a report that shows the number of loans that
have been given to students at various colleges by various vendors.
The report has parameters for vendor and for college, and I created the
parameters as multi-value drop down boxes. The source for the schools
box is a query against my data table for the distinct Schools that
appear.
The problem I'm having is this: There are approximately 4000 schools
in the table, and when the user does a Select All on the web site, the
report chugs away for a while and then returns nothing. It works fine
in Visual Studio (slowly, but it returns everything) but not on the
website. I don't get any error messages.
The WHERE clause in my main script is simply:
Where SchoolName in (@.schoolName)
My guess is that there are simply too much being shoved into the
parameter when I try to select all. Just wondering if anyone has a
reasonable way to get around this. I've managed a rather kludgy method
where I have an additional boolean parameter and then logic to bypass
the WHERE if it's true, but I'd rather just have the thing work
normally (via the drop-down) if that's possible.
The drop down for the Vendors works just fine, whether I select one,
many, or all of the vendors. But there are only 30 of those, so the
cause seems to be the number of choices. Is there a set limit to the
number of choices in a drop down, or a set size that can be passed
perhaps?
Using Reporting Services 2005.How about doing a bit of processing before the query gets run. Something
along the lines of
IIF parameter!School.Item(0) = true, select data regardless of school (no
whereclause on Schoolname) else select data with whereclause.
I'm not quite sure how to check if the Select All parameter was selected or
not, but it might be food for thought anyway.
Kaisa M. Lindahl Lervik
<cphite@.gmail.com> wrote in message
news:1162419349.183710.148290@.h48g2000cwc.googlegroups.com...
>I have a problem and was wondering if someone might have some good
> suggestions. I've created a report that shows the number of loans that
> have been given to students at various colleges by various vendors.
> The report has parameters for vendor and for college, and I created the
> parameters as multi-value drop down boxes. The source for the schools
> box is a query against my data table for the distinct Schools that
> appear.
> The problem I'm having is this: There are approximately 4000 schools
> in the table, and when the user does a Select All on the web site, the
> report chugs away for a while and then returns nothing. It works fine
> in Visual Studio (slowly, but it returns everything) but not on the
> website. I don't get any error messages.
> The WHERE clause in my main script is simply:
> Where SchoolName in (@.schoolName)
> My guess is that there are simply too much being shoved into the
> parameter when I try to select all. Just wondering if anyone has a
> reasonable way to get around this. I've managed a rather kludgy method
> where I have an additional boolean parameter and then logic to bypass
> the WHERE if it's true, but I'd rather just have the thing work
> normally (via the drop-down) if that's possible.
> The drop down for the Vendors works just fine, whether I select one,
> many, or all of the vendors. But there are only 30 of those, so the
> cause seems to be the number of choices. Is there a set limit to the
> number of choices in a drop down, or a set size that can be passed
> perhaps?
> Using Reporting Services 2005.
>|||What I have done in the case is as follows. I found this function
CREATE FUNCTION [dbo].[fn_MVParam](@.RepParam nvarchar(max), @.Delim char(1)=',')
RETURNS @.VALUES TABLE (Param nvarchar(max))AS
BEGIN
DECLARE @.chrind INT
DECLARE @.Piece nvarchar(max)
SELECT @.chrind = 1
WHILE @.chrind > 0
BEGIN
SELECT @.chrind = CHARINDEX(@.Delim,@.RepParam)
IF @.chrind > 0
SELECT @.Piece = LEFT(@.RepParam,@.chrind - 1)
ELSE
SELECT @.Piece = @.RepParam
INSERT @.VALUES(Param) VALUES(@.Piece)
SELECT @.RepParam = RIGHT(@.RepParam,LEN(@.RepParam) - @.chrind)
IF LEN(@.RepParam) = 0 BREAK
END
RETURN
END
This will break the comma separated string passed into your stored proc into
a table. Thow the results of this function into a temp table, and filter you
results with a join, instead of an in.
Ken
"Kaisa M. Lindahl Lervik" wrote:
> How about doing a bit of processing before the query gets run. Something
> along the lines of
> IIF parameter!School.Item(0) = true, select data regardless of school (no
> whereclause on Schoolname) else select data with whereclause.
> I'm not quite sure how to check if the Select All parameter was selected or
> not, but it might be food for thought anyway.
> Kaisa M. Lindahl Lervik
> <cphite@.gmail.com> wrote in message
> news:1162419349.183710.148290@.h48g2000cwc.googlegroups.com...
> >I have a problem and was wondering if someone might have some good
> > suggestions. I've created a report that shows the number of loans that
> > have been given to students at various colleges by various vendors.
> > The report has parameters for vendor and for college, and I created the
> > parameters as multi-value drop down boxes. The source for the schools
> > box is a query against my data table for the distinct Schools that
> > appear.
> >
> > The problem I'm having is this: There are approximately 4000 schools
> > in the table, and when the user does a Select All on the web site, the
> > report chugs away for a while and then returns nothing. It works fine
> > in Visual Studio (slowly, but it returns everything) but not on the
> > website. I don't get any error messages.
> >
> > The WHERE clause in my main script is simply:
> > Where SchoolName in (@.schoolName)
> >
> > My guess is that there are simply too much being shoved into the
> > parameter when I try to select all. Just wondering if anyone has a
> > reasonable way to get around this. I've managed a rather kludgy method
> > where I have an additional boolean parameter and then logic to bypass
> > the WHERE if it's true, but I'd rather just have the thing work
> > normally (via the drop-down) if that's possible.
> >
> > The drop down for the Vendors works just fine, whether I select one,
> > many, or all of the vendors. But there are only 30 of those, so the
> > cause seems to be the number of choices. Is there a set limit to the
> > number of choices in a drop down, or a set size that can be passed
> > perhaps?
> >
> > Using Reporting Services 2005.
> >
>
>|||Ken Reitmeyer wrote:
> What I have done in the case is as follows. I found this function
> CREATE FUNCTION [dbo].[fn_MVParam](@.RepParam nvarchar(max), @.Delim char(1)=> ',')
> RETURNS @.VALUES TABLE (Param nvarchar(max))AS
> BEGIN
> DECLARE @.chrind INT
> DECLARE @.Piece nvarchar(max)
> SELECT @.chrind = 1
> WHILE @.chrind > 0
> BEGIN
> SELECT @.chrind = CHARINDEX(@.Delim,@.RepParam)
> IF @.chrind > 0
> SELECT @.Piece = LEFT(@.RepParam,@.chrind - 1)
> ELSE
> SELECT @.Piece = @.RepParam
> INSERT @.VALUES(Param) VALUES(@.Piece)
> SELECT @.RepParam = RIGHT(@.RepParam,LEN(@.RepParam) - @.chrind)
> IF LEN(@.RepParam) = 0 BREAK
> END
> RETURN
> END
> This will break the comma separated string passed into your stored proc into
> a table. Thow the results of this function into a temp table, and filter you
> results with a join, instead of an in.
Ken,
When I use this function it works for one selection, but when I select
more than one school it tells me I have too many parameters.|||This is how I am using the function to pass a long parameter list
--temp table to hold parameters
declare @.tbl_WorkCenters table
(
work_center int
)
declare @.sql varchar(max)
--@.work_centers is the comma separated parameter list passed in from the
reprot
set @.sql = 'select ltrim(param) from fn_MVParam(''' + @.work_centers + ''',
'','')'
insert into @.tbl_WorkCenters
exec (@.sql)
Not sure if that answers your question or not.
"cphite@.gmail.com" wrote:
> Ken Reitmeyer wrote:
> > What I have done in the case is as follows. I found this function
> >
> > CREATE FUNCTION [dbo].[fn_MVParam](@.RepParam nvarchar(max), @.Delim char(1)=> > ',')
> > RETURNS @.VALUES TABLE (Param nvarchar(max))AS
> > BEGIN
> > DECLARE @.chrind INT
> > DECLARE @.Piece nvarchar(max)
> > SELECT @.chrind = 1
> > WHILE @.chrind > 0
> > BEGIN
> > SELECT @.chrind = CHARINDEX(@.Delim,@.RepParam)
> > IF @.chrind > 0
> > SELECT @.Piece = LEFT(@.RepParam,@.chrind - 1)
> > ELSE
> > SELECT @.Piece = @.RepParam
> > INSERT @.VALUES(Param) VALUES(@.Piece)
> > SELECT @.RepParam = RIGHT(@.RepParam,LEN(@.RepParam) - @.chrind)
> > IF LEN(@.RepParam) = 0 BREAK
> > END
> > RETURN
> > END
> >
> > This will break the comma separated string passed into your stored proc into
> > a table. Thow the results of this function into a temp table, and filter you
> > results with a join, instead of an in.
> Ken,
> When I use this function it works for one selection, but when I select
> more than one school it tells me I have too many parameters.
>

Large number of rows.

Hi all,

A select query returns around 1 million rows. The column in the WHERE condition is indexed. This query takes nearly 1 minute for returning the all the records. Is this normal ?

Does the number of records returned affect the performance inspite of the indexing ?

Thanks,

DBLearner

The index simply allows it to find the data it has to retrieve quickly. It then has to:

load that actual record data in from disk. Depending upon how the records are split across datapages this could be a lot of disk access. Then if you have any sorting or grouping/aggregating on the result it has to do this before it can start passing the results back. After that it has to transfer the data that you are retrieving across the link (shared memory if you are running on the server across the network if not). If you are retrieving say 20 bytes per record (quite small: a couple of ints, a bit of text and a real number can be this size or larger easily) then for a million records that is 20 megabytes.|||

The major 'chokepoints' will be the quality of the index vs. the WHERE clause criteria, amount of server memory, other activity, CPU power, and disk 'arrangement'. (Having the TempDb database on a dedicated array or LUN, for example.)

You might benefit from some tuning and optimization and perhaps that will increase the query responsiveness. But you definitely need to get some benchmarks in place.

Here is some information about Performance Audits, Monitoring, and Tuning:

Performance Audit
http://www.sql-server-performance.com/articles_audit.asp
http://www.sql-server-performance.com/sql_server_performance_audit10.asp

Performance -Link Server Performance Tips
http://www.sql-server-performance.com/linked_server.asp

Performance Monitoring
http://www.microsoft.com/technet/prodtechnol/sql/2005/library/operations.mspx Performance WP's
http://www.microsoft.com/technet/prodtechnol/sql/2005/tsprfprb.mspx Troubleshooting Performance 2005
http://www.swynk.com/friends/vandenberg/perfmonitor.asp Perfmon counters
http://www.sql-server-performance.com/sql_server_performance_audit.asp Hardware Performance CheckList
http://www.sql-server-performance.com/ss_performance_monitoring.asp Practical Solution for Monitoring
http://www.sql-server-performance.com/best_sql_server_performance_tips.asp SQL 2000 Performance tuning tips
http://www.support.microsoft.com/?id=224587 Troubleshooting App Performance
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_perfmon_24u1.asp Disk Monitoring
http://sqldev.net/misc/WaitTypes.htm Wait Types
http://support.microsoft.com/?id=271509 Script to Monitor Blocking

Performance Tuning -Articles
http://www.sql-server-performance.com/articles_performance.asp

Performance Tuning –Hardware
http://www.sql-server-performance.com/sg_sql_server_performance_article.asp

Large number of rows issue

Hi ,

There is a table with the following structure

_
Date-Time of Operation | Message | details | Reason | Username | IP | MAC-Address
_

A user can fire query based on some condition on columns. The maximum no of rows that should be returned are 1 billion.

By default the data returned to the view is sorted on Date-Time. Further user can sort the data in the view on Message, details , reason , username , IP , Mac-Address.

Suppose i have a scenerio where the user first gets the 1 billion records, then some records are inserted in the database.Then user sort on IP column. Now for differnt sorting if i again fire the query new data will be obtained. Thus i will get different result.

One way is to maintain the data in my memory. But the number of records are huge,so this is not a good solution. So what should i do to get the disconnected data without actually getting everything in the memory.

Regards,
Sunil

One way would be to have a stored procedure to fire this information into another table, then have a view of that table. Hence you are in control of the "loading" of that data for reporting purposes.|||

Hi,

I had a similar case in my company.

The solution for the case was creating a second instance on a different server which keeps denormalized data partitioned according to a date field. And loading the most recent partition into memory.

Also the query should have to use the date field since it will use that criteria in the index.

The OLTP database server was using 4GB of RAM on the other hand this second instance was using 12 GB of RAM only for maintaining such reporting processes.

Perhaps you may create covering index on the table. But this will increase the size of data.

Eralper

Large number of reports

Hi

I have a large number of reports that are very similar in structure (only some query and report heading changes).

Creation of these is simple by creating a template or modifying the project file and saving as a new project. But whenever there is some change to be made (format or query change), it has to be made individually in all of the reports, which makes it very time consuming and error prone.

Can anyone give some suggestions as to how to automate this process, or some other way to improve maintainability in this situation.

Thanks

Shomik

Unfortunately RS does not support CSS which would be ideal. One solution is to make certain formatting options data driven. Seeing as most properties are expression based, you could have a styles table and have the report query the styles at runtime and set colours and fonts based on fields from a dataset. Any change would effect all supporting reports.|||

I have made the formatting options and even the static messages shown, database driven wherever possible. But still cannot do it everywhere, because of which even a position change of a textbox has to be made in all of the reports manually.

I tried using a template, but that is ok for creating the new report. I again have the same problem when it comes to maintenance.

Can anyone suggest any changes to the way I am doing this or another approach for tackling this issue ?

Thanks,

Shomik

Large number of records in MSMerge_GenHistory

My MsMerge_GenHistory has too many records (currently 1.6 million rows) and I
can't get it to go down.
One of my Merge publications accidentally had Subscription expire in XX days
set to 70 days. My MsMerge_Contents and GenHistory filled up to 1.6 Million
and 1.9 Million records before I caught the error. I have corrected the
Parameter and have been able to get my msmerge_contents down to 28 K rows. I
can't get MsMerge_GenHistory to come down.
I don't want to set every publication that I have to reinitialize. The
publication that had the expiration days parameter problem is a remote
subscriber with a laptop in the field and I don't have access to it on a
daily basis. It is causing me problems with other publications with
subscribers getting unable to process GenHistory messages. I have all of my
remote subscribers set with a QueryTimeout of 4000.
What can I do?
Thank You
Steve
One additional thing.
I noticed that most all of the records in msmerge_genhistory have a pubid of
NULL. A few have a with what looks like a valid guid. Are these records the
problem and can I simply delete them?
Thanks
"Steve" wrote:

> My MsMerge_GenHistory has too many records (currently 1.6 million rows) and I
> can't get it to go down.
> One of my Merge publications accidentally had Subscription expire in XX days
> set to 70 days. My MsMerge_Contents and GenHistory filled up to 1.6 Million
> and 1.9 Million records before I caught the error. I have corrected the
> Parameter and have been able to get my msmerge_contents down to 28 K rows. I
> can't get MsMerge_GenHistory to come down.
> I don't want to set every publication that I have to reinitialize. The
> publication that had the expiration days parameter problem is a remote
> subscriber with a laptop in the field and I don't have access to it on a
> daily basis. It is causing me problems with other publications with
> subscribers getting unable to process GenHistory messages. I have all of my
> remote subscribers set with a QueryTimeout of 4000.
> What can I do?
>
> Thank You
> Steve
|||What will happen if I run this with the Reinitialize Subscribers set to
False? I am trying to not reinitialize all of my subscribers.
I have found that most of my genhistory records, the pubid field is NULL.
Are these the problems and can I simply delete these?
I have a second question about a recommended max number of publications. I
have a database with 40 different publications . Each publication has 138
articles. Between all of these articles, there are in the neighborhgood of 1
million total records published. Some publications have multiple subscribers,
most publications have a single subscriber with all columns published and
static row filters. Most of these subscribers are remote users traveling. Is
this too publications? This topology has saved us from a system wide
reinitialize a couple of times when a particular subscriber has trouble or
simply will not sync in a reasonable timeframe (we have most of our
publications set to expire in 20 days).
Thanks for the help!
Steve
"Paul Ibison" wrote:

> Steve,
> have a look in BOL at sp_mergecleanupmetadata - you could run this to do a
> manual cleanup of the metedata.
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
>
>