Showing posts with label users. Show all posts
Showing posts with label users. Show all posts

Friday, March 30, 2012

Multiple Join Clause

I have a table "Users" like this:

GroupId
CompanyId
UserId

I need to query the users getting the company's and group's names, but I only know how to join one table. Example:

Select UserId, GroupId, Groups.Name, CompanyId, Companies.Name
From Users JOIN Groups ON Users.GroupId = Groups.Id

Hon can I add the companies table in the Join ?

Thanks,
MosheYou can have multiple JOIN clauses. I find it helpful to put them on separate lines, plus I always indicate the JOIN type since I never can remember which type is the default, and it is liable to change on someone's whim in the future. Plus normally I'd want to return the User's information whether or not I was able to successfully find the corresponding Group or Company -- which means OUTER JOINs:


SELECT
Users.UserId,
Users.GroupId,
ISNULL(Groups.Name,'**unknown**'),
Users.CompanyId,
ISNULL(Companies.Name,'**unknown**')
FROM
Users
LEFT OUTER JOIN
Groups ON Users.GroupId = Groups.Id
LEFT OUTER JOIN
Companies ON Users.CompanyID = Companies.CompanyID

Terri|||Thanks,
It was helpfull

Wednesday, March 28, 2012

multiple instances of spid's

I have sql server 2000 setup on 2003. When users are running queries agains
t
SQL Server from MS Access it opens up 10 - 18 instances for that user instea
d
of just 1 instance. Why would this happen and how can I fix it.
Your help/suggestion is greatly appreciated.
Thank youhelpplease wrote:
> I have sql server 2000 setup on 2003. When users are running queries
> against SQL Server from MS Access it opens up 10 - 18 instances for
> that user instead of just 1 instance. Why would this happen and how
> can I fix it.
> Your help/suggestion is greatly appreciated.
> Thank you
Sounds like an application design issue, not a SQL Server issue. You're
not saying you are seeing the same spid in sysprocesses listed multiple
times, are you? Either the application is programmed to perform multiple
connections to the database or this is happening automatically; possibly
because of active result sets in the application. Not an Access expert.
Probably better to ask this question in an Access ng.
David Gugick
Quest Software
www.imceda.com
www.quest.com|||Yes, I am seeing the same spid in sysprocesses listed multiple times.
What could be the problem?
Thank you
Divya
"David Gugick" wrote:

> helpplease wrote:
> Sounds like an application design issue, not a SQL Server issue. You're
> not saying you are seeing the same spid in sysprocesses listed multiple
> times, are you? Either the application is programmed to perform multiple
> connections to the database or this is happening automatically; possibly
> because of active result sets in the application. Not an Access expert.
> Probably better to ask this question in an Access ng.
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>|||helpplease wrote:
> Yes, I am seeing the same spid in sysprocesses listed multiple times.
> What could be the problem?
> Thank you
> Divya
>
That's probably because the same spid is running in multiple threads on
multiple CPUs. 10-18 instances of a SPID sounds high. Not sure what is
really going on. What version (and SP) of SQL Server are you using? How
many CPUs?
David Gugick
Quest Software
www.imceda.com
www.quest.com|||SQL Server 2000, Service Pack 3.
I have 4 Processors.
Thank you
"David Gugick" wrote:

> helpplease wrote:
> That's probably because the same spid is running in multiple threads on
> multiple CPUs. 10-18 instances of a SPID sounds high. Not sure what is
> really going on. What version (and SP) of SQL Server are you using? How
> many CPUs?
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>|||Any Suggestions on this one.
Thank you
"helpplease" wrote:
[vbcol=seagreen]
> SQL Server 2000, Service Pack 3.
> I have 4 Processors.
> Thank you
> "David Gugick" wrote:
>

multiple instances of spid's

I have sql server 2000 setup on 2003. When users are running queries against
SQL Server from MS Access it opens up 10 - 18 instances for that user instead
of just 1 instance. Why would this happen and how can I fix it.
Your help/suggestion is greatly appreciated.
Thank you
helpplease wrote:
> I have sql server 2000 setup on 2003. When users are running queries
> against SQL Server from MS Access it opens up 10 - 18 instances for
> that user instead of just 1 instance. Why would this happen and how
> can I fix it.
> Your help/suggestion is greatly appreciated.
> Thank you
Sounds like an application design issue, not a SQL Server issue. You're
not saying you are seeing the same spid in sysprocesses listed multiple
times, are you? Either the application is programmed to perform multiple
connections to the database or this is happening automatically; possibly
because of active result sets in the application. Not an Access expert.
Probably better to ask this question in an Access ng.
David Gugick
Quest Software
www.imceda.com
www.quest.com
|||Yes, I am seeing the same spid in sysprocesses listed multiple times.
What could be the problem?
Thank you
Divya
"David Gugick" wrote:

> helpplease wrote:
> Sounds like an application design issue, not a SQL Server issue. You're
> not saying you are seeing the same spid in sysprocesses listed multiple
> times, are you? Either the application is programmed to perform multiple
> connections to the database or this is happening automatically; possibly
> because of active result sets in the application. Not an Access expert.
> Probably better to ask this question in an Access ng.
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>
|||helpplease wrote:
> Yes, I am seeing the same spid in sysprocesses listed multiple times.
> What could be the problem?
> Thank you
> Divya
>
That's probably because the same spid is running in multiple threads on
multiple CPUs. 10-18 instances of a SPID sounds high. Not sure what is
really going on. What version (and SP) of SQL Server are you using? How
many CPUs?
David Gugick
Quest Software
www.imceda.com
www.quest.com
|||SQL Server 2000, Service Pack 3.
I have 4 Processors.
Thank you
"David Gugick" wrote:

> helpplease wrote:
> That's probably because the same spid is running in multiple threads on
> multiple CPUs. 10-18 instances of a SPID sounds high. Not sure what is
> really going on. What version (and SP) of SQL Server are you using? How
> many CPUs?
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>
|||Any Suggestions on this one.
Thank you
"helpplease" wrote:
[vbcol=seagreen]
> SQL Server 2000, Service Pack 3.
> I have 4 Processors.
> Thank you
> "David Gugick" wrote:
sql

multiple instances of spid's

I have sql server 2000 setup on 2003. When users are running queries against
SQL Server from MS Access it opens up 10 - 18 instances for that user instead
of just 1 instance. Why would this happen and how can I fix it.
Your help/suggestion is greatly appreciated.
Thank youhelpplease wrote:
> I have sql server 2000 setup on 2003. When users are running queries
> against SQL Server from MS Access it opens up 10 - 18 instances for
> that user instead of just 1 instance. Why would this happen and how
> can I fix it.
> Your help/suggestion is greatly appreciated.
> Thank you
Sounds like an application design issue, not a SQL Server issue. You're
not saying you are seeing the same spid in sysprocesses listed multiple
times, are you? Either the application is programmed to perform multiple
connections to the database or this is happening automatically; possibly
because of active result sets in the application. Not an Access expert.
Probably better to ask this question in an Access ng.
--
David Gugick
Quest Software
www.imceda.com
www.quest.com|||Yes, I am seeing the same spid in sysprocesses listed multiple times.
What could be the problem?
Thank you
Divya
"David Gugick" wrote:
> helpplease wrote:
> > I have sql server 2000 setup on 2003. When users are running queries
> > against SQL Server from MS Access it opens up 10 - 18 instances for
> > that user instead of just 1 instance. Why would this happen and how
> > can I fix it.
> >
> > Your help/suggestion is greatly appreciated.
> >
> > Thank you
> Sounds like an application design issue, not a SQL Server issue. You're
> not saying you are seeing the same spid in sysprocesses listed multiple
> times, are you? Either the application is programmed to perform multiple
> connections to the database or this is happening automatically; possibly
> because of active result sets in the application. Not an Access expert.
> Probably better to ask this question in an Access ng.
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>|||helpplease wrote:
> Yes, I am seeing the same spid in sysprocesses listed multiple times.
> What could be the problem?
> Thank you
> Divya
>
That's probably because the same spid is running in multiple threads on
multiple CPUs. 10-18 instances of a SPID sounds high. Not sure what is
really going on. What version (and SP) of SQL Server are you using? How
many CPUs?
--
David Gugick
Quest Software
www.imceda.com
www.quest.com|||SQL Server 2000, Service Pack 3.
I have 4 Processors.
Thank you
"David Gugick" wrote:
> helpplease wrote:
> > Yes, I am seeing the same spid in sysprocesses listed multiple times.
> >
> > What could be the problem?
> >
> > Thank you
> > Divya
> >
> That's probably because the same spid is running in multiple threads on
> multiple CPUs. 10-18 instances of a SPID sounds high. Not sure what is
> really going on. What version (and SP) of SQL Server are you using? How
> many CPUs?
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>|||Any Suggestions on this one.
Thank you
"helpplease" wrote:
> SQL Server 2000, Service Pack 3.
> I have 4 Processors.
> Thank you
> "David Gugick" wrote:
> > helpplease wrote:
> > > Yes, I am seeing the same spid in sysprocesses listed multiple times.
> > >
> > > What could be the problem?
> > >
> > > Thank you
> > > Divya
> > >
> >
> > That's probably because the same spid is running in multiple threads on
> > multiple CPUs. 10-18 instances of a SPID sounds high. Not sure what is
> > really going on. What version (and SP) of SQL Server are you using? How
> > many CPUs?
> >
> > --
> > David Gugick
> > Quest Software
> > www.imceda.com
> > www.quest.com
> >
> >

Friday, March 23, 2012

Multiple Filters in an AD HOC report.

There are many business users in my office who would like an AD HOC reporting
system. I am not in a position to install the reporting server right now
suite and check it out myself. I have seen some presentations and i like the
tool for the most part ...I have some questions if anyone can help...
1. Can the users select two tables for a report and manually specify the
join column between the two.
2. Can the user specify more than one condition in the filter. Like Name = X AND Address = Y AND Job = Z where Name, Address, Job can be columns from
more than 1 table
3. Can the users sort on more than one column ?
4. Can the users group by on more than one column. Nested grouping ?Your users can create their own reports using "Report Builder" provided you
create some report model. Nothing complicated Report Model is basically
imangine as a view with all the tables joined together.
Now all the 4 questions the answer is "YES" and it is possible.
Amarnath
"Tk_Neo" wrote:
> There are many business users in my office who would like an AD HOC reporting
> system. I am not in a position to install the reporting server right now
> suite and check it out myself. I have seen some presentations and i like the
> tool for the most part ...I have some questions if anyone can help...
> 1. Can the users select two tables for a report and manually specify the
> join column between the two.
> 2. Can the user specify more than one condition in the filter. Like Name => X AND Address = Y AND Job = Z where Name, Address, Job can be columns from
> more than 1 table
> 3. Can the users sort on more than one column ?
> 4. Can the users group by on more than one column. Nested grouping ?

Wednesday, March 21, 2012

multiple exports files from one report?

Hi
I have a simple report I would like to run for 60 users. Is there a way to
have one report cycle though a dataset and create 60 exported .mhtml files? I
really don't want to create 60 reports and 60 subscriptions :(
All the exported files would reside in the same folder.
Any help would be much appreciated!
Thanks,
MarcusHi,
You should take a look at the Data Driven subscription. This will enable to
generate multiple reports, with different parameters, just the way you want.
For more info:
http://msdn.microsoft.com/library/en-us/rswork/htm/rms_subscribing_v1_7oj9.asp
--
| Jan Pieter Posthuma
--
"Marcus K" wrote:
> Hi
> I have a simple report I would like to run for 60 users. Is there a way to
> have one report cycle though a dataset and create 60 exported .mhtml files? I
> really don't want to create 60 reports and 60 subscriptions :(
> All the exported files would reside in the same folder.
> Any help would be much appreciated!
> Thanks,
> Marcus|||Thanks, I'm not sure what I've done, but I can't get the data-driven
subscrition option to show up. I've already stored the credentials in the
report. It must be something with the security on the site, but I've got
everyone as Site Administration during our testing... weird
"Jan Pieter Posthuma" wrote:
> Hi,
> You should take a look at the Data Driven subscription. This will enable to
> generate multiple reports, with different parameters, just the way you want.
> For more info:
> http://msdn.microsoft.com/library/en-us/rswork/htm/rms_subscribing_v1_7oj9.asp
> --
> | Jan Pieter Posthuma
> --
>
> "Marcus K" wrote:
> > Hi
> >
> > I have a simple report I would like to run for 60 users. Is there a way to
> > have one report cycle though a dataset and create 60 exported .mhtml files? I
> > really don't want to create 60 reports and 60 subscriptions :(
> >
> > All the exported files would reside in the same folder.
> >
> > Any help would be much appreciated!
> >
> > Thanks,
> > Marcus

Monday, March 19, 2012

Multiple Datasets and Report Design problems

I have a table in Database A with users and a table in Database B with
call log records. I need to report the call log for each user in the
User table, sorting by Dept (User table) and then user (user table).
Call data will be detailed for each user. Report will run with a date
range selection. I do not know how to design this. I originally started
with a subreport to print the call detail for a user. Unfortunately, I
need to be able to total and avg call detail for each user, dept which I
believe must happen in the main report. By using a sub report I don?t
think this is possible.
How do I accomplish this?
Thanks in advance.
PamHi Pam,
I'm not sure how your databases are set up (are they on the same
server?), but I would probably choose to combine the data from the
database instead of combining it at the report level - that way you
only need 1 report table and no sub reports and grouping/toggling the
data will be a piece of cake:
SELECT * from User INNER JOIN DatabaseB.dbo.CallLogs CallLogs ON
User.username = CallLogs.username ORDER BY Department, UserName
I hope this helps.
Take Care!
Michelle

Multiple Datasets and Report Design confusion

I have a table in Database A with users and a table in Database B with
call log records. I need to report the call log for each user in the
User table, sorting by Dept (User table) and then user (user table).
Call data will be detailed for each user. Report will run with a date
range selection. I do not know how to design this. I originally started
with a subreport to print the call detail for a user. Unfortunately, I
need to be able to total and avg call detail for each user, dept which I
believe must happen in the main report. By using a sub report I don?t
think this is possible.
Any ideas on how to accomplish this scenario?
Thanks in advance.If both these databases are in the same SQL Server then it is a piece of
cake to do this in a Stored Procedure, just join the two tables. If they are
in different servers it is a little more difficult, you would need to use
linked servers. Same strategy though, you need to look at creating a stored
procedure. Based on your description it does seem to me that a subreport
will not work for you.
Oh, another idea. You don't even need a stored procedure if they are on the
same server, use the generic query designer and create the sql:
select a.field1, a.field2, b.field1, b.field2 from dbname.dbo.usertable a
innerjoin dbname2.dbo.calllog b on a.whatever = b.whatever where
b.somedatefield > @.startdate and b.somedatefield < @.enddate
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"pb" <pbrechlin@.hotmail.com> wrote in message
news:%23v$M9Z7AFHA.2112@.TK2MSFTNGP09.phx.gbl...
> I have a table in Database A with users and a table in Database B with
> call log records. I need to report the call log for each user in the
> User table, sorting by Dept (User table) and then user (user table).
> Call data will be detailed for each user. Report will run with a date
> range selection. I do not know how to design this. I originally started
> with a subreport to print the call detail for a user. Unfortunately, I
> need to be able to total and avg call detail for each user, dept which I
> believe must happen in the main report. By using a sub report I don?t
> think this is possible.
> Any ideas on how to accomplish this scenario?
> Thanks in advance.|||I believe that your best bet would be to either have some process that
creates an intermediary resultant table combining the abstract data
relationship between the two tables, or design your stored procedure so
that you are joining the two together.
As a design key I always try to leave the real work to the best of
breed. In this case you are going to be better off doing your real data
work in the database layer(SQL Server), not in the application layer
(Reporting Services).
-Brian
pb wrote:
> I have a table in Database A with users and a table in Database B
with
> call log records. I need to report the call log for each user in the
> User table, sorting by Dept (User table) and then user (user table).
> Call data will be detailed for each user. Report will run with a date
> range selection. I do not know how to design this. I originally
started
> with a subreport to print the call detail for a user. Unfortunately,
I
> need to be able to total and avg call detail for each user, dept
which I
> believe must happen in the main report. By using a sub report I
don't
> think this is possible.
> Any ideas on how to accomplish this scenario?
> Thanks in advance.|||THanks Brian, Bruce and Michelle. I have chosen to link my servers (data
on two different servers). I created some views and stored procedures.
All is woking great. Thanks for the direction!
Bruce L-C [MVP] wrote:
> If both these databases are in the same SQL Server then it is a piece of
> cake to do this in a Stored Procedure, just join the two tables. If they are
> in different servers it is a little more difficult, you would need to use
> linked servers. Same strategy though, you need to look at creating a stored
> procedure. Based on your description it does seem to me that a subreport
> will not work for you.
> Oh, another idea. You don't even need a stored procedure if they are on the
> same server, use the generic query designer and create the sql:
> select a.field1, a.field2, b.field1, b.field2 from dbname.dbo.usertable a
> innerjoin dbname2.dbo.calllog b on a.whatever = b.whatever where
> b.somedatefield > @.startdate and b.somedatefield < @.enddate
>

Monday, March 12, 2012

Multiple DataBases single report

Ok Here's the senario,

I am currently designing a report which will be used in a production environment by multiple users. Now each of these users might be looking at a different production database, now i want to be able to create a single report that can be pointed at any one of these databases depending on which user calls the report. All the databases have the same structure but may contain different data, so in effect the query I am using can remain the same it is just the datasource connection info that needs to change dependant on the user and the database they are looking at. I could create multiple instances of the same report each with a connection to the different databases, but i would prefere to have only a single report.

I am considering writing a seperate App which the user could launch from within the production environment which would then pass the connection iformation to the report based on what ever user is running it, this however seems like a bit of a hack, Is there a better way of doing it.

Cheers

James R

Can you pass a parameter in when they run the report where the stored procedure will pull the info from the correct server?

For instance, if you had a dataset that contained the log-in user id and a code to identify what server to use (say 'A' would be Prod01 and 'B' would be Prod02)

Then in you could pass the server code to the stored procedure that pulls the data you could do something like

IF @.srvrCode = 'A'
BEGIN
SELECT *
FROM PROD01.DATABASE.dbo.Table
END

IF @.srvrCode = 'B'
BEGIN
SELECT *

FROM PROD02.DATABASE.dbo.Table
END

Hopefully that could offer some assistance

Multiple Databases accessed by Multiple reports by Multiple users...?

Hello All,
I am somewhat new to MS Reporting Services and I've got a situation
where I have different users needing to access the same report (rdl)
but from different databases?
Ideally I would want to have each report pointing to all databases
dynamically.
Do you know how I would go about setting this up? Multiple reports
pointing to different datasources? Passing a parameter which
determines a specific datasource? - Is it even possible to pass a
parameter to the report to determine which data source to use?
Thanks for your help in advance
MagAre you using RS 2000 or RS 2005? In RS 2005 you can use data source
expressions (search books online under expressions, data sources). If RS
2000 it is much harder and a total pain and I strongly suggest going to RS
2005.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"mag" <mestafanos@.gmail.com> wrote in message
news:1137700476.286569.181810@.g14g2000cwa.googlegroups.com...
> Hello All,
> I am somewhat new to MS Reporting Services and I've got a situation
> where I have different users needing to access the same report (rdl)
> but from different databases?
> Ideally I would want to have each report pointing to all databases
> dynamically.
> Do you know how I would go about setting this up? Multiple reports
> pointing to different datasources? Passing a parameter which
> determines a specific datasource? - Is it even possible to pass a
> parameter to the report to determine which data source to use?
> Thanks for your help in advance
> Mag
>

Saturday, February 25, 2012

Multiple Cascade Paths - Fails on SQL Server 2000

This is an old issue, which I chose to ignore, since it was for a temporary
app with a handful of users (famous last words, I know).
The "multiple foreign keys" post today got me thinking about it, and I
figured it is worth looking for a solution.
I will post DDL at the end, but the theory is the main point here, so I hope
my description will suffice.
Please forgive the camel case naming convention, and the silly tbl prefixes.
I do not like it either, but it is a standard in our department.
tblParameter has two FK constraints.
One references tblReport.strReportID
One references tblLookupProcedures.strLookupProcedure
Both tblReport and tblLookupProcedures have a FK reference to
tblDatabaseConnections.strConnectionName
Ideally, all of these constraints have ON UPDATE CASCADE, but the second
constraint on tblParameter will error out with this message:
****
Introducing FOREIGN KEY constraint 'FK_tblParameter_tblLookupProcedures' on
table 'tblParameter' may cause cycles or multiple cascade paths. Specify ON
DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY
constraints.
****
I believe the error is caused because updates to the PK in
tblDatabaseConnections triggers updates to the FK in two tables, each of
which are referenced by tblParameter. Now the references are not on the
same columns, but SQL Server seems to think this could lead to circular
references.
The questions are:
1. Is this against RD theory, or is it just a quirk of SQL Server?
2. Is there a setting that will allow this?
3. What is the usual workaround? A trigger is the only thing that I could
think of.
Here is the DDL, scaled down to demonstrate the issue.
CREATE TABLE [dbo].[tblDatabaseConnections] (
[strConnectionName] [varchar] (10) PRIMARY KEY NOT NULL ,
[strDatabase] [varchar] (50) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tblLookupProcedures] (
[strLookupProcedure] [varchar] (50) PRIMARY KEY NOT NULL ,
[strProcedureDescription] [varchar] (100) NOT NULL ,
[strConnectionName] [varchar] (10) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tblReport] (
[strReportID] [varchar] (10) PRIMARY KEY NOT NULL ,
[strReportDescr] [varchar] (50) NULL ,
[strConnectionName] [varchar] (10) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[tblParameter] (
[strReportID] [varchar] (10) NOT NULL ,
[strParamID] [varchar] (20) NOT NULL ,
[strLookupProcedure] [varchar] (50) NOT NULL
PRIMARY KEY ([strReportID],[strParamID])
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tblLookupProcedures] ADD
CONSTRAINT [FK_tblLookupProcedures_tblDatabaseConne
ctions] FOREIGN KEY
([strConnectionName]
) REFERENCES [dbo].[tblDatabaseConnections] ([strConnectionName]
) ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[tblReport] ADD
CONSTRAINT [FK_tblReport_tblDatabaseConnections] FOREIGN KEY
([strConnectionName]
) REFERENCES [dbo].[tblDatabaseConnections] ([strConnectionName]
) ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[tblParameter] ADD
CONSTRAINT [FK_tblParameter_tblReport] FOREIGN KEY
([strReportID]
) REFERENCES [dbo].[tblReport] ([strReportID]
) ON UPDATE CASCADE
GO
--This constraint fails due to a perceived cyclical reference
ALTER TABLE [dbo].[tblParameter] ADD CONSTRAINT
[FK_tblParameter_tblLookupProcedures] FOREIGN KEY
([strLookupProcedure]
) REFERENCES [dbo]. [tblLookupProcedures]([strLookupProcedur
e]
) on update cascade
GO
-- if we remove on update cascade, the constraint gets created
ALTER TABLE [dbo].[tblParameter] ADD CONSTRAINT
[FK_tblParameter_tblLookupProcedures_NOC
ASCADE] FOREIGN KEY
([strLookupProcedure]
) REFERENCES [dbo]. [tblLookupProcedures]([strLookupProcedur
e]
)
GO
drop table [dbo].[tblParameter];
drop table [dbo].[tblReport];
drop table [dbo].[tblLookupProcedures];
drop table [dbo].[tblDatabaseConnections];I sketched it all out on some scrap paper. I think the real issue is that th
e
row that would get deleted on tblParameter depends upon which path the
cascade took down the tree. I can see how deleting a value of
strConnectionName from tblDatabaseConnections could result in different
rows being deleted in tblParameter through the cascade depending on the path
,
because the foreign keys in tblParameter point to different columns in
tblLookupProcedures and tblReport. (I hope that made sense).
Another thing is that SQL will determine if any constraints would be
violated by the cascading action, and rollback any transactions that
initiated the cascade. What if one path violated some constraint on
tblParameter, but the other path didn't?
Just thinking out loud.
"Jim Underwood" wrote:

> This is an old issue, which I chose to ignore, since it was for a temporar
y
> app with a handful of users (famous last words, I know).
>|||Interesting points, but I am using cascade update, not cascade delete, so
the updates would not filter down through the levels, they would stop at the
first table, since different columns are affected.
Just for chuckles I tried adding
ON DELETE NO ACTION
to the constraints but the results were the same.
"Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
news:5C7F6B3D-DC1B-4F64-9F4A-16EE6F66D51C@.microsoft.com...
> I sketched it all out on some scrap paper. I think the real issue is that
the
> row that would get deleted on tblParameter depends upon which path the
> cascade took down the tree. I can see how deleting a value of
> strConnectionName from tblDatabaseConnections could result in different
> rows being deleted in tblParameter through the cascade depending on the
path,
> because the foreign keys in tblParameter point to different columns in
> tblLookupProcedures and tblReport. (I hope that made sense).
> Another thing is that SQL will determine if any constraints would be
> violated by the cascading action, and rollback any transactions that
> initiated the cascade. What if one path violated some constraint on
> tblParameter, but the other path didn't?
> Just thinking out loud.
>
> --
> "Jim Underwood" wrote:
>
temporary
>|||As far as relational set theory goes, an update is really just a delete /
insert pair. (There's no 'updated' virtual table you can use inside a
trigger).
"Jim Underwood" wrote:

> Interesting points, but I am using cascade update, not cascade delete, so
> the updates would not filter down through the levels, they would stop at t
he
> first table, since different columns are affected.
> Just for chuckles I tried adding
> ON DELETE NO ACTION
> to the constraints but the results were the same.
> "Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
> news:5C7F6B3D-DC1B-4F64-9F4A-16EE6F66D51C@.microsoft.com...
> the
> path,
> temporary
>
>|||Ahhhh...
Now that makes sense.
"Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
news:6F31E2E5-9B2F-4EF3-8D53-2B44F6403D0B@.microsoft.com...
> As far as relational set theory goes, an update is really just a delete /
> insert pair. (There's no 'updated' virtual table you can use inside a
> trigger).
> "Jim Underwood" wrote:
>
so
the
message
that
different
the|||Jim,
I have had discussions about this (in one of these newsgroups) when it
was introduced in SQL Server 2000. SQL Server really takes a very
simplistic view. It acts as if each table only has one column when it
determines if there is a potential circular reference. This is really
silly if you ask me, because it means there is hardly any real life
application that makes it worth your while to use it.
AFAIK there is not setting around this. You must avoid this supposed
circular reference. One way of doing that is to define the 'offending'
foreign key constraint as not cascading. But obviously that does not
achieve the desired cascading.
Of course triggers are always an options, but than means disabling the
foreign key constraint. So it is always a compromise...
By the way: has any of this changed in SQL Server 2005?
Gert-Jan
Jim Underwood wrote:
> This is an old issue, which I chose to ignore, since it was for a temporar
y
> app with a handful of users (famous last words, I know).
> The "multiple foreign keys" post today got me thinking about it, and I
> figured it is worth looking for a solution.
> I will post DDL at the end, but the theory is the main point here, so I ho
pe
> my description will suffice.
> Please forgive the camel case naming convention, and the silly tbl prefixe
s.
> I do not like it either, but it is a standard in our department.
> tblParameter has two FK constraints.
> One references tblReport.strReportID
> One references tblLookupProcedures.strLookupProcedure
> Both tblReport and tblLookupProcedures have a FK reference to
> tblDatabaseConnections.strConnectionName
> Ideally, all of these constraints have ON UPDATE CASCADE, but the second
> constraint on tblParameter will error out with this message:
> ****
> Introducing FOREIGN KEY constraint 'FK_tblParameter_tblLookupProcedures' o
n
> table 'tblParameter' may cause cycles or multiple cascade paths. Specify O
N
> DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY
> constraints.
> ****
> I believe the error is caused because updates to the PK in
> tblDatabaseConnections triggers updates to the FK in two tables, each of
> which are referenced by tblParameter. Now the references are not on the
> same columns, but SQL Server seems to think this could lead to circular
> references.
> The questions are:
> 1. Is this against RD theory, or is it just a quirk of SQL Server?
> 2. Is there a setting that will allow this?
> 3. What is the usual workaround? A trigger is the only thing that I could
> think of.
>
[snip]|||DB2 had this problem in a very early version. If you had cascade
chains like A-->B, B-->C and A-->C, the final values in C would be
whoever got there last to overwrite the value. Today DB2 has a pretty
good cycle detector and allows some things that it did not before.
The relational rule is that all possible cascade paths must leave the
DB in the same state when they finish and that state has to be validate
under all the constraints.
This is hard to implement in theory -- remember graph theory? So real
products give up at some point, using a combination of a graph and
constraints. SQL Server happens to quit very early :)|||Thanks for the response. I don't have a 2005 environment to test in, so I
am not sure if the issue is the same or not.
"Gert-Jan Strik" <sorry@.toomuchspamalready.nl> wrote in message
news:446A3C9E.BE700DFF@.toomuchspamalready.nl...
> Jim,
> I have had discussions about this (in one of these newsgroups) when it
> was introduced in SQL Server 2000. SQL Server really takes a very
> simplistic view. It acts as if each table only has one column when it
> determines if there is a potential circular reference. This is really
> silly if you ask me, because it means there is hardly any real life
> application that makes it worth your while to use it.
> AFAIK there is not setting around this. You must avoid this supposed
> circular reference. One way of doing that is to define the 'offending'
> foreign key constraint as not cascading. But obviously that does not
> achieve the desired cascading.
> Of course triggers are always an options, but than means disabling the
> foreign key constraint. So it is always a compromise...
> By the way: has any of this changed in SQL Server 2005?
> Gert-Jan
>
> Jim Underwood wrote:
temporary
hope
prefixes.
second
on
ON
could
> [snip]|||Thanks. At least I know that my logical model is ok, I just need to change
the implementation a bit.
"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1147828111.648849.30010@.u72g2000cwu.googlegroups.com...
> DB2 had this problem in a very early version. If you had cascade
> chains like A-->B, B-->C and A-->C, the final values in C would be
> whoever got there last to overwrite the value. Today DB2 has a pretty
> good cycle detector and allows some things that it did not before.
> The relational rule is that all possible cascade paths must leave the
> DB in the same state when they finish and that state has to be validate
> under all the constraints.
> This is hard to implement in theory -- remember graph theory? So real
> products give up at some point, using a combination of a graph and
> constraints. SQL Server happens to quit very early :)
>

Monday, February 20, 2012

Multiple Ado Connections

Hi, I have a VB application running on SQL Enterprise Edition. Physically there are only 20 users loging in to the software at one time. However i can see more that 12 SPIDs for each user. The developers have been opening a new connection for each form in the application i guess. Is it normal or is there any specific requirement that foces them to do so? Shall i need to change the default WORKER-THREADS option on the server for peformance? Suggestions please!!!

Regards.They should close connections when the retrieving of data is completed
(or updates, or inserts are completed)

one connection per user is the best way to control connection leaks
(when developpers forget to close an unusefull connection)|||Means that they can open multiple connections for retrieving data for multiple forms however the connections must be closed later. What about the max-worker threads. Is there any need to change the settings, for i have more that 300 SPIDs at a time on the server.
Thanx for the kind response.|||programs are almost always "linear"
> open connection
> retrieve data1
> close connection

> open connection
> retrieve data2
> close connection
...

even if you've got 300 users there's rarely 300 connections
opened at the same time because they are closed most of the time
(except if users do big SELECTs on your database connections will
be opened longer)

Originally posted by TALAT
Means that they can open multiple connections for retrieving data for multiple forms however the connections must be closed later. What about the max-worker threads. Is there any need to change the settings, for i have more that 300 SPIDs at a time on the server.
Thanx for the kind response.|||The developers(genius) say that they close the connections in an error handler routine only, i.e., if an exception is thrown; they have written the code to close the connection for that particular form, otherwise not. What a nice coding technique they have adopted.

Regards.|||they could open a connection and leave it opened
but they should reuse this connection
instead of reopening new ones

this could be an other way to control the connection leaks

> start program : open ONE connection
> window1
> window2
> use program
> use program
...
> end program : close THE connection

in this case
Nb users = Nb connections

but if you have for example a max nb of connections at 100
only 100 users can connect at the same time

but with the other solution (open/close unuseful connection)
you can have more users than the max connections (100 in this example)
the users are not connected all the time of the use of the program
and they do not connect at the same time
if the max connections is reached a user just has to wait a little for a
connection to be liberated by an other user|||good luck with your consuming-connections-developper

just say to him that a connection is a very precious thing to waste
many users dreamed of having one free
and db-administrator cannot multiply them indefinitly

If ONE should use a connection
ONE should use it shortly
ONE should think of liberating it rapidly
ONE should carefully close it
ONE should know that ONE is not alone
For MANY use the program
Even if only ONE develops it|||I shall rather force them to stop doing this and to change their coding techiniques. Thanx for guiding and responding so quick. Thanx again!!

Regards.