Showing posts with label point. Show all posts
Showing posts with label point. Show all posts

Tuesday, March 20, 2012

3 table joins - 3rd table join main not exist (return null columns) - please help!

Hello SQL Guru's,

This has had me stumped for about 8 hours already and I think I've gotten to a point where I'm trying the same things over and over again and they are just not working. Any help would be greatly appreciated!

My Table Structure:

Table 1) 'Modules'

ModuleID | ModuleName | isVisible
--
1 Test 1 True
2 Test 2 True
3 Test 3 False
4 Test 4 True

Table 2) 'ModuleUserTypes'

ID | ModuleID | UserType

1 1 1
2 1 2
3 2 1
4 3 1
5 4 1
6 4 2

Table 3) 'ModuleUserSettings'

ID | ModuleID | UserID | CustomTitle | BGColor
--
1 2 1 New Title2 Black
2 2 2 New Title2 White
3 3 1 New Title3 Orange
4 4 1 NewTitle4 Yellow

My Goal:
To be able to join the 3 tables 'Modules', 'ModuleUserTypes', and 'ModuleUserSettings' together and return 'ModuleID, ModuleName, CustomTitle, BGColor' for ALL Modules with UserType = 1 along with associated ModuleUserSettings IF the UserSetting exists, otherwise NULL for the columns.

My desired result set:

UserID = 1
UserType = 1
isVisible = True

ModuleID | ModuleName | CustomTitle | BGColor
--
1 Test1 NULL NULL
2 Test2 New Title2 White
4 Test4 New Title4 Yellow

I'm sure this type of query will be easy for someone out there, but rather hard for me!

Thanks for your efforts!

Execute the following query, to get your results :

select m.ModuleID,m.ModuleName,CustomTitle,BGColor

from Modules m left join ModuleUserTypes mut on m.ModuleID = mut.ModuleID

left join ModuleUserSettings mus on m.ModuleID = mus.ModuleID

where (UserID is null or UserID = 1)

and UserType=1

and IsVisible = 1

Assumption - IsVisible column is bit data type

otherwise - use -

and IsVisible = 'True'

Thanks

Naras.

|||you need to include your User table or you table that define the usertype of a user and you need to use left join

hope this helps

SELECT *
INTO #Modules
FROM (
SELECT 1 AS ModuleID
,'Test 1' AS ModuleName
, 'True' AS isVisible
UNION ALL
SELECT 2 AS ModuleID
,'Test 2' AS ModuleName
, 'True' AS isVisible
UNION ALL
SELECT 3 AS ModuleID
,'Test 3' AS ModuleName
, 'False' AS isVisible
UNION ALL
SELECT 4 AS ModuleID
,'Test 4' AS ModuleName
, 'True' AS isVisible
) Modules

SELECT *
INTO #ModuleUserTypes
FROM ( SELECT 1 AS [ID]
, 1 AS ModuleID
, 1 AS UserType
UNION ALL
SELECT 2 AS [ID]
, 1 AS ModuleID
, 2 AS UserType
UNION ALL
SELECT 3 AS [ID]
, 2 AS ModuleID
, 1 AS UserType
UNION ALL
SELECT 4 AS [ID]
, 3 AS ModuleID
, 1 AS UserType
UNION ALL
SELECT 5 AS [ID]
, 4 AS ModuleID
, 1 AS UserType
UNION ALL
SELECT 6 AS [ID]
, 4 AS ModuleID
, 2 AS UserType

) ModuleUserTypes

SELECT *
INTO #ModuleUserSettings
FROM (

SELECT 1 AS [ID]
, 2 AS ModuleID
, 1 AS UserID
, 'New Title2' AS CustomTitle
, 'White' AS BGColor
UNION ALL
SELECT 2 AS [ID]
, 2 AS ModuleID
, 2 AS UserID
, 'New Title2' AS CustomTitle
, 'Black' AS BGColor
UNION ALL
SELECT 3 AS [ID]
, 3 AS ModuleID
, 1 AS UserID
, 'New Title3' AS CustomTitle
, 'Orange' AS BGColor
UNION ALL
SELECT 4 AS [ID]
, 4 AS ModuleID
, 1 AS UserID
, 'New Title4' AS CustomTitle
, 'Yellow' AS BGColor
) ModuleUserSettings

SELECT *
INTO #Users
FROM (
SELECT 1 AS UserID
, 1 AS UserType
UNION ALL
SELECT 2 AS UserID
, 2 AS UserType

) Users

DECLARE @.UserType int
DECLARE @.UserID int
DECLARE @.isVisible varchar(5)

SET @.UserType = 1
SET @.UserID = 1
SET @.isVisible = 'True'

SELECT DISTINCT
m.ModuleID
, m.ModuleName
, mus.CustomTitle
, mus.BGColor
FROM #Modules m LEFT OUTER JOIN
#ModuleUserTypes mut ON m.ModuleID = mut.ModuleID LEFT OUTER JOIN
#ModuleUserSettings mus ON m.ModuleID = mus.ModuleID
AND mut.ModuleID = mus.ModuleID LEFT OUTER JOIN
#Users ut ON mut.UserType = ut.UserType
AND mus.UserID = ut.UserID
WHERE ISNULL(mut.UserType,@.UserType) = @.UserType
AND ISNULL(mus.UserID,@.UserID) = @.UserID
AND ISNULL(m.isVisible,@.isVisible) = @.isVisible

DROP TABLE #Modules
DROP TABLE #ModuleUserTypes
DROP TABLE #ModuleUserSettings
DROP TABLE #Users|||

select m.ModuleId,m.ModuleName ,mus.Customtitle,mus.bgcolour

from Modules m

join moduleusertypes mut

on m.moduleid = mut.moduleid

and mut.usertype = 1

left join ModuleUserSettings mus

on mus.moduleid = mut.moduleid

and mus.userid = mut.usertype

where IsVisible = 1

Assuming userid in 'ModuleUserSettings' is equal to UserType in 'ModuleUserTypes'

Regards,

kwareol

|||Thanks Nara's for your reply. I tried a similar statement but it was not filtering correctly. It would work until I added the UserType=1 and isVisible=1 to the where clause.
|||Kwareol,

Your statement took me in the right direction!

All I needed to add was the UserID filter.

This is the final statement that works exactly as I needed:

select m.ModuleId,m.ModuleName ,mus.Customtitle,mus.bgcolor

from Modules m

join moduleusertypes mut

on m.moduleid = mut.moduleid

and mut.usertype = 1

left join ModuleUserSettings mus

on mus.moduleid = mut.moduleid

and (mus.userid = 1 or mus.userid is null)

where IsVisible = 1

Thank you and everybody so much for your time and efforts!! It's much much appreciated!

(I marked this post as the final answer. I'm not exactly sure how this forums works and if users get some sort of point ranking for posting correct answers. If so, I will change it to Kwareol for him leading me in the direction I needed to go)

3 node sql2000 on win2003 cookbook?

Can some point to a doc (cookbook) for building a 3 node sql2000 cluster on
win 2003.
thanks,
JR
You can take a look at the following link
http://support.microsoft.com/?id=260758. It deals with FAQ and also has
links on how to install SQL2000 on Win2003 Cluster. Your experience should
not vary on the number of nodes on the cluster.
Sandeep Sutari
Microsoft Corp.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"jr" <jr@.jr.com> wrote in message
news:%23iyGdVQOEHA.904@.TK2MSFTNGP12.phx.gbl...
> Can some point to a doc (cookbook) for building a 3 node sql2000 cluster
on
> win 2003.
> thanks,
> JR
>
|||Sandeep, can you point to similar information on the Active / active clustering, not failover? i seems to find a lot about fail over but having hard time locating faq or a how to on configuring it as multiple active nodes to share the processing load.
Thank you
-- Sandeep Sutari [MSFT] wrote: --
You can take a look at the following link
http://support.microsoft.com/?id=260758. It deals with FAQ and also has
links on how to install SQL2000 on Win2003 Cluster. Your experience should
not vary on the number of nodes on the cluster.
Sandeep Sutari
Microsoft Corp.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"jr" <jr@.jr.com> wrote in message
news:%23iyGdVQOEHA.904@.TK2MSFTNGP12.phx.gbl...
> Can some point to a doc (cookbook) for building a 3 node sql2000 cluster
on[vbcol=seagreen]
> win 2003.
> JR
|||I don't think active/active means what you think it does here. :-) That's a
term that was used in SQL Server 7.0 to indicate that both nodes in your
Failover Cluster were running a installation of SQL Server that was being
accessed by users. Those instances do not share databases between them, they
were completely stand-alone. SQL Server 2000 does not allow multiple nodes
to access the same database at the same time either.
Sincerely,
Stephen Dybing
This posting is provided "AS IS" with no warranties, and confers no rights.
"Michael" <anonymous@.discussions.microsoft.com> wrote in message
news:538CE54C-0C3B-48B9-AD24-3E23CF18B54D@.microsoft.com...
> Sandeep, can you point to similar information on the Active / active
clustering, not failover? i seems to find a lot about fail over but having
hard time locating faq or a how to on configuring it as multiple active
nodes to share the processing load.
> Thank you
> -- Sandeep Sutari [MSFT] wrote: --
> You can take a look at the following link
> http://support.microsoft.com/?id=260758. It deals with FAQ and also
has
> links on how to install SQL2000 on Win2003 Cluster. Your experience
should
> not vary on the number of nodes on the cluster.
>
> --
> Sandeep Sutari
> Microsoft Corp.
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> Use of any included script samples are subject to the terms specified
at[vbcol=seagreen]
> http://www.microsoft.com/info/cpyright.htm
> "jr" <jr@.jr.com> wrote in message
> news:%23iyGdVQOEHA.904@.TK2MSFTNGP12.phx.gbl...
cluster[vbcol=seagreen]
> on
sql

Thursday, March 8, 2012

24 - 7 and the need for maintainence

Hi,
I hope someone can point me in the right direction at least on our
maintainence problem. As a 24x7 shop the databases are up all the time. We
are running enterprise edition 2000 on clustered servers.
The little mundane things like reindexing, torn page fix and other little
things that you would normally run in dead time are the problem.
How do you guys take care of these chores?
TIA
JohnJohn,
For reindexing, you might want to look at DBCC INDEXDEFRAG. Locking is totally different than
the other methods (essentially only locks the area where it currently "sweeps").
As for torn page fixing: This is not something you would normally have. Are you saying that this
is common in your installation?
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"John Campbell" <jcampbell@.us-south.net> wrote in message
news:ejiBemtRDHA.304@.tk2msftngp13.phx.gbl...
> Hi,
> I hope someone can point me in the right direction at least on our
> maintainence problem. As a 24x7 shop the databases are up all the time. We
> are running enterprise edition 2000 on clustered servers.
> The little mundane things like reindexing, torn page fix and other little
> things that you would normally run in dead time are the problem.
> How do you guys take care of these chores?
> TIA
> John
>|||I currently use the indexdefrag command. I have seen more torn pages at
this job than I have ever seen in the past. In the past I would only see
them on non-production type servers. Here I see them about every 2 to 3
months on the same server, different databases.
The normal solution is to drop the indexes and then recreate them.
The general maintainence issue is that I went on vacation a few weeks back.
Before I left I was running the DBCC INDEXDEFRAG on the 10 largest tables
about 2 or 3 times a week depenting on my schedule and system load.
Since I have come back, I am unable to run any of my maintenance without
blocking on this particular production server......
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:ebQ8HztRDHA.3144@.tk2msftngp13.phx.gbl...
> John,
> For reindexing, you might want to look at DBCC INDEXDEFRAG. Locking is
totally different than
> the other methods (essentially only locks the area where it currently
"sweeps").
> As for torn page fixing: This is not something you would normally have.
Are you saying that this
> is common in your installation?
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "John Campbell" <jcampbell@.us-south.net> wrote in message
> news:ejiBemtRDHA.304@.tk2msftngp13.phx.gbl...
> > Hi,
> > I hope someone can point me in the right direction at least on our
> > maintainence problem. As a 24x7 shop the databases are up all the time.
We
> > are running enterprise edition 2000 on clustered servers.
> > The little mundane things like reindexing, torn page fix and other
little
> > things that you would normally run in dead time are the problem.
> > How do you guys take care of these chores?
> >
> > TIA
> > John
> >
> >
>|||If your getting that many torn pages the I would take a good look at your
hardware, especially your disk subsystem to ensure it is working properly.
Torn pages usually occur when the write to the disk was not completed and
that is mainly caused by the hardware or power failures. As for your other
issue, are you saying that DBCC INDEXDEFRAG is now causing blocking at a
point it interferes with your app? It should only block pages at a time and
for brief periods. This should not adversely affect a properly designed
app. One thing it does do is take a shared lock on the table so if you have
any code in your app that takes out a table level lock this can be a
problem. What kind of blocking are you seeing?
Andrew J. Kelly
SQL Server MVP
"John Campbell" <jcampbell@.us-south.net> wrote in message
news:uBijd6tRDHA.3192@.TK2MSFTNGP10.phx.gbl...
> I currently use the indexdefrag command. I have seen more torn pages at
> this job than I have ever seen in the past. In the past I would only see
> them on non-production type servers. Here I see them about every 2 to 3
> months on the same server, different databases.
> The normal solution is to drop the indexes and then recreate them.
> The general maintainence issue is that I went on vacation a few weeks
back.
> Before I left I was running the DBCC INDEXDEFRAG on the 10 largest tables
> about 2 or 3 times a week depenting on my schedule and system load.
> Since I have come back, I am unable to run any of my maintenance without
> blocking on this particular production server......
> "Tibor Karaszi"
<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
> wrote in message news:ebQ8HztRDHA.3144@.tk2msftngp13.phx.gbl...
> > John,
> >
> > For reindexing, you might want to look at DBCC INDEXDEFRAG. Locking is
> totally different than
> > the other methods (essentially only locks the area where it currently
> "sweeps").
> >
> > As for torn page fixing: This is not something you would normally have.
> Are you saying that this
> > is common in your installation?
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > Archive at:
>
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
> >
> >
> > "John Campbell" <jcampbell@.us-south.net> wrote in message
> > news:ejiBemtRDHA.304@.tk2msftngp13.phx.gbl...
> > > Hi,
> > > I hope someone can point me in the right direction at least on our
> > > maintainence problem. As a 24x7 shop the databases are up all the
time.
> We
> > > are running enterprise edition 2000 on clustered servers.
> > > The little mundane things like reindexing, torn page fix and other
> little
> > > things that you would normally run in dead time are the problem.
> > > How do you guys take care of these chores?
> > >
> > > TIA
> > > John
> > >
> > >
> >
> >
>

Saturday, February 11, 2012

2005 Developer - Perf Monitor Counter Check Failed message

Trying to install 2005 Dev edition in xp pro, sp2.

Performance Monitor Counter Check Failed Error.
Had to stop the install twice at the point it verified what components were to be included as
the docs were not going to be installed. Resolved the issue.

Now it won't pass the system config test because the registry is not the way it wants it.
I look up the messages and the only solution is to hack the registry and risk my system.

This is nuts.

Isn't there some way to restart cleanly without hacking registry keys ?

Help.

I know it isn't a nice solution, but this thread sums up the registry changes to fix this problem. Sorry for the hassle. The thread discusses the released article to solve this, as well as some gotchas that aren't covered in the doc.

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

Thanks,
Sam Lester (MSFT)

|||Thanks,
I was able to complete the installation and thought all was well.
I was wrong.

No data base tools or docs were installed, so I ran the install again
and it says they are already there.. They are not.

I installed 2005 dev on my laptop with no issues and the installed dirs and products are
not the same.

I tried to uninstall 2005 on the problem desktop but it errors out during uninstall and no
I am trapped in do mans land.

Why can't the install program function correctly?

How can I start from scratch without rebuilding my machine?

2005 chart

At present I am showing the series name on each linie of the chart at each
point. How can I just show the series name on the line of the graph to appear
just once so that each chart line is indicated with the series name?
ThanksI am not sure whether I fully understand your problem . Try this ,
right click on the chart object and go to the properties -> Data tab.
Look at the series groups section at the bottom . Click on the
series , then click on edit and modify the label value . Leave it
blank for all or hard code it to the one you want or use an expression
to customise it. Hope that solves your problem.
Best of luck
Shai