Thursday, March 29, 2012
How Query Same Columns w/Mulitple Criteria
report and wonder if you guys can help. I need to query the same sets of
fields but with different criteria and compare them over time as follows:
-show order NetAmount, Gross Amount, %NetAmount for each sales person for
2003
-show order NetAmount, Gross Amount, %NetAmount for each sales person for
2004
-show % change
Might look something like:
SalesPersId 03GrsAmt 03NetAmt 03NetAmt% | 04GrsAmt 04NetAmt 04NetAmt%
| GrsChg% NetChg%
Not sure if this needs subqueries/subreports or some othe report feature.
I am struggling with the documentation so many thanks for any helpTake a look at [Company Sales.rdl] sample report that ships with the
product.
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mike Harbinger" <MikeH@.Cybervillage.net> wrote in message
news:%23gFwvgDrEHA.3868@.TK2MSFTNGP15.phx.gbl...
> I am trying to build my first report that is more than a simple columnar
> report and wonder if you guys can help. I need to query the same sets of
> fields but with different criteria and compare them over time as follows:
> -show order NetAmount, Gross Amount, %NetAmount for each sales person for
> 2003
> -show order NetAmount, Gross Amount, %NetAmount for each sales person for
> 2004
> -show % change
> Might look something like:
> SalesPersId 03GrsAmt 03NetAmt 03NetAmt% | 04GrsAmt 04NetAmt
04NetAmt%
> | GrsChg% NetChg%
> Not sure if this needs subqueries/subreports or some othe report feature.
> I am struggling with the documentation so many thanks for any help
>
>|||Thanks for the resonse. I don't have the sampe data base loaded that is
needed for the sampler reports and not sure why it wasn't created during the
install.
-How would I go about installing that DB?
-If I were using straigt SQL for this, what functions would I need;
subqueries, group by ..?
Thanks again!sql
Wednesday, March 28, 2012
How much storage needed for bit datatypes?
Hi!
I'm investigating if it is an good idea to use some form of "bitmap index",
e.g. I have an normal table with 100-200 columns, but sometimes I just want to know:
"Is there an value in the cell" (...where col20 is not null)
So I will measure if I get some benifit, so If you tried this, let me hear, but otherwise see only the rest:
If I remember correctly SQL Server will group bit-columns in some way minimizing storage needs,
but my questions: how much storage is needed for an bit column:
1 or 2 bit (the second bit, because we can have three states: 0,1 and null)
Will 8 bit-columns need 1 byte or 2 byte?
I tried some tests with a number table (1mio rows), but It didn't give me the answer.
Best Regards
Bjorn
create table tmpbit (a bit)
create table tmpbit8 (a1 bit, a2 bit, a3 bit , a4 bit, a5 bit , a6 bit, a7 bit, a8 bit)
insert into tmpbit
select cast(1 as bit) from numbers
insert into tmpbit8
select cast(1 as bit) , cast(1 as bit) , cast(1 as bit) , cast(1 as bit) ,
cast(1 as bit) , cast(1 as bit) , cast(1 as bit) , cast(1 as bit)
from numbers
select object_id('tmpbit8') -- for input to dbcc
DBCC SHOWCONTIG scanning 'tmpbit' table...
Table: 'tmpbit' (1269891891); index ID: 0, database ID: 6
TABLE level scan performed.
- Pages Scanned................................: 1359
- Extents Scanned..............................: 171
- Extent Switches..............................: 170
- Avg. Pages per Extent........................: 7.9
- Scan Density [Best Count:Actual Count].......: 99.42% [170:171]
- Extent Scan Fragmentation ...................: 1.75%
- Avg. Bytes Free per Page.....................: 1.8
- Avg. Page Density (full).....................: 99.98%
DBCC SHOWCONTIG scanning 'tmpbit8' table...
Table: 'tmpbit8' (1301892005); index ID: 0, database ID: 6
TABLE level scan performed.
- Pages Scanned................................: 1359
- Extents Scanned..............................: 171
- Extent Switches..............................: 170
- Avg. Pages per Extent........................: 7.9
- Scan Density [Best Count:Actual Count].......: 99.42% [170:171]
- Extent Scan Fragmentation ...................: 0.58%
- Avg. Bytes Free per Page.....................: 1.8
- Avg. Page Density (full).....................: 99.98%
both tmp-tables uses 10,617 MB
If your table have 1-8 then the values are strored in 1 Byte. again 1-16 stored in 2 bytes...
ie,
CEILING(n number of BIT columns /8.0) Bytes will be occupied.
|||
Hi!
Yes, but how can db store null without using extra bit?
/Bjorn
|||It can't. In fact, the null bitmap is an entirely separate structure within the row. Inside Microsoft SQL Server 2005: The Storage Engine (Delaney) has a nice diagram on page 216, along with some explanations, but the main details are that the null bitmap lies after the fixed-length column data, but before the variable-length column data. Furthermore, in SQL Server 2005, a row always has a null bitmap, even if there are no nullable columns. The size of the bitmap is 1 byte per 8 columns, rounded up to the nearest byte.Monday, March 19, 2012
How many columns?
In a SQL Serevr table maximum how many columns(or fields) are possible?
1024
How many columns is ok?
I have a database table containing about 40 columns, mostly bit data type, some nvarchar and smallint columns...
Is it ok to have so many columns in one table and how does the number of columns affect database perfomance? Wouldn't it be better to split this table?
Thank You!
JannoPossible? Yes. OK. Not really.
My guess is that you need to work on normalizing your database. For example, all those bit datatypes might be better served off in their own table, with a vertical not horizontal, design. This would much more easily allow you to add traits (bits) in the future.
What is the nature of the table, and what is being stored in all of those BIT columns?|||Pjmcb,
Basically it's a databese for flat rental site. Those BIT columns are used to store True/False type values.
In case I'm going to store those values verticaly in a separate table... could you please explain me how does it exactly works - I'm a SQL Server newbie...
Ads Table structure:
------------
AdIDint
AdTypesmallint
UserIDnvarchar
Activebit
AdDetails Table structure:
------------
AdIDint
Areasmallint
StreetNamenvarchar
Neighbourhoodnvarchar
Citynvarchar50
PostCodenvarchar15
AvailableFromdatetime
Rentmoney8
MinimumStaysmallint
Depositmoney8
PropertyTypenvarchar
Floorsmallint2
Parkingbit1
AdditionalCostmoney
Bathroomssmallint2
Bedroomssmallint2
Gasbit1
Cablebit1
TVbit1
Phonebit1
Closetbit1
Furnishedbit1
AirConditioningbit1
Bathbit1
Fireplacebit1
Balconybit1
Elevatorbit1
Washerbit1
KitchenAccessbit1
Storagebit1
Gardenbit1
Poolbit1
Gymnbit1|||You might have a second table, and call it, say Traits.
In this table, you might include each of the bit traits, along with an ID for each trait.
Then, you could have a join table to link each particular trait with each type of apartment. You would only have records in the join table for those traits that applied to a specific apartment.
You might have a second table for manetary items, with a similar join table, and a third with rooms or similar information.
With your join tables for these last two items, you could include additional information. For example, you might have:
Rooms
--
RoomID
RoomName
RoomDesc
(which might contain: Bedroom; Bathroom; Closets; Laundry Room; Kitchen; Living Room)
AdRooms
--
AdID
RoomID
RoomCount
Obviously, I'm throwing this out off the top of my head. But when you need to run an ad featuring an apartment with a SunRoom, all you need to do is add a record to your Rooms, table, and assign that value to your new apartment. You don't have to go in and change your database design.
Your retrieval of data might be a bit more complicated (actually, I would argue that ultimately, once you get comfortable with SQL, it will be easier), but growing the application will be much easier.|||I completely agree in principle with normalizing this, but it does depend on how the data is being used. if every single ad always lists each of those categories with a yes/no, it may make sense to leave it denormalized. bits don't hurt you that much as far as performance, the table is still relatively narrow. normalizing does make maintenance much better, as you point out, when you want to add additional attributes. it also makes the query more complex, although not necessarily slower. so those are just some tradeoffs I would keep in mind.
cs
How Many Columns Are Too Many?
I was just wondering if anyone can tell me what the max number of columns
you should put into a table is? I am writing an ASP.NET API that is using a
preexisting SQL Server backend. One of the existing tables is over 320
columns long. The servers are dual processor high end machines and the
traffic will be relatively low right now (about 5 users off and on a few
times every day). The test API I wrote works great with little or no pauses
but I am a little concerned about future traffic requirements if this API
takes off and there are consideraly more users.
Any comments and/or suggestions will be greatly appreciated.
TIA
Dennis Pike
Chief Technology Engineer
ErgoSoft Solutions
this question is a bit difficult to answer.
Generally you want to normalize your database but we need to know what it is
you're doing....
Greg Jackson
PDX, Oregon
|||BOL Lists the maximum "Columns per base table" at 1,024.
As for traffic, make sure that you are specifying column names explicitly in
your SELECT statements (no SELECT *) to ensure that you are only pulling
back the columns you actually need. You might even consider using Stored
Proc's if you have some very commonly used queries in your app.
"nomadic1" <nomadic1@.discussions.microsoft.com> wrote in message
news:984D499A-A30A-4E2E-B998-B8C43B562993@.microsoft.com...
> Greetings,
> I was just wondering if anyone can tell me what the max number of columns
> you should put into a table is? I am writing an ASP.NET API that is using
> a
> preexisting SQL Server backend. One of the existing tables is over 320
> columns long. The servers are dual processor high end machines and the
> traffic will be relatively low right now (about 5 users off and on a few
> times every day). The test API I wrote works great with little or no
> pauses
> but I am a little concerned about future traffic requirements if this API
> takes off and there are consideraly more users.
> Any comments and/or suggestions will be greatly appreciated.
> TIA
> --
> Dennis Pike
> Chief Technology Engineer
> ErgoSoft Solutions
How Many Columns Are Too Many?
I was just wondering if anyone can tell me what the max number of columns
you should put into a table is? I am writing an ASP.NET API that is using a
preexisting SQL Server backend. One of the existing tables is over 320
columns long. The servers are dual processor high end machines and the
traffic will be relatively low right now (about 5 users off and on a few
times every day). The test API I wrote works great with little or no pauses
but I am a little concerned about future traffic requirements if this API
takes off and there are consideraly more users.
Any comments and/or suggestions will be greatly appreciated.
TIA
--
Dennis Pike
Chief Technology Engineer
ErgoSoft Solutionsthis question is a bit difficult to answer.
Generally you want to normalize your database but we need to know what it is
you're doing....
Greg Jackson
PDX, Oregon|||BOL Lists the maximum "Columns per base table" at 1,024.
As for traffic, make sure that you are specifying column names explicitly in
your SELECT statements (no SELECT *) to ensure that you are only pulling
back the columns you actually need. You might even consider using Stored
Proc's if you have some very commonly used queries in your app.
"nomadic1" <nomadic1@.discussions.microsoft.com> wrote in message
news:984D499A-A30A-4E2E-B998-B8C43B562993@.microsoft.com...
> Greetings,
> I was just wondering if anyone can tell me what the max number of columns
> you should put into a table is? I am writing an ASP.NET API that is using
> a
> preexisting SQL Server backend. One of the existing tables is over 320
> columns long. The servers are dual processor high end machines and the
> traffic will be relatively low right now (about 5 users off and on a few
> times every day). The test API I wrote works great with little or no
> pauses
> but I am a little concerned about future traffic requirements if this API
> takes off and there are consideraly more users.
> Any comments and/or suggestions will be greatly appreciated.
> TIA
> --
> Dennis Pike
> Chief Technology Engineer
> ErgoSoft Solutions
How Many Columns Are Too Many?
I was just wondering if anyone can tell me what the max number of columns
you should put into a table is? I am writing an ASP.NET API that is using a
preexisting SQL Server backend. One of the existing tables is over 320
columns long. The servers are dual processor high end machines and the
traffic will be relatively low right now (about 5 users off and on a few
times every day). The test API I wrote works great with little or no pauses
but I am a little concerned about future traffic requirements if this API
takes off and there are consideraly more users.
Any comments and/or suggestions will be greatly appreciated.
TIA
--
Dennis Pike
Chief Technology Engineer
ErgoSoft Solutionsthis question is a bit difficult to answer.
Generally you want to normalize your database but we need to know what it is
you're doing....
Greg Jackson
PDX, Oregon|||BOL Lists the maximum "Columns per base table" at 1,024.
As for traffic, make sure that you are specifying column names explicitly in
your SELECT statements (no SELECT *) to ensure that you are only pulling
back the columns you actually need. You might even consider using Stored
Proc's if you have some very commonly used queries in your app.
"nomadic1" <nomadic1@.discussions.microsoft.com> wrote in message
news:984D499A-A30A-4E2E-B998-B8C43B562993@.microsoft.com...
> Greetings,
> I was just wondering if anyone can tell me what the max number of columns
> you should put into a table is? I am writing an ASP.NET API that is using
> a
> preexisting SQL Server backend. One of the existing tables is over 320
> columns long. The servers are dual processor high end machines and the
> traffic will be relatively low right now (about 5 users off and on a few
> times every day). The test API I wrote works great with little or no
> pauses
> but I am a little concerned about future traffic requirements if this API
> takes off and there are consideraly more users.
> Any comments and/or suggestions will be greatly appreciated.
> TIA
> --
> Dennis Pike
> Chief Technology Engineer
> ErgoSoft Solutions
Monday, March 12, 2012
How long will finish new column add to the biggest table?
Does anyone know, I will be add two new columns with small int data type to
existing table that has 121 million records. How long will finish? We use SQL
Server 2005 EE with SP2 (OS Windows 2003 with SP1).
Thanks!
-Chen
This is roughly impossible to predict. Make sure you add it using ALTER
TABLE and not through any designer in SSMS, and it will probably be fastest
if you make it NULL and don't put any NOT NULL / DEFAULT or other
constraints on it until after the column has been added.
"Chen" <Chen@.discussions.microsoft.com> wrote in message
news:41B2BF44-929A-481F-A06F-7DDC5B7992EF@.microsoft.com...
> Hi All,
> Does anyone know, I will be add two new columns with small int data type
> to
> existing table that has 121 million records. How long will finish? We use
> SQL
> Server 2005 EE with SP2 (OS Windows 2003 with SP1).
> Thanks!
> -Chen
How long will finish new column add to the biggest table?
Does anyone know, I will be add two new columns with small int data type to
existing table that has 121 million records. How long will finish? We use SQL
Server 2005 EE with SP2 (OS Windows 2003 with SP1).
Thanks!
-ChenThis is roughly impossible to predict. Make sure you add it using ALTER
TABLE and not through any designer in SSMS, and it will probably be fastest
if you make it NULL and don't put any NOT NULL / DEFAULT or other
constraints on it until after the column has been added.
"Chen" <Chen@.discussions.microsoft.com> wrote in message
news:41B2BF44-929A-481F-A06F-7DDC5B7992EF@.microsoft.com...
> Hi All,
> Does anyone know, I will be add two new columns with small int data type
> to
> existing table that has 121 million records. How long will finish? We use
> SQL
> Server 2005 EE with SP2 (OS Windows 2003 with SP1).
> Thanks!
> -Chen
How long to create a non-clustered index?
I know how many columns the index will affect, the column width in bytes, how many rows, an average row size, the number of hard disks, their speed in RPM, and they are setup in RAID 5.
Thanksdepends on lots of stuff|||What else do you need to know?|||there are too many variables. it could be 2 seconds to x number of hours. Hardware. configuration. is the table a terabyte in size or a megabyte in size. Is the column an int or varchar etc...(numbers process faster), what is already happening on the machine. Are the moons of saturn in alignment. is there a MLB conspiracy to have the cubs win the series this year now that red sox won.
just do it. if you are worried about what is going to ahppen to the computer, do it when everyone goes home or schedule it as job to run at midnight.|||The non-clustered index is created on 10 columns - each 100 bytes wide. The table is 6 X 10^6 rows and average 2000 bytes per row - so 12 X 10^9 bytes total. I have 5 15,000 RPM disks in RAID 5.
Take everything else out of the picture. I just need a mathematical way to estimate a best case/worst case scenario.|||I just need a mathematical way to estimate a best case/worst case scenario.
No you don't.
It's a bad idea in the first place
Don't do it.|||Can you explain how you came to this humble conclusion?|||I am tiddy bit curious about why anyone would need a 10 column index but I decided to keep my mouth shut.|||if memory serves (and it often does'nt) multi column idexes only do any good if all of the columns are searched in the same query and are queried in the same order that they appear in the index.
Seems to me something like this would be a performance hit on inserts and deletes and updates and such.
Am I close Brett.|||Can you explain how you came to this humble conclusion?
Let's see, a thousand byte + wide index...
I would think that would be very ineffecient.
Also, if you needed anything else from the row, I imagine, the optimizer might choose to ignore it anyway.
humble, not humble, whatever, it has nothing to do with it.
It's a bad idea.
Post the DDL of this table.
And who told you that you need that index?|||Seems to me something like this would be a performance hit on inserts and deletes and updates and such.
:eek:
Ya think?
Am I close to Brett.
Let's not start picking out wallpaper or anything... :)
But if you're buying...I'll have a 'rita on the rocks... :D
How long has transaction been open?
transaction hase been open? None of the columns in
sysprocesses seem to provide that.
ThanksThis is a multi-part message in MIME format.
--=_NextPart_000_008E_01C3FC84.72B5DE30
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Check out DBCC OPENTRAN in the BOL.
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Mike" <anonymous@.discussions.microsoft.com> wrote in message
news:2a1601c3fcad$eaf28550$a501280a@.phx.gbl...
Does anyone know how to determine how long an open
transaction hase been open? None of the columns in
sysprocesses seem to provide that.
Thanks
--=_NextPart_000_008E_01C3FC84.72B5DE30
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Check out DBCC OPENTRAN in the =BOL.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Mike" wrote in message news:2a1601c3fcad$ea=f28550$a501280a@.phx.gbl...Does anyone know how to determine how long an open transaction hase been open? None of the columns in sysprocesses seem to provide that.Thanks
--=_NextPart_000_008E_01C3FC84.72B5DE30--|||> Does anyone know how to determine how long an open
> transaction hase been open? None of the columns in
> sysprocesses seem to provide that.
See DBCC OPENTRAN, it displays information about the oldest active
transaction and the oldest distributed and nondistributed replicated
transactions, if any, within the specified database.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_dbcc_5fhq.asp
sincerely,
--
Sebastian K. Zaklada
Skilled Software
http://www.skilledsoftware.com
This posting is provided "AS IS" with no warranties, and confers no rights.|||Thank you both.
How long has transaction been open?
transaction hase been open? None of the columns in
sysprocesses seem to provide that.
ThanksCheck out DBCC OPENTRAN in the BOL.
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Mike" <anonymous@.discussions.microsoft.com> wrote in message
news:2a1601c3fcad$eaf28550$a501280a@.phx.gbl...
Does anyone know how to determine how long an open
transaction hase been open? None of the columns in
sysprocesses seem to provide that.
Thanks|||> Does anyone know how to determine how long an open
> transaction hase been open? None of the columns in
> sysprocesses seem to provide that.
See DBCC OPENTRAN, it displays information about the oldest active
transaction and the oldest distributed and nondistributed replicated
transactions, if any, within the specified database.
http://msdn.microsoft.com/library/d...
fhq.asp
sincerely,
--
Sebastian K. Zaklada
Skilled Software
http://www.skilledsoftware.com
This posting is provided "AS IS" with no warranties, and confers no rights.