From rl_stewart at highstream.net Thu Jul 1 10:47:42 2004 From: rl_stewart at highstream.net (Robert L. Stewart) Date: Thu, 01 Jul 2004 10:47:42 -0500 Subject: [dba-SQLServer] Re: Difference between views and queries In-Reply-To: <200407010008.i6108aQ04424@databaseadvisors.com> Message-ID: <5.1.0.14.2.20040701104631.01744c30@pop3.highstream.net> I made the assumption that we were talking about databases that were transactional and should be normalized. At 07:08 PM 30/06/2004 -0500, you wrote: >Date: Wed, 30 Jun 2004 20:37:49 +0000 >From: "Billy Pang" >Subject: RE: [dba-SQLServer] Re: Difference between views and queries >To: dba-sqlserver at databaseadvisors.com >Message-ID: >Content-Type: text/plain; format=flowed > >A database could be not normalized for reporting reasons, isn't that true? >difference between OLTP and OLAP? > >Billy > > > >From: "Robert L. Stewart" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: [dba-SQLServer] Re: Difference between views and queries > >Date: Wed, 30 Jun 2004 12:17:41 -0500 > > > >Francis, > > > >Actually the reason most databases are not fully normalized is not > >laziness, but ignorance. Most DBA's know nothing about normalization and > >many developers even less. And, yes I would make such a blanket statement. > > > >Robert > > From shamil at users.mns.ru Thu Jul 1 15:24:32 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Fri, 2 Jul 2004 00:24:32 +0400 Subject: [dba-SQLServer] Difference between views and queries References: <04d901c45eb2$82afb780$6601a8c0@rock><005401c45ef5$7716d500$0201a8c0@PARIS> <40E34FE8.2020803@verizon.net> Message-ID: <002501c45fad$c3257790$0201a8c0@PARIS> Francisco, I meant mainly metadata-driven (middle-tier) components, which on-the fly (recursively) build/execute SQL etc.etc. They are generic i.e. once written for a given meta-model they don't need to be rewritten - just augmented/extended... Shamil ----- Original Message ----- From: "Francisco H Tapia" To: Sent: Thursday, July 01, 2004 3:42 AM Subject: Re: [dba-SQLServer] Difference between views and queries > I hear what you're saying Shamil, but coding is coding at any layer. So > even with less resources, ie, .net or c# programmers, code must still be > altered even if not at the sql server, but at the gui or webservice > layer. These statements don't make as much sense to me as just > modifying the logic at the source. > > coding w/ .net components in your sproc doesn't make them dynamic sql, > it's like coding .COM objects in your sproc you can do it via sp_OAxxx > but these are limited to sysadmin roles because of the major security > risk involved. > > no offense either to you or to the article you posted, it's a good > article, I just don't agree that column names justify dynamic sql. > There are otherways of working output at the gui level if that is ultra > imporant. > > Shamil Salakhetdinov wrote On 6/30/2004 3:56 PM: > > >Arthur, > > > >Just a philosopical opinion/point of view: > > > >Database-centered programming for nowaday businesses are becoming more > >and more dynamic and constantly changing.... > >The SPs are like a "chiseled in stone" stuff. > >And dynamic SQL is an amorphic matter, flexibly and smoothly adapting to > >constantly changing businesses and their business rules. > >Please take into consideration this fact: "chiseled in stone" DLL-Hell > >producing COM interfaces are being substituted with .NET Framework > >flexible architecture... > >IMHO the similar tendence is starting to appear itself more and more > >apparently in data(base) layer programming. > >Here is why Application Roles (see BOL) were introduced. > >Here is why Youkon will support smooth integration with C#/VB.NET/... > >extended SPs which in turn will (I guess) work heavily with dynamic > >SQL... > > > >And as far as I see metadata-based data access and data > >integrity/business rules verification/support are also becoming more and > >more popular - and this is what is needed for the modern small and > >middle size businesses: they urge for the broad automation of their > >businesses because of economical and other reasons but they don't have > >enough resources to finance design and development and then constant > >redesign and code rewriting/refactoring... > > > >And of course I'm not talking about "SPs must die" - as usual solution > >is somewhere in between and is a balance of many interests but for sure > >dynamic SQL's role isn't that narrow as described in > >http://www.sqlservercentral.com/columnists/rmarda/whendynamicsqlisusefu l_printversion.asp - > >the fact is that most of these samples look obsolete because they can be > >rewritten IMO using UDFs, XML (OpenXML) - i.e.using SPs but without EXEC > >I think! :) > > > >Just my pair of roubles, > >Sorry in advance if I did miss the subject of this thread, > >Shamil > > > >-- > >e-mail: shamil at smsconsulting.spb.ru > >Web: http://smsconsulting.spb.ru/shamil_s > > > >----- Original Message ----- > >From: "Arthur Fuller" > >To: > >Sent: Wednesday, June 30, 2004 6:57 PM > >Subject: RE: [dba-SQLServer] Difference between views and queries > > > > > > > > > >>Good example, and good reasoning, and I agree that dynamic SQL is > >> > >> > >never > > > > > >>out of the question. What I intended to write is that more often than > >>not, dynamic SQL is the lazy way out of thinking carefully about > >> > >> > >sprocs. > > > > > >>Most of the time it is unnecessary and costly in terms of performance > >>and front-end code; some of the time, there is no other way. > >> > >>Arthur > >> > > > -- > -Francisco > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From shamil at users.mns.ru Thu Jul 1 15:59:14 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Fri, 2 Jul 2004 00:59:14 +0400 Subject: [dba-SQLServer] Difference between views and queries References: <058801c45f04$ceaa6d40$6601a8c0@rock> Message-ID: <005501c45fae$4700a7b0$0201a8c0@PARIS> Arthur, Yes, I also "don't want some "power user" to load Excel and f**k with the data!" And in the past SPs were almost the only secure way to defend DB from these power users. But now MS SQL have Application Role feature(see BOL), which IMO allows to write (server side) components in VB/C++/C#/VB.NET, which are as secure as SPs... > Ideally, I don't want any code that touches the database in the FE. Same goal here. Shamil ----- Original Message ----- From: "Arthur Fuller" To: Sent: Thursday, July 01, 2004 4:46 AM Subject: RE: [dba-SQLServer] Difference between views and queries > As usual, Shamil, you make excellenmt points. We are not arguing so much > as complementing each other's position. > > IMO, (and that's all it is), everything the database can do the database > should do. In my ideal SQL app, there would be almost no code in the FE > except the code that decides which sproc to fire and what to pass as > arguments. The more code that exists in the FE, the weaker I think the > app is. Why? Because I don't want some "power user" to load Excel and > f**k with the data! > > So when I build a SQL database, NO ONE (except me and my peers) can > touch a table. Everyone else using the system hits a sproc or view or > UDF. End of story. I, as godlike being, can touch tables. Mere mortals > cannot. Period. No exceptions. > > In practice, this means that I examine the human roles, i.e. job specs, > to see what the various humans in the organization are allowed to do. I > build roles corresponding to job specs. I generate simple sprocs for > each op (DISU = delete/insert/select/update) on each table. Could be > that a single form hits a number of tables, but the hits always result > in some combination of DISU -- there are no other ops. Having built the > single-table DISU ops, it becomes trivial to write a sproc that hits say > 5 tables, inserting into 2, updating 1, and deleting from 2. Nothing to > it, brain-dead simple once you have the atomic pieces in place. > > Ideally, I don't want any code that touches the database in the FE. Why? > Because if we dump FE#1 (let's call it Access) and replace it with FE#2 > (let's call it vb.net), I don't want to rewrite any database-hitting > code. I want to fire sprocs and/or call UDFS and be done with it. So if > some "power user" fires up Excel and creates an ODBC hook to the > database, he can't do anything but select (at most). Can't add, can't > edit, can't insert, can't delete. Substitute POwerBuilder or Delphi or > anything you want... If the only available access is via > sprocs/views/udfs, then I'm confident that you can't trudge in and stomp > all over my data. > > Every new UI inherits the smarts in the sprocs, and nothing needs to be > duplicated except the calls to the sprocs/views/udfs. IMO, this way no > code needs to be copied from one UI to another; you simply fire the > sprocs, passing what they require. If there's a bug in the sproc you fix > the sproc and all apps inherit the fix -- because the logic resides in > precisely one place -- the db, where it belongs! > > Ok, I stated this a little bit fundamentalist. There are exceptions, and > I accept them. > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Shamil > Salakhetdinov > Sent: Wednesday, June 30, 2004 6:56 PM > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] Difference between views and queries > > > Arthur, > > Just a philosopical opinion/point of view: > > Database-centered programming for nowaday businesses are becoming more > and more dynamic and constantly changing.... The SPs are like a > "chiseled in stone" stuff. And dynamic SQL is an amorphic matter, > flexibly and smoothly adapting to constantly changing businesses and > their business rules. Please take into consideration this fact: > "chiseled in stone" DLL-Hell producing COM interfaces are being > substituted with .NET Framework flexible architecture... IMHO the > similar tendence is starting to appear itself more and more apparently > in data(base) layer programming. Here is why Application Roles (see BOL) > were introduced. Here is why Youkon will support smooth integration with > C#/VB.NET/... extended SPs which in turn will (I guess) work heavily > with dynamic SQL... > > And as far as I see metadata-based data access and data > integrity/business rules verification/support are also becoming more and > more popular - and this is what is needed for the modern small and > middle size businesses: they urge for the broad automation of their > businesses because of economical and other reasons but they don't have > enough resources to finance design and development and then constant > redesign and code rewriting/refactoring... > > And of course I'm not talking about "SPs must die" - as usual solution > is somewhere in between and is a balance of many interests but for sure > dynamic SQL's role isn't that narrow as described in > http://www.sqlservercentral.com/columnists/rmarda/whendynamicsqlisuseful > _printversion.asp - the fact is that most of these samples look obsolete > because they can be rewritten IMO using UDFs, XML (OpenXML) - i.e.using > SPs but without EXEC I think! :) > > Just my pair of roubles, > Sorry in advance if I did miss the subject of this thread, Shamil > > -- > e-mail: shamil at smsconsulting.spb.ru > Web: http://smsconsulting.spb.ru/shamil_s > > ----- Original Message ----- > From: "Arthur Fuller" > To: > Sent: Wednesday, June 30, 2004 6:57 PM > Subject: RE: [dba-SQLServer] Difference between views and queries > > > > Good example, and good reasoning, and I agree that dynamic SQL is > never > > out of the question. What I intended to write is that more often than > > not, dynamic SQL is the lazy way out of thinking carefully about > sprocs. > > Most of the time it is unnecessary and costly in terms of performance > > and front-end code; some of the time, there is no other way. > > > > Arthur > > > > -----Original Message----- > > From: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy > > > Pang > > Sent: Wednesday, June 30, 2004 12:57 AM > > To: dba-sqlserver at databaseadvisors.com > > Subject: RE: [dba-SQLServer] Difference between views and queries > > > > > > oh boy, can't wait to get into this discussion :)...there is one > example > > I > > can think of.. the example would be based on the physical storage of > > the sproc in a single db. it is not possible for a sproc to query > > table > in > > another db that the sproc does not reside in. > > > > To illustrate, let's say that there are three copies of the northwind > db > > on > > db server: northwind0, northwind1 and northwind2; all three have exact > > > db schema; > > > > Your goal is to develop a report that counts number of records in the > > products table in each of the northwind databases. sometimes you may > > only want to count records in northwind0 and northwind1 but not > > northwind2; sometimes you may only want northwind2 and northwind1 but > > not northwind0; > > and sometimes you want all three northwind dbs in your count. It is > > possible to create a sp for each of the permutation but if a fourth > > northwind db is introduced to the system, then the code base is > doubled. > > > > The alternate solution would be to build dynamic sql to piece together > > > select statement referencing tables using the [db].[owner].[table] > > format; which tables are pieced together is based on what the user > > selects as criteria for report. Not elegant solution but it is a lot > > less code > to > > maintain. > > > > With that being said, dynamic sql is not as safe for reporting > compared > > to > > sproc. > > > > I think what Francis is trying to get at is that it is not possible > for > > a > > developer to claim that a particular "coding method" is never needed. > > Rather, it is more correct to state that it is not likely that a > > particular "coding method" is ever needed. Difference between the > > words "impossible" > > and "improbable". Similiar to how a judge cannot hand out a verdict > to > > court case before the case is presented no matter obvious it may seem. > > > > Another point of reference on this topic would be look up "Validating > > User Input" in BOL for best practices on this issue. > > > > Billy > > > > > > >From: "Arthur Fuller" > > >Reply-To: dba-sqlserver at databaseadvisors.com > > >To: > > >Subject: RE: [dba-SQLServer] Difference between views and queries > > >Date: Tue, 29 Jun 2004 20:08:54 -0400 > > > > > >All I want is an example that cannot be coded by one or more sprocs. > > > > > >Arthur > > > > > >-----Original Message----- > > >From: dba-sqlserver-bounces at databaseadvisors.com > > >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > > >Francis Harvey > > >Sent: Tuesday, June 29, 2004 10:47 AM > > >To: 'dba-sqlserver at databaseadvisors.com' > > >Subject: RE: [dba-SQLServer] Difference between views and queries > > > > > > > > >Francisco, > > > > > >I would like to consider the opinion of someone who shares my > namesake > > >as seriously as possible, but in this case, I believe you suffer from > > > >Arthur's problem of a lack of experience with the very specific > > >problems I cited. It is fine to talk about not using dynamic SQL in > > >general when using SQL Server, but just as with normalization, there > > >are exceptions and no one should be stating it as an absolute rule or > > > >bad practice until they have reviewed the problems I mentioned. > Again, > > >I will state, for those particular problems, dynamic SQL is often the > > > >superior solution. > > > > > >Also, the "scaling" issue is teetering awfully close to using FUD. > You > > >can always use any programming method incorrectly, but correctly > > >written dynamic SQL does not suffer from the horrible efficiency loss > > > >that not having a cached query plan would seem to imply. Similarly, > the > > > > >"time spent" argument is bad logic. I don't spend less time on my > > >dynamic SQL solutions, I spend more time because the problems are > > >difficult. Adding more time for a static SQL solution will not result > > > >in a better design or even a working design in some cases. > > > > > >I don't think you, Arthur or I are in disagreement over security, I > > >just didn't like the oversimplified way security was described, so I > > >chose to emphasize a particular point. I think this is an important > > >part that should be highlighted. > > > > > >Francis R Harvey III > > >WB 303, (301)294-3952 > > >harveyf1 at westat.com > > > > > > > > > > -----Original Message----- > > > > From: dba-sqlserver-bounces at databaseadvisors.com > > > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > > > > Francisco H Tapia > > > > Sent: Monday, June 28, 2004 12:42 PM > > > > To: dba-sqlserver at databaseadvisors.com > > > > Subject: Re: [dba-SQLServer] Difference between views and queries > > > > > > > > > > > > Francis, > > > > I respectfully agree w/ Arthur on this. Dynamic SQL as a rule, > > > > > is bad design. Many times over you will find that there are > > > > comparable solutions that often meet the demand much better, and > > > > "scale" much better than that of dynamic sql. There is no "ONE" > > > > right way of doing things, that is the nature of this business. > > > > However justifying dynamic sql because of some time spent on > > > > design is imnsho incorrect. You will > > > > often find more times that enabling users/roles via Views/Sprocs > and > > > > Functions to be far superior solutions than to open wide dynamic > > sql. > > > > > > > > re: security. > > > > Of course if you deny permissions on any object the take > precedence > > > > over allows, this is the nature of security. That is why you must > > > > > be explicitly "SURE" when making DENY requests on any object. NOT > > > > giving rights to an object does not equeal REJECT. > > > > > > > > If I do not give a user rights to a view, under Role1, but then > give > > > > > > him rights to that object via Role2. There will be 0 issues w/ > > > > accessability. However If by poor planning I had a "REJECT" > > > > rights in Role1, then I'd have the issues you are stating. > > > > > > > > > > > > > > > > > > > > Francis Harvey wrote On 6/25/2004 2:24 PM: > > > > > > > > >Arthur, > > > > > > > > > >Do some research on the basic solutions for SQL that has to > > > > adjust for > > > > >varying databases, conditions (dynamic search), or servers > > > > >(different > > > > > > > >SQL dialects). Some designs also call for encapsulating > > > > business logic > > > > >outside of the data tier. In these situations, dynamic SQL is > often > > > > > > >the only logical choice. I have only had to deal with dynamic > > > > >search myself, but this is enough to convince me of its > usefulness. > > > > > > > > > >Describing permissions solely as additive in nature is > > > > incorrect. This > > > > >is the point I was making. > > > > > > > > > >Francis R Harvey III > > > > >WB 303, (301)294-3952 > > > > >harveyf1 at westat.com > > > > > >_______________________________________________ > > >dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > >http://www.databaseadvisors.com > > > > > >_______________________________________________ > > >dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > >http://www.databaseadvisors.com > > > > > > > _________________________________________________________________ > > MSN Premium with Virus Guard and Firewall* from McAfeeR Security : 2 > > months > > FREE* > > > http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU > > =http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From davide at dalyn.co.nz Thu Jul 1 17:11:45 2004 From: davide at dalyn.co.nz (David Emerson) Date: Fri, 02 Jul 2004 10:11:45 +1200 Subject: [dba-SQLServer] Finding current login group Message-ID: <5.2.0.9.0.20040702095935.00b2bb80@mail.dalyn.co.nz> SQL2000 I am using Windows Authentication. I have set up Windows groups that users belong to. These groups are set up in SQL as logins (this means that new users just need to be added to the windows group to be given access to all the databases with permissions for the group). Within my ADP I need to find out what login the user has accessed the SQL database from so that I can show/hide controls etc. However, when I use the CURRENT_USER variable in a Sproc it returns the user, not the group they have come in by. EG - egas\David is a member of egas\BillingUsers Group. egas\BillingUsers is set up as a login in SQL (egas\David is not). When egas\David is using a database he has accessed it because he is a member of egas\BillingUsers. Is there a way to find out the login that was used for egas\David to get in (CURRENT_USER returns egas\David, I want egas\BillingUsers)? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 From Jeff at OUTBAKTech.com Thu Jul 1 17:44:37 2004 From: Jeff at OUTBAKTech.com (Jeff Barrows) Date: Thu, 1 Jul 2004 17:44:37 -0500 Subject: [dba-SQLServer] Finding current login group Message-ID: <8DA8776D2F418E46A2A464AC6CE63050032692@outbaksrv1.outbaktech.com> Have you tried: EXECUTE sp_who in the SQL Query Analyser? -----Original Message----- From: David Emerson [mailto:davide at dalyn.co.nz] Sent: Thu 7/1/2004 5:11 PM To: dba-SQLServer at databaseadvisors.com Cc: Subject: [dba-SQLServer] Finding current login group SQL2000 I am using Windows Authentication. I have set up Windows groups that users belong to. These groups are set up in SQL as logins (this means that new users just need to be added to the windows group to be given access to all the databases with permissions for the group). Within my ADP I need to find out what login the user has accessed the SQL database from so that I can show/hide controls etc. However, when I use the CURRENT_USER variable in a Sproc it returns the user, not the group they have come in by. EG - egas\David is a member of egas\BillingUsers Group. egas\BillingUsers is set up as a login in SQL (egas\David is not). When egas\David is using a database he has accessed it because he is a member of egas\BillingUsers. Is there a way to find out the login that was used for egas\David to get in (CURRENT_USER returns egas\David, I want egas\BillingUsers)? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From my.lists at verizon.net Thu Jul 1 18:14:35 2004 From: my.lists at verizon.net (Francisco H Tapia) Date: Thu, 01 Jul 2004 16:14:35 -0700 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <8DA8776D2F418E46A2A464AC6CE63050032692@outbaksrv1.outbaktech.com> References: <8DA8776D2F418E46A2A464AC6CE63050032692@outbaksrv1.outbaktech.com> Message-ID: <40E49ADB.2020109@verizon.net> sp_who returns domain and userid not the usergroup, and in fact I don't know how to get he usergroup name within a sproc, but one workaround is to create seperate functions and assign them rights based on the NT groups, you can have the sprocs return some type of value based on their usergroup name and this will provide you with the info you are seeking. Jeff Barrows wrote On 7/1/2004 3:44 PM: >Have you tried: EXECUTE sp_who in the SQL Query Analyser? > > -----Original Message----- > From: David Emerson [mailto:davide at dalyn.co.nz] > Sent: Thu 7/1/2004 5:11 PM > To: dba-SQLServer at databaseadvisors.com > Cc: > Subject: [dba-SQLServer] Finding current login group > > > > SQL2000 > > I am using Windows Authentication. I have set up Windows groups that users > belong to. These groups are set up in SQL as logins (this means that new > users just need to be added to the windows group to be given access to all > the databases with permissions for the group). > > Within my ADP I need to find out what login the user has accessed the SQL > database from so that I can show/hide controls etc. However, when I use > the CURRENT_USER variable in a Sproc it returns the user, not the group > they have come in by. > > EG - egas\David is a member of egas\BillingUsers Group. egas\BillingUsers > is set up as a login in SQL (egas\David is not). When egas\David is using > a database he has accessed it because he is a member of > egas\BillingUsers. Is there a way to find out the login that was used for > egas\David to get in (CURRENT_USER returns egas\David, I want > egas\BillingUsers)? > > > -- -Francisco From davide at dalyn.co.nz Thu Jul 1 18:47:45 2004 From: davide at dalyn.co.nz (David Emerson) Date: Fri, 02 Jul 2004 11:47:45 +1200 Subject: [dba-SQLServer] Alternative Front Ends Message-ID: <5.2.0.9.0.20040702114503.00b46308@mail.dalyn.co.nz> Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 From kens.programming at verizon.net Thu Jul 1 19:04:50 2004 From: kens.programming at verizon.net (Ken Stoker) Date: Thu, 1 Jul 2004 17:04:50 -0700 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <40E49ADB.2020109@verizon.net> Message-ID: <20040702000435.IMFA18566.out011.verizon.net@enterprise> Could you use something like this? select sg.name from sysusers su inner join sysmembers sm on su.uid = sm.memberuid inner join sysusers sg on sm.groupuid = sg.uid where su.name = current_user When I run this, it returns all the groups that a particular user is a member of. Ken -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco H Tapia Sent: Thursday, July 01, 2004 4:15 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Finding current login group sp_who returns domain and userid not the usergroup, and in fact I don't know how to get he usergroup name within a sproc, but one workaround is to create seperate functions and assign them rights based on the NT groups, you can have the sprocs return some type of value based on their usergroup name and this will provide you with the info you are seeking. Jeff Barrows wrote On 7/1/2004 3:44 PM: >Have you tried: EXECUTE sp_who in the SQL Query Analyser? > > -----Original Message----- > From: David Emerson [mailto:davide at dalyn.co.nz] > Sent: Thu 7/1/2004 5:11 PM > To: dba-SQLServer at databaseadvisors.com > Cc: > Subject: [dba-SQLServer] Finding current login group > > > > SQL2000 > > I am using Windows Authentication. I have set up Windows groups that users > belong to. These groups are set up in SQL as logins (this means that new > users just need to be added to the windows group to be given access to all > the databases with permissions for the group). > > Within my ADP I need to find out what login the user has accessed the SQL > database from so that I can show/hide controls etc. However, when I use > the CURRENT_USER variable in a Sproc it returns the user, not the group > they have come in by. > > EG - egas\David is a member of egas\BillingUsers Group. egas\BillingUsers > is set up as a login in SQL (egas\David is not). When egas\David is using > a database he has accessed it because he is a member of > egas\BillingUsers. Is there a way to find out the login that was used for > egas\David to get in (CURRENT_USER returns egas\David, I want > egas\BillingUsers)? > > > -- -Francisco _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From accessd at shaw.ca Thu Jul 1 22:20:13 2004 From: accessd at shaw.ca (Jim Lawrence (AccessD)) Date: Thu, 01 Jul 2004 20:20:13 -0700 Subject: [dba-SQLServer] Alternative Front Ends In-Reply-To: <5.2.0.9.0.20040702114503.00b46308@mail.dalyn.co.nz> Message-ID: Hi David: There are FEs that are designed to handle more clients like web based ones. There is a trade off as they are slower and do not have as many features. The new vb.net have the capability to be the FE, data web connection and sever side database interface. I have not actually created an applications with the product yet but if it lives up to current billing... An Access FE will work with hundreds of customers. The main issue is what type of BE do you have. It would have to be a SQL DB; SQL2000, Oracle, MySQL etc. on a server or severs of significant power, depending on the application. That volume of data is far beyond an Access MDB. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 4:48 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From Jeff at OUTBAKTech.com Thu Jul 1 23:26:33 2004 From: Jeff at OUTBAKTech.com (Jeff Barrows) Date: Thu, 1 Jul 2004 23:26:33 -0500 Subject: [dba-SQLServer] Finding current login group Message-ID: <8DA8776D2F418E46A2A464AC6CE63050032695@outbaksrv1.outbaktech.com> Actually, since David stated that he has added the usergroup as an SQL Server user, the sp_who should work for him sp_who provides information about current Microsoft? SQL Server? users and processes (SQL Server Books Online) -----Original Message----- From: Francisco H Tapia [mailto:my.lists at verizon.net] Sent: Thu 7/1/2004 6:14 PM To: dba-sqlserver at databaseadvisors.com Cc: Subject: Re: [dba-SQLServer] Finding current login group sp_who returns domain and userid not the usergroup, and in fact I don't know how to get he usergroup name within a sproc, but one workaround is to create seperate functions and assign them rights based on the NT groups, you can have the sprocs return some type of value based on their usergroup name and this will provide you with the info you are seeking. Jeff Barrows wrote On 7/1/2004 3:44 PM: >Have you tried: EXECUTE sp_who in the SQL Query Analyser? > > -----Original Message----- > From: David Emerson [mailto:davide at dalyn.co.nz] > Sent: Thu 7/1/2004 5:11 PM > To: dba-SQLServer at databaseadvisors.com > Cc: > Subject: [dba-SQLServer] Finding current login group > > > > SQL2000 > > I am using Windows Authentication. I have set up Windows groups that users > belong to. These groups are set up in SQL as logins (this means that new > users just need to be added to the windows group to be given access to all > the databases with permissions for the group). > > Within my ADP I need to find out what login the user has accessed the SQL > database from so that I can show/hide controls etc. However, when I use > the CURRENT_USER variable in a Sproc it returns the user, not the group > they have come in by. > > EG - egas\David is a member of egas\BillingUsers Group. egas\BillingUsers > is set up as a login in SQL (egas\David is not). When egas\David is using > a database he has accessed it because he is a member of > egas\BillingUsers. Is there a way to find out the login that was used for > egas\David to get in (CURRENT_USER returns egas\David, I want > egas\BillingUsers)? > > > -- -Francisco _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From michael.broesdorf at web.de Fri Jul 2 07:50:10 2004 From: michael.broesdorf at web.de (=?utf-8?Q?Michael_Br=C3=B6sdorf?=) Date: Fri, 2 Jul 2004 14:50:10 +0200 Subject: [dba-SQLServer] #Deleted-Problem (Cross-posted) In-Reply-To: <8DA8776D2F418E46A2A464AC6CE63050032695@outbaksrv1.outbaktech.com> Message-ID: Dear group, I have a problem with my Access2000-App. The Backend is SQL Server 2000 A bound form is linked to Table A. Table A has an insert-trigger, that creates a record in table B. Both tables have an ID-Field (A_ID and B_ID). Whenever I save a new record in the bound form, it either immediately displays #Deleted# in every field, or displays an old record(!). However, the new record is created correctly. There's a knowledgebase article, describing that problem. It states, that Access tries to re-select the new record using the ID value. It looks like that it is using the ID-value of table B instead that of table A to do the re-select. If it finds a record with that ID it displays that in the new row on the bound form. If it does not find it, the form displays #Deleted#. Is there any way to tell the trigger on table A not to return the ID of the new record in table B? Michael From michael.broesdorf at web.de Fri Jul 2 08:24:44 2004 From: michael.broesdorf at web.de (=?utf-8?Q?Michael_Br=C3=B6sdorf?=) Date: Fri, 2 Jul 2004 15:24:44 +0200 Subject: Updated: [dba-SQLServer] #Deleted-Problem (Cross-posted) In-Reply-To: Message-ID: Using SQL Profiler I found that Access indeed uses 'SELECT @@IDENTITY' to get the ID of the newly inserted record. Unfortunately this will return the new ID-value from table B. Using Scope_Identity could solve the problem. Is there a way to tell Access or the ODBC-Driver to use Scope_Identity instead of @@INSERTED? Michael -----Urspr?ngliche Nachricht----- Von: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]Im Auftrag von Michael Br?sdorf Gesendet: Freitag, 2. Juli 2004 14:50 An: dba-sqlserver at databaseadvisors.com Betreff: [dba-SQLServer] #Deleted-Problem (Cross-posted) Dear group, I have a problem with my Access2000-App. The Backend is SQL Server 2000 A bound form is linked to Table A. Table A has an insert-trigger, that creates a record in table B. Both tables have an ID-Field (A_ID and B_ID). Whenever I save a new record in the bound form, it either immediately displays #Deleted# in every field, or displays an old record(!). However, the new record is created correctly. There's a knowledgebase article, describing that problem. It states, that Access tries to re-select the new record using the ID value. It looks like that it is using the ID-value of table B instead that of table A to do the re-select. If it finds a record with that ID it displays that in the new row on the bound form. If it does not find it, the form displays #Deleted#. Is there any way to tell the trigger on table A not to return the ID of the new record in table B? Michael _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From artful at rogers.com Fri Jul 2 10:03:48 2004 From: artful at rogers.com (Arthur Fuller) Date: Fri, 2 Jul 2004 11:03:48 -0400 Subject: [dba-SQLServer] Alternative Front Ends In-Reply-To: Message-ID: <002d01c46045$c7378150$6601a8c0@rock> I have an ADP that hits a SQL database with approximately 50K customers, most of which have only a few orders, while most of the orders have about 5 details. No problems. Granted, I rely heavily on sprocs to deliver the data, as well as what I call the Sally Rand principle. (Sally was a famous stripper way back when, who coined the phrase, "Show them just enough to maintain their interest." I try to emulate that principle in my designs. I.e., I show one form displaying only a list of company names; select one and then I make visible the subform that shows the details of said customer. Many examples like this; the point is, read in as little data as possible, then wait for a user action.) Strictly for testing purposes, I have created a db called BIG that contains 1M parent rows, 10M child rows and 100M grandchild rows. Relationships are declared and autoForm was used to generate the forms that talk to these tables. I then modified the parent form to include a "finder" on the header that accepts a few letters of the company name, then executes a sproc that performs a LIKE command. The performance is excellent. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence (AccessD) Sent: Thursday, July 01, 2004 11:20 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Hi David: There are FEs that are designed to handle more clients like web based ones. There is a trade off as they are slower and do not have as many features. The new vb.net have the capability to be the FE, data web connection and sever side database interface. I have not actually created an applications with the product yet but if it lives up to current billing... An Access FE will work with hundreds of customers. The main issue is what type of BE do you have. It would have to be a SQL DB; SQL2000, Oracle, MySQL etc. on a server or severs of significant power, depending on the application. That volume of data is far beyond an Access MDB. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 4:48 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From artful at rogers.com Fri Jul 2 10:05:12 2004 From: artful at rogers.com (Arthur Fuller) Date: Fri, 2 Jul 2004 11:05:12 -0400 Subject: Updated: [dba-SQLServer] #Deleted-Problem (Cross-posted) In-Reply-To: Message-ID: <002e01c46045$f967dd00$6601a8c0@rock> A simple fix for this problem is to requery the form after the insert. HTH, Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Michael Br?sdorf Sent: Friday, July 02, 2004 9:25 AM To: dba-sqlserver at databaseadvisors.com Subject: Updated: [dba-SQLServer] #Deleted-Problem (Cross-posted) Using SQL Profiler I found that Access indeed uses 'SELECT @@IDENTITY' to get the ID of the newly inserted record. Unfortunately this will return the new ID-value from table B. Using Scope_Identity could solve the problem. Is there a way to tell Access or the ODBC-Driver to use Scope_Identity instead of @@INSERTED? Michael -----Urspr?ngliche Nachricht----- Von: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]Im Auftrag von Michael Br?sdorf Gesendet: Freitag, 2. Juli 2004 14:50 An: dba-sqlserver at databaseadvisors.com Betreff: [dba-SQLServer] #Deleted-Problem (Cross-posted) Dear group, I have a problem with my Access2000-App. The Backend is SQL Server 2000 A bound form is linked to Table A. Table A has an insert-trigger, that creates a record in table B. Both tables have an ID-Field (A_ID and B_ID). Whenever I save a new record in the bound form, it either immediately displays #Deleted# in every field, or displays an old record(!). However, the new record is created correctly. There's a knowledgebase article, describing that problem. It states, that Access tries to re-select the new record using the ID value. It looks like that it is using the ID-value of table B instead that of table A to do the re-select. If it finds a record with that ID it displays that in the new row on the bound form. If it does not find it, the form displays #Deleted#. Is there any way to tell the trigger on table A not to return the ID of the new record in table B? Michael _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From knicholson at gpsx.net Fri Jul 2 10:08:57 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Fri, 2 Jul 2004 11:08:57 -0400 Subject: [dba-SQLServer] Alternative Front Ends Message-ID: <74169B16EF9024458197A72AF4643B74045D4666@agoc-pabu-16.agoc_nt5.agoc.com> A Stripper? Your programming theory is based on a stripper? This is great news, not the stripper, the performance. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Friday, July 02, 2004 11:04 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends I have an ADP that hits a SQL database with approximately 50K customers, most of which have only a few orders, while most of the orders have about 5 details. No problems. Granted, I rely heavily on sprocs to deliver the data, as well as what I call the Sally Rand principle. (Sally was a famous stripper way back when, who coined the phrase, "Show them just enough to maintain their interest." I try to emulate that principle in my designs. I.e., I show one form displaying only a list of company names; select one and then I make visible the subform that shows the details of said customer. Many examples like this; the point is, read in as little data as possible, then wait for a user action.) Strictly for testing purposes, I have created a db called BIG that contains 1M parent rows, 10M child rows and 100M grandchild rows. Relationships are declared and autoForm was used to generate the forms that talk to these tables. I then modified the parent form to include a "finder" on the header that accepts a few letters of the company name, then executes a sproc that performs a LIKE command. The performance is excellent. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence (AccessD) Sent: Thursday, July 01, 2004 11:20 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Hi David: There are FEs that are designed to handle more clients like web based ones. There is a trade off as they are slower and do not have as many features. The new vb.net have the capability to be the FE, data web connection and sever side database interface. I have not actually created an applications with the product yet but if it lives up to current billing... An Access FE will work with hundreds of customers. The main issue is what type of BE do you have. It would have to be a SQL DB; SQL2000, Oracle, MySQL etc. on a server or severs of significant power, depending on the application. That volume of data is far beyond an Access MDB. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 4:48 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From michael.broesdorf at web.de Fri Jul 2 10:30:23 2004 From: michael.broesdorf at web.de (=?iso-8859-1?Q?Michael_Br=F6sdorf?=) Date: Fri, 2 Jul 2004 17:30:23 +0200 Subject: AW: Updated: [dba-SQLServer] #Deleted-Problem (Cross-posted) In-Reply-To: <002e01c46045$f967dd00$6601a8c0@rock> Message-ID: But that 'moves' the cursor to the first record. I would need to find out how the user navigated out of the new record (using the up/down-arrow-keys or by pressing enter etc.) Plus, I don't know the ID of the new record so I don't even have a starting point?? Right now I am willing to go for an unbound form with a grid control (which gives me better control of what is going on anyway...) Looks like a loooong weekend of coding... :-( Michael -----Urspr?ngliche Nachricht----- Von: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]Im Auftrag von Arthur Fuller Gesendet: Freitag, 2. Juli 2004 17:05 An: dba-sqlserver at databaseadvisors.com Betreff: RE: Updated: [dba-SQLServer] #Deleted-Problem (Cross-posted) A simple fix for this problem is to requery the form after the insert. HTH, Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Michael Br?sdorf Sent: Friday, July 02, 2004 9:25 AM To: dba-sqlserver at databaseadvisors.com Subject: Updated: [dba-SQLServer] #Deleted-Problem (Cross-posted) Using SQL Profiler I found that Access indeed uses 'SELECT @@IDENTITY' to get the ID of the newly inserted record. Unfortunately this will return the new ID-value from table B. Using Scope_Identity could solve the problem. Is there a way to tell Access or the ODBC-Driver to use Scope_Identity instead of @@INSERTED? Michael -----Urspr?ngliche Nachricht----- Von: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]Im Auftrag von Michael Br?sdorf Gesendet: Freitag, 2. Juli 2004 14:50 An: dba-sqlserver at databaseadvisors.com Betreff: [dba-SQLServer] #Deleted-Problem (Cross-posted) Dear group, I have a problem with my Access2000-App. The Backend is SQL Server 2000 A bound form is linked to Table A. Table A has an insert-trigger, that creates a record in table B. Both tables have an ID-Field (A_ID and B_ID). Whenever I save a new record in the bound form, it either immediately displays #Deleted# in every field, or displays an old record(!). However, the new record is created correctly. There's a knowledgebase article, describing that problem. It states, that Access tries to re-select the new record using the ID value. It looks like that it is using the ID-value of table B instead that of table A to do the re-select. If it finds a record with that ID it displays that in the new row on the bound form. If it does not find it, the form displays #Deleted#. Is there any way to tell the trigger on table A not to return the ID of the new record in table B? Michael _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From artful at rogers.com Fri Jul 2 10:28:42 2004 From: artful at rogers.com (Arthur Fuller) Date: Fri, 2 Jul 2004 11:28:42 -0400 Subject: [dba-SQLServer] Alternative Front Ends In-Reply-To: <74169B16EF9024458197A72AF4643B74045D4666@agoc-pabu-16.agoc_nt5.agoc.com> Message-ID: <003901c46049$41e0b0e0$6601a8c0@rock> You should see my demos! :) -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Nicholson, Karen Sent: Friday, July 02, 2004 11:09 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends A Stripper? Your programming theory is based on a stripper? This is great news, not the stripper, the performance. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Friday, July 02, 2004 11:04 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends I have an ADP that hits a SQL database with approximately 50K customers, most of which have only a few orders, while most of the orders have about 5 details. No problems. Granted, I rely heavily on sprocs to deliver the data, as well as what I call the Sally Rand principle. (Sally was a famous stripper way back when, who coined the phrase, "Show them just enough to maintain their interest." I try to emulate that principle in my designs. I.e., I show one form displaying only a list of company names; select one and then I make visible the subform that shows the details of said customer. Many examples like this; the point is, read in as little data as possible, then wait for a user action.) Strictly for testing purposes, I have created a db called BIG that contains 1M parent rows, 10M child rows and 100M grandchild rows. Relationships are declared and autoForm was used to generate the forms that talk to these tables. I then modified the parent form to include a "finder" on the header that accepts a few letters of the company name, then executes a sproc that performs a LIKE command. The performance is excellent. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence (AccessD) Sent: Thursday, July 01, 2004 11:20 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Hi David: There are FEs that are designed to handle more clients like web based ones. There is a trade off as they are slower and do not have as many features. The new vb.net have the capability to be the FE, data web connection and sever side database interface. I have not actually created an applications with the product yet but if it lives up to current billing... An Access FE will work with hundreds of customers. The main issue is what type of BE do you have. It would have to be a SQL DB; SQL2000, Oracle, MySQL etc. on a server or severs of significant power, depending on the application. That volume of data is far beyond an Access MDB. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 4:48 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From knicholson at gpsx.net Fri Jul 2 10:54:16 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Fri, 2 Jul 2004 11:54:16 -0400 Subject: [dba-SQLServer] Alternative Front Ends Message-ID: <74169B16EF9024458197A72AF4643B74045D46B4@agoc-pabu-16.agoc_nt5.agoc.com> Do you have a webcam? -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Friday, July 02, 2004 11:29 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends You should see my demos! :) -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Nicholson, Karen Sent: Friday, July 02, 2004 11:09 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends A Stripper? Your programming theory is based on a stripper? This is great news, not the stripper, the performance. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Friday, July 02, 2004 11:04 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends I have an ADP that hits a SQL database with approximately 50K customers, most of which have only a few orders, while most of the orders have about 5 details. No problems. Granted, I rely heavily on sprocs to deliver the data, as well as what I call the Sally Rand principle. (Sally was a famous stripper way back when, who coined the phrase, "Show them just enough to maintain their interest." I try to emulate that principle in my designs. I.e., I show one form displaying only a list of company names; select one and then I make visible the subform that shows the details of said customer. Many examples like this; the point is, read in as little data as possible, then wait for a user action.) Strictly for testing purposes, I have created a db called BIG that contains 1M parent rows, 10M child rows and 100M grandchild rows. Relationships are declared and autoForm was used to generate the forms that talk to these tables. I then modified the parent form to include a "finder" on the header that accepts a few letters of the company name, then executes a sproc that performs a LIKE command. The performance is excellent. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence (AccessD) Sent: Thursday, July 01, 2004 11:20 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Hi David: There are FEs that are designed to handle more clients like web based ones. There is a trade off as they are slower and do not have as many features. The new vb.net have the capability to be the FE, data web connection and sever side database interface. I have not actually created an applications with the product yet but if it lives up to current billing... An Access FE will work with hundreds of customers. The main issue is what type of BE do you have. It would have to be a SQL DB; SQL2000, Oracle, MySQL etc. on a server or severs of significant power, depending on the application. That volume of data is far beyond an Access MDB. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 4:48 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From cfoust at infostatsystems.com Fri Jul 2 11:05:58 2004 From: cfoust at infostatsystems.com (Charlotte Foust) Date: Fri, 2 Jul 2004 09:05:58 -0700 Subject: [dba-SQLServer] Alternative Front Ends Message-ID: Complete with ostrich feather fans? Sally Rand was a fan dancer, not a stripper. Charlotte Foust -----Original Message----- From: Arthur Fuller [mailto:artful at rogers.com] Sent: Friday, July 02, 2004 7:29 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends You should see my demos! :) -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Nicholson, Karen Sent: Friday, July 02, 2004 11:09 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends A Stripper? Your programming theory is based on a stripper? This is great news, not the stripper, the performance. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Friday, July 02, 2004 11:04 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends I have an ADP that hits a SQL database with approximately 50K customers, most of which have only a few orders, while most of the orders have about 5 details. No problems. Granted, I rely heavily on sprocs to deliver the data, as well as what I call the Sally Rand principle. (Sally was a famous stripper way back when, who coined the phrase, "Show them just enough to maintain their interest." I try to emulate that principle in my designs. I.e., I show one form displaying only a list of company names; select one and then I make visible the subform that shows the details of said customer. Many examples like this; the point is, read in as little data as possible, then wait for a user action.) Strictly for testing purposes, I have created a db called BIG that contains 1M parent rows, 10M child rows and 100M grandchild rows. Relationships are declared and autoForm was used to generate the forms that talk to these tables. I then modified the parent form to include a "finder" on the header that accepts a few letters of the company name, then executes a sproc that performs a LIKE command. The performance is excellent. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence (AccessD) Sent: Thursday, July 01, 2004 11:20 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Hi David: There are FEs that are designed to handle more clients like web based ones. There is a trade off as they are slower and do not have as many features. The new vb.net have the capability to be the FE, data web connection and sever side database interface. I have not actually created an applications with the product yet but if it lives up to current billing... An Access FE will work with hundreds of customers. The main issue is what type of BE do you have. It would have to be a SQL DB; SQL2000, Oracle, MySQL etc. on a server or severs of significant power, depending on the application. That volume of data is far beyond an Access MDB. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 4:48 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From knicholson at gpsx.net Fri Jul 2 11:24:29 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Fri, 2 Jul 2004 12:24:29 -0400 Subject: [dba-SQLServer] Alternative Front Ends Message-ID: <74169B16EF9024458197A72AF4643B74045D46E0@agoc-pabu-16.agoc_nt5.agoc.com> You have to google her. She did a wardrobe malfunction in 1933 or something like that at the World's Fair. Arthur is showing his age. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Charlotte Foust Sent: Friday, July 02, 2004 12:06 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Complete with ostrich feather fans? Sally Rand was a fan dancer, not a stripper. Charlotte Foust -----Original Message----- From: Arthur Fuller [mailto:artful at rogers.com] Sent: Friday, July 02, 2004 7:29 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends You should see my demos! :) -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Nicholson, Karen Sent: Friday, July 02, 2004 11:09 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends A Stripper? Your programming theory is based on a stripper? This is great news, not the stripper, the performance. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Friday, July 02, 2004 11:04 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends I have an ADP that hits a SQL database with approximately 50K customers, most of which have only a few orders, while most of the orders have about 5 details. No problems. Granted, I rely heavily on sprocs to deliver the data, as well as what I call the Sally Rand principle. (Sally was a famous stripper way back when, who coined the phrase, "Show them just enough to maintain their interest." I try to emulate that principle in my designs. I.e., I show one form displaying only a list of company names; select one and then I make visible the subform that shows the details of said customer. Many examples like this; the point is, read in as little data as possible, then wait for a user action.) Strictly for testing purposes, I have created a db called BIG that contains 1M parent rows, 10M child rows and 100M grandchild rows. Relationships are declared and autoForm was used to generate the forms that talk to these tables. I then modified the parent form to include a "finder" on the header that accepts a few letters of the company name, then executes a sproc that performs a LIKE command. The performance is excellent. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence (AccessD) Sent: Thursday, July 01, 2004 11:20 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Hi David: There are FEs that are designed to handle more clients like web based ones. There is a trade off as they are slower and do not have as many features. The new vb.net have the capability to be the FE, data web connection and sever side database interface. I have not actually created an applications with the product yet but if it lives up to current billing... An Access FE will work with hundreds of customers. The main issue is what type of BE do you have. It would have to be a SQL DB; SQL2000, Oracle, MySQL etc. on a server or severs of significant power, depending on the application. That volume of data is far beyond an Access MDB. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 4:48 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From CMackin at Quiznos.com Thu Jul 1 18:53:41 2004 From: CMackin at Quiznos.com (Mackin, Christopher) Date: Thu, 1 Jul 2004 17:53:41 -0600 Subject: Spam: [dba-SQLServer] Alternative Front Ends Message-ID: It's not the .adp that has to deal with the 200,000 customers, it's the SQL Server, assuming you've set it up with each user with their own copy of the FE there is no issue. The issue that is critical is making sure you're Back End design and implementation is rock solid. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 5:48 PM To: dba-SQLServer at databaseadvisors.com Subject: Spam: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Fri Jul 2 16:28:48 2004 From: davide at dalyn.co.nz (David Emerson) Date: Sat, 03 Jul 2004 09:28:48 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <8DA8776D2F418E46A2A464AC6CE63050032692@outbaksrv1.outbakte ch.com> Message-ID: <5.2.0.9.0.20040703092804.00b3fd20@mail.dalyn.co.nz> I tried this but still got egas\David rather than the group he belongs to. David At 1/07/2004, you wrote: >Have you tried: EXECUTE sp_who in the SQL Query Analyser? > > -----Original Message----- > From: David Emerson [mailto:davide at dalyn.co.nz] > Sent: Thu 7/1/2004 5:11 PM > To: dba-SQLServer at databaseadvisors.com > Cc: > Subject: [dba-SQLServer] Finding current login group > > > > SQL2000 > > I am using Windows Authentication. I have set up Windows groups > that users > belong to. These groups are set up in SQL as logins (this means > that new > users just need to be added to the windows group to be given > access to all > the databases with permissions for the group). > > Within my ADP I need to find out what login the user has accessed > the SQL > database from so that I can show/hide controls etc. However, > when I use > the CURRENT_USER variable in a Sproc it returns the user, not the > group > they have come in by. > > EG - egas\David is a member of egas\BillingUsers > Group. egas\BillingUsers > is set up as a login in SQL (egas\David is not). When egas\David > is using > a database he has accessed it because he is a member of > egas\BillingUsers. Is there a way to find out the login that was > used for > egas\David to get in (CURRENT_USER returns egas\David, I want > egas\BillingUsers)? > > Regards > > David Emerson > Dalyn Software Ltd > 25 Cunliffe St, Churton Park > Wellington, New Zealand > Ph/Fax (04) 478-7456 > Mobile 027-280-9348 > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From davide at dalyn.co.nz Fri Jul 2 16:13:00 2004 From: davide at dalyn.co.nz (David Emerson) Date: Sat, 03 Jul 2004 09:13:00 +1200 Subject: [dba-SQLServer] Alternative Front Ends In-Reply-To: <5.2.0.9.0.20040702114503.00b46308@mail.dalyn.co.nz> Message-ID: <5.2.0.9.0.20040703091232.00b2bc90@mail.dalyn.co.nz> Thanks everyone for the feedback. David At 2/07/2004, you wrote: >Group, > >A company I am contracting to what to know if there are any "higher" >alternatives to Access adp's. They are concerned that Access may not be >powerful enough to handle databases with monthly accounts for say 200,000 >customers. > >Any comments? > >Regards > >David Emerson >Dalyn Software Ltd >25 Cunliffe St, Churton Park >Wellington, New Zealand >Ph/Fax (04) 478-7456 >Mobile 027-280-9348 >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > From davide at dalyn.co.nz Fri Jul 2 16:48:19 2004 From: davide at dalyn.co.nz (David Emerson) Date: Sat, 03 Jul 2004 09:48:19 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <20040702000435.IMFA18566.out011.verizon.net@enterprise> References: <40E49ADB.2020109@verizon.net> Message-ID: <5.2.0.9.0.20040703093031.00b98bf8@mail.dalyn.co.nz> Ken, Current_user gives me the name of the user (egas\David), not the group that that they were logged in as (egas\BillingUsers). David At 1/07/2004, you wrote: >Could you use something like this? > >select sg.name >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid > inner join sysusers sg on sm.groupuid = sg.uid >where su.name = current_user > >When I run this, it returns all the groups that a particular user is a >member of. > >Ken > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco H >Tapia >Sent: Thursday, July 01, 2004 4:15 PM >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] Finding current login group > >sp_who returns domain and userid not the usergroup, and in fact I don't >know how to get he usergroup name within a sproc, but one workaround is >to create seperate functions and assign them rights based on the NT >groups, you can have the sprocs return some type of value based on their >usergroup name and this will provide you with the info you are seeking. > > >Jeff Barrows wrote On 7/1/2004 3:44 PM: > > >Have you tried: EXECUTE sp_who in the SQL Query Analyser? > > > > -----Original Message----- > > From: David Emerson [mailto:davide at dalyn.co.nz] > > Sent: Thu 7/1/2004 5:11 PM > > To: dba-SQLServer at databaseadvisors.com > > Cc: > > Subject: [dba-SQLServer] Finding current login group > > > > > > > > SQL2000 > > > > I am using Windows Authentication. I have set up Windows groups >that users > > belong to. These groups are set up in SQL as logins (this means >that new > > users just need to be added to the windows group to be given access >to all > > the databases with permissions for the group). > > > > Within my ADP I need to find out what login the user has accessed >the SQL > > database from so that I can show/hide controls etc. However, when I >use > > the CURRENT_USER variable in a Sproc it returns the user, not the >group > > they have come in by. > > > > EG - egas\David is a member of egas\BillingUsers Group. >egas\BillingUsers > > is set up as a login in SQL (egas\David is not). When egas\David is >using > > a database he has accessed it because he is a member of > > egas\BillingUsers. Is there a way to find out the login that was >used for > > egas\David to get in (CURRENT_USER returns egas\David, I want > > egas\BillingUsers)? From kens.programming at verizon.net Fri Jul 2 19:50:34 2004 From: kens.programming at verizon.net (Ken Stoker) Date: Fri, 2 Jul 2004 17:50:34 -0700 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <5.2.0.9.0.20040703093031.00b98bf8@mail.dalyn.co.nz> Message-ID: <20040703005017.FVVQ28276.out007.verizon.net@enterprise> David, Yes, but that is only the criteria for the query. By joining sysusers to sysmembers, once to represent users and a second time to represent roles, you can determine which roles a user belongs to, which may be one or many, I don't know how you managed that. Ken -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Friday, July 02, 2004 2:48 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Finding current login group Ken, Current_user gives me the name of the user (egas\David), not the group that that they were logged in as (egas\BillingUsers). David At 1/07/2004, you wrote: >Could you use something like this? > >select sg.name >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid > inner join sysusers sg on sm.groupuid = sg.uid >where su.name = current_user > >When I run this, it returns all the groups that a particular user is a >member of. > >Ken > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco H >Tapia >Sent: Thursday, July 01, 2004 4:15 PM >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] Finding current login group > >sp_who returns domain and userid not the usergroup, and in fact I don't >know how to get he usergroup name within a sproc, but one workaround is >to create seperate functions and assign them rights based on the NT >groups, you can have the sprocs return some type of value based on their >usergroup name and this will provide you with the info you are seeking. > > >Jeff Barrows wrote On 7/1/2004 3:44 PM: > > >Have you tried: EXECUTE sp_who in the SQL Query Analyser? > > > > -----Original Message----- > > From: David Emerson [mailto:davide at dalyn.co.nz] > > Sent: Thu 7/1/2004 5:11 PM > > To: dba-SQLServer at databaseadvisors.com > > Cc: > > Subject: [dba-SQLServer] Finding current login group > > > > > > > > SQL2000 > > > > I am using Windows Authentication. I have set up Windows groups >that users > > belong to. These groups are set up in SQL as logins (this means >that new > > users just need to be added to the windows group to be given access >to all > > the databases with permissions for the group). > > > > Within my ADP I need to find out what login the user has accessed >the SQL > > database from so that I can show/hide controls etc. However, when I >use > > the CURRENT_USER variable in a Sproc it returns the user, not the >group > > they have come in by. > > > > EG - egas\David is a member of egas\BillingUsers Group. >egas\BillingUsers > > is set up as a login in SQL (egas\David is not). When egas\David is >using > > a database he has accessed it because he is a member of > > egas\BillingUsers. Is there a way to find out the login that was >used for > > egas\David to get in (CURRENT_USER returns egas\David, I want > > egas\BillingUsers)? _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Fri Jul 2 21:34:45 2004 From: davide at dalyn.co.nz (David Emerson) Date: Sat, 03 Jul 2004 14:34:45 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <20040703005017.FVVQ28276.out007.verizon.net@enterprise> References: <5.2.0.9.0.20040703093031.00b98bf8@mail.dalyn.co.nz> Message-ID: <5.2.0.9.0.20040703142940.00b2b420@mail.dalyn.co.nz> Ken, The problem is that while egas\David is the windows login for the user, the SQL login is egas\BillingUsers. That is, the user accessed SQL because he is a member of egas\BillingUsers. egas\David is not a login in SQL. Because egas\David is not in sysusers there is no match with Current_User (which returns the windows login, not the SQL login). David At 2/07/2004, you wrote: >David, > >Yes, but that is only the criteria for the query. By joining sysusers to >sysmembers, once to represent users and a second time to represent roles, >you can determine which roles a user belongs to, which may be one or many, I >don't know how you managed that. > >Ken > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >Emerson >Sent: Friday, July 02, 2004 2:48 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Finding current login group > >Ken, > >Current_user gives me the name of the user (egas\David), not the group that >that they were logged in as (egas\BillingUsers). > >David > >At 1/07/2004, you wrote: > >Could you use something like this? > > > >select sg.name > >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid > > inner join sysusers sg on sm.groupuid = sg.uid > >where su.name = current_user > > > >When I run this, it returns all the groups that a particular user is a > >member of. > > > >Ken > > > >-----Original Message----- > >From: dba-sqlserver-bounces at databaseadvisors.com > >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco >H > >Tapia > >Sent: Thursday, July 01, 2004 4:15 PM > >To: dba-sqlserver at databaseadvisors.com > >Subject: Re: [dba-SQLServer] Finding current login group > > > >sp_who returns domain and userid not the usergroup, and in fact I don't > >know how to get he usergroup name within a sproc, but one workaround is > >to create seperate functions and assign them rights based on the NT > >groups, you can have the sprocs return some type of value based on their > >usergroup name and this will provide you with the info you are seeking. > > > > > >Jeff Barrows wrote On 7/1/2004 3:44 PM: > > > > >Have you tried: EXECUTE sp_who in the SQL Query Analyser? > > > > > > -----Original Message----- > > > From: David Emerson [mailto:davide at dalyn.co.nz] > > > Sent: Thu 7/1/2004 5:11 PM > > > To: dba-SQLServer at databaseadvisors.com > > > Cc: > > > Subject: [dba-SQLServer] Finding current login group > > > > > > > > > > > > SQL2000 > > > > > > I am using Windows Authentication. I have set up Windows groups > >that users > > > belong to. These groups are set up in SQL as logins (this means > >that new > > > users just need to be added to the windows group to be given >access > >to all > > > the databases with permissions for the group). > > > > > > Within my ADP I need to find out what login the user has accessed > >the SQL > > > database from so that I can show/hide controls etc. However, when >I > >use > > > the CURRENT_USER variable in a Sproc it returns the user, not the > >group > > > they have come in by. > > > > > > EG - egas\David is a member of egas\BillingUsers Group. > >egas\BillingUsers > > > is set up as a login in SQL (egas\David is not). When egas\David >is > >using > > > a database he has accessed it because he is a member of > > > egas\BillingUsers. Is there a way to find out the login that was > >used for > > > egas\David to get in (CURRENT_USER returns egas\David, I want > > > egas\BillingUsers)? > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From tuxedo_man at hotmail.com Sat Jul 3 04:31:35 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Sat, 03 Jul 2004 09:31:35 +0000 Subject: [dba-SQLServer] Finding current login group Message-ID: "permission path" column of xp_logininfo? see below.. /* -- cut here */ DECLARE @sys_usr varchar(100) SET @sys_usr = SYSTEM_USER SELECT @sys_usr EXEC xp_logininfo @sys_usr /* -- cut here */ HTH Billy >From: David Emerson >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Finding current login group >Date: Sat, 03 Jul 2004 14:34:45 +1200 > >Ken, > >The problem is that while egas\David is the windows login for the user, the >SQL login is egas\BillingUsers. That is, the user accessed SQL because he >is a member of egas\BillingUsers. egas\David is not a login in SQL. >Because egas\David is not in sysusers there is no match with Current_User >(which returns the windows login, not the SQL login). > >David > >At 2/07/2004, you wrote: >>David, >> >>Yes, but that is only the criteria for the query. By joining sysusers to >>sysmembers, once to represent users and a second time to represent roles, >>you can determine which roles a user belongs to, which may be one or many, >>I >>don't know how you managed that. >> >>Ken >> >>-----Original Message----- >>From: dba-sqlserver-bounces at databaseadvisors.com >>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>Emerson >>Sent: Friday, July 02, 2004 2:48 PM >>To: dba-sqlserver at databaseadvisors.com >>Subject: RE: [dba-SQLServer] Finding current login group >> >>Ken, >> >>Current_user gives me the name of the user (egas\David), not the group >>that >>that they were logged in as (egas\BillingUsers). >> >>David >> >>At 1/07/2004, you wrote: >> >Could you use something like this? >> > >> >select sg.name >> >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid >> > inner join sysusers sg on sm.groupuid = sg.uid >> >where su.name = current_user >> > >> >When I run this, it returns all the groups that a particular user is a >> >member of. >> > >> >Ken >> > >> >-----Original Message----- >> >From: dba-sqlserver-bounces at databaseadvisors.com >> >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of >>Francisco >>H >> >Tapia >> >Sent: Thursday, July 01, 2004 4:15 PM >> >To: dba-sqlserver at databaseadvisors.com >> >Subject: Re: [dba-SQLServer] Finding current login group >> > >> >sp_who returns domain and userid not the usergroup, and in fact I don't >> >know how to get he usergroup name within a sproc, but one workaround is >> >to create seperate functions and assign them rights based on the NT >> >groups, you can have the sprocs return some type of value based on their >> >usergroup name and this will provide you with the info you are seeking. >> > >> > >> >Jeff Barrows wrote On 7/1/2004 3:44 PM: >> > >> > >Have you tried: EXECUTE sp_who in the SQL Query Analyser? >> > > >> > > -----Original Message----- >> > > From: David Emerson [mailto:davide at dalyn.co.nz] >> > > Sent: Thu 7/1/2004 5:11 PM >> > > To: dba-SQLServer at databaseadvisors.com >> > > Cc: >> > > Subject: [dba-SQLServer] Finding current login group >> > > >> > > >> > > >> > > SQL2000 >> > > >> > > I am using Windows Authentication. I have set up Windows >>groups >> >that users >> > > belong to. These groups are set up in SQL as logins (this >>means >> >that new >> > > users just need to be added to the windows group to be given >>access >> >to all >> > > the databases with permissions for the group). >> > > >> > > Within my ADP I need to find out what login the user has >>accessed >> >the SQL >> > > database from so that I can show/hide controls etc. However, >>when >>I >> >use >> > > the CURRENT_USER variable in a Sproc it returns the user, not >>the >> >group >> > > they have come in by. >> > > >> > > EG - egas\David is a member of egas\BillingUsers Group. >> >egas\BillingUsers >> > > is set up as a login in SQL (egas\David is not). When >>egas\David >>is >> >using >> > > a database he has accessed it because he is a member of >> > > egas\BillingUsers. Is there a way to find out the login that >>was >> >used for >> > > egas\David to get in (CURRENT_USER returns egas\David, I want >> > > egas\BillingUsers)? >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com >> >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN Premium includes powerful parental controls and get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From davide at dalyn.co.nz Sun Jul 4 02:50:47 2004 From: davide at dalyn.co.nz (David Emerson) Date: Sun, 04 Jul 2004 19:50:47 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: Message-ID: <5.2.0.9.0.20040704194713.00b2b5d0@mail.dalyn.co.nz> Tried running this in Query Analyzer. Received error - couldn't find xp_logininfo. What am I missing? David At 3/07/2004, you wrote: >"permission path" column of xp_logininfo? > >see below.. > >/* -- cut here */ >DECLARE @sys_usr varchar(100) >SET @sys_usr = SYSTEM_USER >SELECT @sys_usr >EXEC xp_logininfo @sys_usr >/* -- cut here */ > >HTH >Billy > > >>From: David Emerson >>Reply-To: dba-sqlserver at databaseadvisors.com >>To: dba-sqlserver at databaseadvisors.com >>Subject: RE: [dba-SQLServer] Finding current login group >>Date: Sat, 03 Jul 2004 14:34:45 +1200 >> >>Ken, >> >>The problem is that while egas\David is the windows login for the user, >>the SQL login is egas\BillingUsers. That is, the user accessed SQL >>because he is a member of egas\BillingUsers. egas\David is not a login >>in SQL. >>Because egas\David is not in sysusers there is no match with Current_User >>(which returns the windows login, not the SQL login). >> >>David >> >>At 2/07/2004, you wrote: >>>David, >>> >>>Yes, but that is only the criteria for the query. By joining sysusers to >>>sysmembers, once to represent users and a second time to represent roles, >>>you can determine which roles a user belongs to, which may be one or many, I >>>don't know how you managed that. >>> >>>Ken >>> >>>-----Original Message----- >>>From: dba-sqlserver-bounces at databaseadvisors.com >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>>Emerson >>>Sent: Friday, July 02, 2004 2:48 PM >>>To: dba-sqlserver at databaseadvisors.com >>>Subject: RE: [dba-SQLServer] Finding current login group >>> >>>Ken, >>> >>>Current_user gives me the name of the user (egas\David), not the group that >>>that they were logged in as (egas\BillingUsers). >>> >>>David >>> >>>At 1/07/2004, you wrote: >>> >Could you use something like this? >>> > >>> >select sg.name >>> >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid >>> > inner join sysusers sg on sm.groupuid = sg.uid >>> >where su.name = current_user >>> > >>> >When I run this, it returns all the groups that a particular user is a >>> >member of. >>> > >>> >Ken >>> > >>> >-----Original Message----- >>> >From: dba-sqlserver-bounces at databaseadvisors.com >>> >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco >>>H >>> >Tapia >>> >Sent: Thursday, July 01, 2004 4:15 PM >>> >To: dba-sqlserver at databaseadvisors.com >>> >Subject: Re: [dba-SQLServer] Finding current login group >>> > >>> >sp_who returns domain and userid not the usergroup, and in fact I don't >>> >know how to get he usergroup name within a sproc, but one workaround is >>> >to create seperate functions and assign them rights based on the NT >>> >groups, you can have the sprocs return some type of value based on their >>> >usergroup name and this will provide you with the info you are seeking. >>> > >>> > >>> >Jeff Barrows wrote On 7/1/2004 3:44 PM: >>> > >>> > >Have you tried: EXECUTE sp_who in the SQL Query Analyser? >>> > > >>> > > -----Original Message----- >>> > > From: David Emerson [mailto:davide at dalyn.co.nz] >>> > > Sent: Thu 7/1/2004 5:11 PM >>> > > To: dba-SQLServer at databaseadvisors.com >>> > > Cc: >>> > > Subject: [dba-SQLServer] Finding current login group >>> > > >>> > > >>> > > >>> > > SQL2000 >>> > > >>> > > I am using Windows Authentication. I have set up Windows groups >>> >that users >>> > > belong to. These groups are set up in SQL as logins (this means >>> >that new >>> > > users just need to be added to the windows group to be given >>>access >>> >to all >>> > > the databases with permissions for the group). >>> > > >>> > > Within my ADP I need to find out what login the user has accessed >>> >the SQL >>> > > database from so that I can show/hide controls etc. However, >>> when >>>I >>> >use >>> > > the CURRENT_USER variable in a Sproc it returns the user, not the >>> >group >>> > > they have come in by. >>> > > >>> > > EG - egas\David is a member of egas\BillingUsers Group. >>> >egas\BillingUsers >>> > > is set up as a login in SQL (egas\David is not). When egas\David >>>is >>> >using >>> > > a database he has accessed it because he is a member of >>> > > egas\BillingUsers. Is there a way to find out the login that was >>> >used for >>> > > egas\David to get in (CURRENT_USER returns egas\David, I want >>> > > egas\BillingUsers)? >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >>> >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com > >_________________________________________________________________ >MSN Premium includes powerful parental controls and get 2 months FREE* >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > From tuxedo_man at hotmail.com Sun Jul 4 03:25:21 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Sun, 04 Jul 2004 08:25:21 +0000 Subject: [dba-SQLServer] Finding current login group Message-ID: xp_logininfo sproc is in master db... so try... /* -- cut here */ DECLARE @sys_usr varchar(100) SET @sys_usr = SYSTEM_USER SELECT @sys_usr EXEC master..xp_logininfo @sys_usr /* -- cut here */ be aware of the execute permissions of this sproc...from bol, it reads: Execute permissions for xp_logininfo default to members of the db_owner fixed database role in the master database and members of the sysadmin fixed server role, but can be granted to other users. HTH Billy >From: David Emerson >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Finding current login group >Date: Sun, 04 Jul 2004 19:50:47 +1200 > >Tried running this in Query Analyzer. Received error - couldn't find >xp_logininfo. What am I missing? > >David > >At 3/07/2004, you wrote: >>"permission path" column of xp_logininfo? >> >>see below.. >> >>/* -- cut here */ >>DECLARE @sys_usr varchar(100) >>SET @sys_usr = SYSTEM_USER >>SELECT @sys_usr >>EXEC xp_logininfo @sys_usr >>/* -- cut here */ >> >>HTH >>Billy >> >> >>>From: David Emerson >>>Reply-To: dba-sqlserver at databaseadvisors.com >>>To: dba-sqlserver at databaseadvisors.com >>>Subject: RE: [dba-SQLServer] Finding current login group >>>Date: Sat, 03 Jul 2004 14:34:45 +1200 >>> >>>Ken, >>> >>>The problem is that while egas\David is the windows login for the user, >>>the SQL login is egas\BillingUsers. That is, the user accessed SQL >>>because he is a member of egas\BillingUsers. egas\David is not a login >>>in SQL. >>>Because egas\David is not in sysusers there is no match with Current_User >>>(which returns the windows login, not the SQL login). >>> >>>David >>> >>>At 2/07/2004, you wrote: >>>>David, >>>> >>>>Yes, but that is only the criteria for the query. By joining sysusers >>>>to >>>>sysmembers, once to represent users and a second time to represent >>>>roles, >>>>you can determine which roles a user belongs to, which may be one or >>>>many, I >>>>don't know how you managed that. >>>> >>>>Ken >>>> >>>>-----Original Message----- >>>>From: dba-sqlserver-bounces at databaseadvisors.com >>>>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>>>Emerson >>>>Sent: Friday, July 02, 2004 2:48 PM >>>>To: dba-sqlserver at databaseadvisors.com >>>>Subject: RE: [dba-SQLServer] Finding current login group >>>> >>>>Ken, >>>> >>>>Current_user gives me the name of the user (egas\David), not the group >>>>that >>>>that they were logged in as (egas\BillingUsers). >>>> >>>>David >>>> >>>>At 1/07/2004, you wrote: >>>> >Could you use something like this? >>>> > >>>> >select sg.name >>>> >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid >>>> > inner join sysusers sg on sm.groupuid = sg.uid >>>> >where su.name = current_user >>>> > >>>> >When I run this, it returns all the groups that a particular user is a >>>> >member of. >>>> > >>>> >Ken >>>> > >>>> >-----Original Message----- >>>> >From: dba-sqlserver-bounces at databaseadvisors.com >>>> >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of >>>>Francisco >>>>H >>>> >Tapia >>>> >Sent: Thursday, July 01, 2004 4:15 PM >>>> >To: dba-sqlserver at databaseadvisors.com >>>> >Subject: Re: [dba-SQLServer] Finding current login group >>>> > >>>> >sp_who returns domain and userid not the usergroup, and in fact I >>>>don't >>>> >know how to get he usergroup name within a sproc, but one workaround >>>>is >>>> >to create seperate functions and assign them rights based on the NT >>>> >groups, you can have the sprocs return some type of value based on >>>>their >>>> >usergroup name and this will provide you with the info you are >>>>seeking. >>>> > >>>> > >>>> >Jeff Barrows wrote On 7/1/2004 3:44 PM: >>>> > >>>> > >Have you tried: EXECUTE sp_who in the SQL Query Analyser? >>>> > > >>>> > > -----Original Message----- >>>> > > From: David Emerson [mailto:davide at dalyn.co.nz] >>>> > > Sent: Thu 7/1/2004 5:11 PM >>>> > > To: dba-SQLServer at databaseadvisors.com >>>> > > Cc: >>>> > > Subject: [dba-SQLServer] Finding current login group >>>> > > >>>> > > >>>> > > >>>> > > SQL2000 >>>> > > >>>> > > I am using Windows Authentication. I have set up Windows >>>>groups >>>> >that users >>>> > > belong to. These groups are set up in SQL as logins (this >>>>means >>>> >that new >>>> > > users just need to be added to the windows group to be given >>>>access >>>> >to all >>>> > > the databases with permissions for the group). >>>> > > >>>> > > Within my ADP I need to find out what login the user has >>>>accessed >>>> >the SQL >>>> > > database from so that I can show/hide controls etc. However, >>>>when >>>>I >>>> >use >>>> > > the CURRENT_USER variable in a Sproc it returns the user, not >>>>the >>>> >group >>>> > > they have come in by. >>>> > > >>>> > > EG - egas\David is a member of egas\BillingUsers Group. >>>> >egas\BillingUsers >>>> > > is set up as a login in SQL (egas\David is not). When >>>>egas\David >>>>is >>>> >using >>>> > > a database he has accessed it because he is a member of >>>> > > egas\BillingUsers. Is there a way to find out the login that >>>>was >>>> >used for >>>> > > egas\David to get in (CURRENT_USER returns egas\David, I want >>>> > > egas\BillingUsers)? >>>> >>>>_______________________________________________ >>>>dba-SQLServer mailing list >>>>dba-SQLServer at databaseadvisors.com >>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>http://www.databaseadvisors.com >>>> >>>> >>>>_______________________________________________ >>>>dba-SQLServer mailing list >>>>dba-SQLServer at databaseadvisors.com >>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>http://www.databaseadvisors.com >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >> >>_________________________________________________________________ >>MSN Premium includes powerful parental controls and get 2 months FREE* >>http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com >> >> > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Add photos to your e-mail with MSN Premium. Get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From davide at dalyn.co.nz Sun Jul 4 03:00:06 2004 From: davide at dalyn.co.nz (David Emerson) Date: Sun, 04 Jul 2004 20:00:06 +1200 Subject: [dba-SQLServer] Finding current login group Message-ID: <5.2.0.9.0.20040704195835.00b48140@mail.dalyn.co.nz> OK, I have found it referred to in BOL and found it in the Master database. I will need to go into the client's office to set the permissions to enable it to be run but I think we are getting somewhere. Thanks. David At 3/07/2004, you wrote: >"permission path" column of xp_logininfo? > >see below.. > >/* -- cut here */ >DECLARE @sys_usr varchar(100) >SET @sys_usr = SYSTEM_USER >SELECT @sys_usr >EXEC xp_logininfo @sys_usr >/* -- cut here */ > >HTH >Billy > > >>From: David Emerson >>Reply-To: dba-sqlserver at databaseadvisors.com >>To: dba-sqlserver at databaseadvisors.com >>Subject: RE: [dba-SQLServer] Finding current login group >>Date: Sat, 03 Jul 2004 14:34:45 +1200 >> >>Ken, >> >>The problem is that while egas\David is the windows login for the user, >>the SQL login is egas\BillingUsers. That is, the user accessed SQL >>because he is a member of egas\BillingUsers. egas\David is not a login >>in SQL. >>Because egas\David is not in sysusers there is no match with Current_User >>(which returns the windows login, not the SQL login). >> >>David >> >>At 2/07/2004, you wrote: >>>David, >>> >>>Yes, but that is only the criteria for the query. By joining sysusers to >>>sysmembers, once to represent users and a second time to represent roles, >>>you can determine which roles a user belongs to, which may be one or many, I >>>don't know how you managed that. >>> >>>Ken >>> >>>-----Original Message----- >>>From: dba-sqlserver-bounces at databaseadvisors.com >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>>Emerson >>>Sent: Friday, July 02, 2004 2:48 PM >>>To: dba-sqlserver at databaseadvisors.com >>>Subject: RE: [dba-SQLServer] Finding current login group >>> >>>Ken, >>> >>>Current_user gives me the name of the user (egas\David), not the group that >>>that they were logged in as (egas\BillingUsers). >>> >>>David >>> >>>At 1/07/2004, you wrote: >>> >Could you use something like this? >>> > >>> >select sg.name >>> >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid >>> > inner join sysusers sg on sm.groupuid = sg.uid >>> >where su.name = current_user >>> > >>> >When I run this, it returns all the groups that a particular user is a >>> >member of. >>> > >>> >Ken >>> > >>> >-----Original Message----- >>> >From: dba-sqlserver-bounces at databaseadvisors.com >>> >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco >>>H >>> >Tapia >>> >Sent: Thursday, July 01, 2004 4:15 PM >>> >To: dba-sqlserver at databaseadvisors.com >>> >Subject: Re: [dba-SQLServer] Finding current login group >>> > >>> >sp_who returns domain and userid not the usergroup, and in fact I don't >>> >know how to get he usergroup name within a sproc, but one workaround is >>> >to create seperate functions and assign them rights based on the NT >>> >groups, you can have the sprocs return some type of value based on their >>> >usergroup name and this will provide you with the info you are seeking. >>> > >>> > >>> >Jeff Barrows wrote On 7/1/2004 3:44 PM: >>> > >>> > >Have you tried: EXECUTE sp_who in the SQL Query Analyser? >>> > > >>> > > -----Original Message----- >>> > > From: David Emerson [mailto:davide at dalyn.co.nz] >>> > > Sent: Thu 7/1/2004 5:11 PM >>> > > To: dba-SQLServer at databaseadvisors.com >>> > > Cc: >>> > > Subject: [dba-SQLServer] Finding current login group >>> > > >>> > > >>> > > >>> > > SQL2000 >>> > > >>> > > I am using Windows Authentication. I have set up Windows groups >>> >that users >>> > > belong to. These groups are set up in SQL as logins (this means >>> >that new >>> > > users just need to be added to the windows group to be given >>>access >>> >to all >>> > > the databases with permissions for the group). >>> > > >>> > > Within my ADP I need to find out what login the user has accessed >>> >the SQL >>> > > database from so that I can show/hide controls etc. However, >>> when >>>I >>> >use >>> > > the CURRENT_USER variable in a Sproc it returns the user, not the >>> >group >>> > > they have come in by. >>> > > >>> > > EG - egas\David is a member of egas\BillingUsers Group. >>> >egas\BillingUsers >>> > > is set up as a login in SQL (egas\David is not). When egas\David >>>is >>> >using >>> > > a database he has accessed it because he is a member of >>> > > egas\BillingUsers. Is there a way to find out the login that was >>> >used for >>> > > egas\David to get in (CURRENT_USER returns egas\David, I want >>> > > egas\BillingUsers)? >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >>> >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com > >_________________________________________________________________ >MSN Premium includes powerful parental controls and get 2 months FREE* >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From davide at dalyn.co.nz Sun Jul 4 03:29:41 2004 From: davide at dalyn.co.nz (David Emerson) Date: Sun, 04 Jul 2004 20:29:41 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: Message-ID: <5.2.0.9.0.20040704202846.00b2b5d0@mail.dalyn.co.nz> Thanks - finally found it. Will test it out tomorrow. Much appreciated. Why working so late? and on a Saturday! David At 4/07/2004, you wrote: >xp_logininfo sproc is in master db... so try... > >/* -- cut here */ >DECLARE @sys_usr varchar(100) >SET @sys_usr = SYSTEM_USER >SELECT @sys_usr >EXEC master..xp_logininfo @sys_usr >/* -- cut here */ > >be aware of the execute permissions of this sproc...from bol, it reads: > >Execute permissions for xp_logininfo default to members of the db_owner >fixed database role in the master database and members of the sysadmin >fixed server role, but can be granted to other users. > >HTH > >Billy > > >>From: David Emerson >>Reply-To: dba-sqlserver at databaseadvisors.com >>To: dba-sqlserver at databaseadvisors.com >>Subject: RE: [dba-SQLServer] Finding current login group >>Date: Sun, 04 Jul 2004 19:50:47 +1200 >> >>Tried running this in Query Analyzer. Received error - couldn't find >>xp_logininfo. What am I missing? >> >>David >> >>At 3/07/2004, you wrote: >>>"permission path" column of xp_logininfo? >>> >>>see below.. >>> >>>/* -- cut here */ >>>DECLARE @sys_usr varchar(100) >>>SET @sys_usr = SYSTEM_USER >>>SELECT @sys_usr >>>EXEC xp_logininfo @sys_usr >>>/* -- cut here */ >>> >>>HTH >>>Billy >>> >>> >>>>From: David Emerson >>>>Reply-To: dba-sqlserver at databaseadvisors.com >>>>To: dba-sqlserver at databaseadvisors.com >>>>Subject: RE: [dba-SQLServer] Finding current login group >>>>Date: Sat, 03 Jul 2004 14:34:45 +1200 >>>> >>>>Ken, >>>> >>>>The problem is that while egas\David is the windows login for the user, >>>>the SQL login is egas\BillingUsers. That is, the user accessed SQL >>>>because he is a member of egas\BillingUsers. egas\David is not a login in SQL. >>>>Because egas\David is not in sysusers there is no match with >>>>Current_User (which returns the windows login, not the SQL login). >>>> >>>>David >>>> >>>>At 2/07/2004, you wrote: >>>>>David, >>>>> >>>>>Yes, but that is only the criteria for the query. By joining sysusers to >>>>>sysmembers, once to represent users and a second time to represent roles, >>>>>you can determine which roles a user belongs to, which may be one or >>>>>many, I >>>>>don't know how you managed that. >>>>> >>>>>Ken >>>>> >>>>>-----Original Message----- >>>>>From: dba-sqlserver-bounces at databaseadvisors.com >>>>>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>>>>Emerson >>>>>Sent: Friday, July 02, 2004 2:48 PM >>>>>To: dba-sqlserver at databaseadvisors.com >>>>>Subject: RE: [dba-SQLServer] Finding current login group >>>>> >>>>>Ken, >>>>> >>>>>Current_user gives me the name of the user (egas\David), not the group >>>>>that >>>>>that they were logged in as (egas\BillingUsers). >>>>> >>>>>David >>>>> >>>>>At 1/07/2004, you wrote: >>>>> >Could you use something like this? >>>>> > >>>>> >select sg.name >>>>> >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid >>>>> > inner join sysusers sg on sm.groupuid = sg.uid >>>>> >where su.name = current_user >>>>> > >>>>> >When I run this, it returns all the groups that a particular user is a >>>>> >member of. >>>>> > >>>>> >Ken >>>>> > >>>>> >-----Original Message----- >>>>> >From: dba-sqlserver-bounces at databaseadvisors.com >>>>> >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of >>>>> Francisco >>>>>H >>>>> >Tapia >>>>> >Sent: Thursday, July 01, 2004 4:15 PM >>>>> >To: dba-sqlserver at databaseadvisors.com >>>>> >Subject: Re: [dba-SQLServer] Finding current login group >>>>> > >>>>> >sp_who returns domain and userid not the usergroup, and in fact I don't >>>>> >know how to get he usergroup name within a sproc, but one workaround is >>>>> >to create seperate functions and assign them rights based on the NT >>>>> >groups, you can have the sprocs return some type of value based on their >>>>> >usergroup name and this will provide you with the info you are seeking. >>>>> > >>>>> > >>>>> >Jeff Barrows wrote On 7/1/2004 3:44 PM: >>>>> > >>>>> > >Have you tried: EXECUTE sp_who in the SQL Query Analyser? >>>>> > > >>>>> > > -----Original Message----- >>>>> > > From: David Emerson [mailto:davide at dalyn.co.nz] >>>>> > > Sent: Thu 7/1/2004 5:11 PM >>>>> > > To: dba-SQLServer at databaseadvisors.com >>>>> > > Cc: >>>>> > > Subject: [dba-SQLServer] Finding current login group >>>>> > > >>>>> > > >>>>> > > >>>>> > > SQL2000 >>>>> > > >>>>> > > I am using Windows Authentication. I have set up Windows >>>>> groups >>>>> >that users >>>>> > > belong to. These groups are set up in SQL as logins (this >>>>> means >>>>> >that new >>>>> > > users just need to be added to the windows group to be given >>>>>access >>>>> >to all >>>>> > > the databases with permissions for the group). >>>>> > > >>>>> > > Within my ADP I need to find out what login the user has >>>>> accessed >>>>> >the SQL >>>>> > > database from so that I can show/hide controls >>>>> etc. However, when >>>>>I >>>>> >use >>>>> > > the CURRENT_USER variable in a Sproc it returns the user, >>>>> not the >>>>> >group >>>>> > > they have come in by. >>>>> > > >>>>> > > EG - egas\David is a member of egas\BillingUsers Group. >>>>> >egas\BillingUsers >>>>> > > is set up as a login in SQL (egas\David is not). When >>>>> egas\David >>>>>is >>>>> >using >>>>> > > a database he has accessed it because he is a member of >>>>> > > egas\BillingUsers. Is there a way to find out the login >>>>> that was >>>>> >used for >>>>> > > egas\David to get in (CURRENT_USER returns egas\David, I want >>>>> > > egas\BillingUsers)? >>>>> >>>>>_______________________________________________ >>>>>dba-SQLServer mailing list >>>>>dba-SQLServer at databaseadvisors.com >>>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>>http://www.databaseadvisors.com >>>>> >>>>> >>>>>_______________________________________________ >>>>>dba-SQLServer mailing list >>>>>dba-SQLServer at databaseadvisors.com >>>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>>http://www.databaseadvisors.com >>>> >>>>_______________________________________________ >>>>dba-SQLServer mailing list >>>>dba-SQLServer at databaseadvisors.com >>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>http://www.databaseadvisors.com >>> >>>_________________________________________________________________ >>>MSN Premium includes powerful parental controls and get 2 months FREE* >>>http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com > >_________________________________________________________________ >Add photos to your e-mail with MSN Premium. Get 2 months FREE* >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > From tuxedo_man at hotmail.com Sun Jul 4 04:08:23 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Sun, 04 Jul 2004 09:08:23 +0000 Subject: [dba-SQLServer] Finding current login group Message-ID: not really working.. I am currently trying to resuscitate an old toshiba 4005CDT laptop. it has served me well in university 6 years ago. now it won't boot up. when it powers up, I see Toshiba welcome screen and then blank screen. I won't let it go out on me.. not on my watch :) >From: David Emerson >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Finding current login group >Date: Sun, 04 Jul 2004 20:29:41 +1200 > >Thanks - finally found it. Will test it out tomorrow. Much appreciated. > >Why working so late? and on a Saturday! > >David > >At 4/07/2004, you wrote: >>xp_logininfo sproc is in master db... so try... >> >>/* -- cut here */ >>DECLARE @sys_usr varchar(100) >>SET @sys_usr = SYSTEM_USER >>SELECT @sys_usr >>EXEC master..xp_logininfo @sys_usr >>/* -- cut here */ >> >>be aware of the execute permissions of this sproc...from bol, it reads: >> >>Execute permissions for xp_logininfo default to members of the db_owner >>fixed database role in the master database and members of the sysadmin >>fixed server role, but can be granted to other users. >> >>HTH >> >>Billy >> >> >>>From: David Emerson >>>Reply-To: dba-sqlserver at databaseadvisors.com >>>To: dba-sqlserver at databaseadvisors.com >>>Subject: RE: [dba-SQLServer] Finding current login group >>>Date: Sun, 04 Jul 2004 19:50:47 +1200 >>> >>>Tried running this in Query Analyzer. Received error - couldn't find >>>xp_logininfo. What am I missing? >>> >>>David >>> >>>At 3/07/2004, you wrote: >>>>"permission path" column of xp_logininfo? >>>> >>>>see below.. >>>> >>>>/* -- cut here */ >>>>DECLARE @sys_usr varchar(100) >>>>SET @sys_usr = SYSTEM_USER >>>>SELECT @sys_usr >>>>EXEC xp_logininfo @sys_usr >>>>/* -- cut here */ >>>> >>>>HTH >>>>Billy >>>> >>>> >>>>>From: David Emerson >>>>>Reply-To: dba-sqlserver at databaseadvisors.com >>>>>To: dba-sqlserver at databaseadvisors.com >>>>>Subject: RE: [dba-SQLServer] Finding current login group >>>>>Date: Sat, 03 Jul 2004 14:34:45 +1200 >>>>> >>>>>Ken, >>>>> >>>>>The problem is that while egas\David is the windows login for the user, >>>>>the SQL login is egas\BillingUsers. That is, the user accessed SQL >>>>>because he is a member of egas\BillingUsers. egas\David is not a login >>>>>in SQL. >>>>>Because egas\David is not in sysusers there is no match with >>>>>Current_User (which returns the windows login, not the SQL login). >>>>> >>>>>David >>>>> >>>>>At 2/07/2004, you wrote: >>>>>>David, >>>>>> >>>>>>Yes, but that is only the criteria for the query. By joining sysusers >>>>>>to >>>>>>sysmembers, once to represent users and a second time to represent >>>>>>roles, >>>>>>you can determine which roles a user belongs to, which may be one or >>>>>>many, I >>>>>>don't know how you managed that. >>>>>> >>>>>>Ken >>>>>> >>>>>>-----Original Message----- >>>>>>From: dba-sqlserver-bounces at databaseadvisors.com >>>>>>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>>>>>Emerson >>>>>>Sent: Friday, July 02, 2004 2:48 PM >>>>>>To: dba-sqlserver at databaseadvisors.com >>>>>>Subject: RE: [dba-SQLServer] Finding current login group >>>>>> >>>>>>Ken, >>>>>> >>>>>>Current_user gives me the name of the user (egas\David), not the group >>>>>>that >>>>>>that they were logged in as (egas\BillingUsers). >>>>>> >>>>>>David >>>>>> >>>>>>At 1/07/2004, you wrote: >>>>>> >Could you use something like this? >>>>>> > >>>>>> >select sg.name >>>>>> >from sysusers su inner join sysmembers sm on su.uid = sm.memberuid >>>>>> > inner join sysusers sg on sm.groupuid = sg.uid >>>>>> >where su.name = current_user >>>>>> > >>>>>> >When I run this, it returns all the groups that a particular user is >>>>>>a >>>>>> >member of. >>>>>> > >>>>>> >Ken >>>>>> > >>>>>> >-----Original Message----- >>>>>> >From: dba-sqlserver-bounces at databaseadvisors.com >>>>>> >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of >>>>>>Francisco >>>>>>H >>>>>> >Tapia >>>>>> >Sent: Thursday, July 01, 2004 4:15 PM >>>>>> >To: dba-sqlserver at databaseadvisors.com >>>>>> >Subject: Re: [dba-SQLServer] Finding current login group >>>>>> > >>>>>> >sp_who returns domain and userid not the usergroup, and in fact I >>>>>>don't >>>>>> >know how to get he usergroup name within a sproc, but one workaround >>>>>>is >>>>>> >to create seperate functions and assign them rights based on the NT >>>>>> >groups, you can have the sprocs return some type of value based on >>>>>>their >>>>>> >usergroup name and this will provide you with the info you are >>>>>>seeking. >>>>>> > >>>>>> > >>>>>> >Jeff Barrows wrote On 7/1/2004 3:44 PM: >>>>>> > >>>>>> > >Have you tried: EXECUTE sp_who in the SQL Query >>>>>>Analyser? >>>>>> > > >>>>>> > > -----Original Message----- >>>>>> > > From: David Emerson [mailto:davide at dalyn.co.nz] >>>>>> > > Sent: Thu 7/1/2004 5:11 PM >>>>>> > > To: dba-SQLServer at databaseadvisors.com >>>>>> > > Cc: >>>>>> > > Subject: [dba-SQLServer] Finding current login group >>>>>> > > >>>>>> > > >>>>>> > > >>>>>> > > SQL2000 >>>>>> > > >>>>>> > > I am using Windows Authentication. I have set up Windows >>>>>>groups >>>>>> >that users >>>>>> > > belong to. These groups are set up in SQL as logins (this >>>>>>means >>>>>> >that new >>>>>> > > users just need to be added to the windows group to be >>>>>>given >>>>>>access >>>>>> >to all >>>>>> > > the databases with permissions for the group). >>>>>> > > >>>>>> > > Within my ADP I need to find out what login the user has >>>>>>accessed >>>>>> >the SQL >>>>>> > > database from so that I can show/hide controls etc. >>>>>>However, when >>>>>>I >>>>>> >use >>>>>> > > the CURRENT_USER variable in a Sproc it returns the user, >>>>>>not the >>>>>> >group >>>>>> > > they have come in by. >>>>>> > > >>>>>> > > EG - egas\David is a member of egas\BillingUsers Group. >>>>>> >egas\BillingUsers >>>>>> > > is set up as a login in SQL (egas\David is not). When >>>>>>egas\David >>>>>>is >>>>>> >using >>>>>> > > a database he has accessed it because he is a member of >>>>>> > > egas\BillingUsers. Is there a way to find out the login >>>>>>that was >>>>>> >used for >>>>>> > > egas\David to get in (CURRENT_USER returns egas\David, I >>>>>>want >>>>>> > > egas\BillingUsers)? >>>>>> >>>>>>_______________________________________________ >>>>>>dba-SQLServer mailing list >>>>>>dba-SQLServer at databaseadvisors.com >>>>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>>>http://www.databaseadvisors.com >>>>>> >>>>>> >>>>>>_______________________________________________ >>>>>>dba-SQLServer mailing list >>>>>>dba-SQLServer at databaseadvisors.com >>>>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>>>http://www.databaseadvisors.com >>>>> >>>>>_______________________________________________ >>>>>dba-SQLServer mailing list >>>>>dba-SQLServer at databaseadvisors.com >>>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>>http://www.databaseadvisors.com >>>> >>>>_________________________________________________________________ >>>>MSN Premium includes powerful parental controls and get 2 months FREE* >>>>http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines >>>> >>>>_______________________________________________ >>>>dba-SQLServer mailing list >>>>dba-SQLServer at databaseadvisors.com >>>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>>http://www.databaseadvisors.com >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >> >>_________________________________________________________________ >>Add photos to your e-mail with MSN Premium. Get 2 months FREE* >>http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com >> > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ STOP MORE SPAM with the MSN Premium and get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From mark at markkaren.com Sun Jul 4 08:28:57 2004 From: mark at markkaren.com (Mark Rider) Date: Sun, 4 Jul 2004 08:28:57 -0500 Subject: [dba-SQLServer] Locking Issue In-Reply-To: Message-ID: <200407041329.i64DTGQ29904@databaseadvisors.com> I have a database that crunches a bunch of data and the boss wants to crunch the data based on a totally different set of criteria. Can't do it all on the same DB since it takes about 6 hours to run and we need the two sets of results as close to the same time as possible. I have set up SQL Server on a new machine and have copied the tables I want to use from the old SQL Server using DTS. Permissions have been set as they were on the old machine and the new criteria is in place. The VB.NET program that runs the numbers through the DB is the same as on the old one, pointing to the local machine's database to get the data. About halfway through the program SQL Server throws an error indicating that there is a problem with Locking and the SQL server process has terminated. I have tried running this from other PCs, pointing to the new SQL Server and get the same error. Tables get created as they are supposed to, and sometime during the Update statement the failure occurs. The table that is getting Updated is getting updated at first, so there does not seem to be a permission issue there. The main difference between the 'old' SQL Server and the 'new' one is that the new one has 1 processor and 1 Gb RAM, while the 'old' SQL Server has 2 processors and 3 Gb RAM. The new SQL Server runs at just about 100% processor use for several minutes just before the error. Is the lack of 'power' causing the Lock? I have the Physical memory reserved for SQL Server, Priority Boosted, 32 Worker threads, and dynamic memory allocation all set up. Is there a way to get around this locking problem? BOL seems to indicate that it is a memory issue, but I cannot find a way to get SQL to slow down enough to make this work. Any ideas will be greatly appreciated! Mark Rider From davide at dalyn.co.nz Sun Jul 4 17:12:43 2004 From: davide at dalyn.co.nz (David Emerson) Date: Mon, 05 Jul 2004 10:12:43 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: Message-ID: <5.2.0.9.0.20040705094320.00b2b6f8@mail.dalyn.co.nz> OK - getting closer. I have a procedure in my FE like this - Dim cmd As ADODB.Command, strCurrentUser As String, rst As ADODB.Recordset 'This returns the user (eg egas\david) Set cmd = basGetCommand("dbo.spGetCurrentUser", adCmdStoredProc) cmd.Parameters.Append cmd.CreateParameter("@CurrUser", adVarChar, adParamOutput, 100) cmd.Execute strCurrentUser = cmd.Parameters("@CurrUser") Set cmd = basGetCommand("master..xp_logininfo", adCmdStoredProc) cmd.Parameters.Append cmd.CreateParameter("@acctname", adVarChar, adParamInput, 100, strCurrentUser) Set rst = cmd.Execute basGetCurrentRole = "" If Not (rst.BOF Or rst.EOF) Then 'Record exist <= Error occurs here rst.MoveFirst While Not rst.EOF 'Users should only belong to 1 login group If Not IsNull(rst![Permission Path]) Then basGetCurrentRole = rst![Permission Path] rst.MoveNext Wend End If When this is run I get an error on the line above where indicated. The number is 3704 - Operation is not allowed when object is closed. Why should it be closed when I have just opened it? Billy's code below works ok if run from Query Analyzer. I have given the users permissions to execute master..xp_logininfo. David At 4/07/2004, you wrote: >xp_logininfo sproc is in master db... so try... > >/* -- cut here */ >DECLARE @sys_usr varchar(100) >SET @sys_usr = SYSTEM_USER >SELECT @sys_usr >EXEC master..xp_logininfo @sys_usr >/* -- cut here */ > >be aware of the execute permissions of this sproc...from bol, it reads: > >Execute permissions for xp_logininfo default to members of the db_owner >fixed database role in the master database and members of the sysadmin >fixed server role, but can be granted to other users. > >HTH > >Billy From davide at dalyn.co.nz Sun Jul 4 18:26:28 2004 From: davide at dalyn.co.nz (David Emerson) Date: Mon, 05 Jul 2004 11:26:28 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <5.2.0.9.0.20040705094320.00b2b6f8@mail.dalyn.co.nz> References: Message-ID: <5.2.0.9.0.20040705112218.00b4ce58@mail.dalyn.co.nz> More testing - I have written the following sproc - declare @qs nvarchar(4000) DELETE FROM ttmpTemporary SELECT @qs = ' INSERT INTO ttmpTemporary (F1) SELECT Privilege FROM openquery(localServer, ''exec master..xp_logininfo'')' EXEC (@qs) When run from query analyzer I get the following message - Server: Msg 7357, Level 16, State 2, Line 1 Could not process object 'exec master..xp_logininfo'. The OLE DB provider 'SQLOLEDB' indicates that the object has no columns. OLE DB error trace [Non-interface error: OLE DB provider unable to process object, since the object has no columnsProviderName='SQLOLEDB', Query=exec master..xp_logininfo']. Yet when I run "EXEC master..xp_logininfo" in Query Analyzer I get a result set with the columns expected in BOL. This is starting to get urgent. David At 5/07/2004, you wrote: >OK - getting closer. > >I have a procedure in my FE like this - > > Dim cmd As ADODB.Command, strCurrentUser As String, rst As > ADODB.Recordset > > 'This returns the user (eg egas\david) > Set cmd = basGetCommand("dbo.spGetCurrentUser", adCmdStoredProc) > cmd.Parameters.Append cmd.CreateParameter("@CurrUser", adVarChar, > adParamOutput, 100) > cmd.Execute > strCurrentUser = cmd.Parameters("@CurrUser") > > Set cmd = basGetCommand("master..xp_logininfo", adCmdStoredProc) > cmd.Parameters.Append cmd.CreateParameter("@acctname", adVarChar, > adParamInput, 100, strCurrentUser) > Set rst = cmd.Execute > basGetCurrentRole = "" > If Not (rst.BOF Or rst.EOF) Then 'Record exist <= Error > occurs here > rst.MoveFirst > While Not rst.EOF > 'Users should only belong to 1 login group > If Not IsNull(rst![Permission Path]) Then basGetCurrentRole = > rst![Permission Path] > rst.MoveNext > Wend > End If > >When this is run I get an error on the line above where indicated. The >number is 3704 - Operation is not allowed when object is closed. Why >should it be closed when I have just opened it? > >Billy's code below works ok if run from Query Analyzer. I have given the >users permissions to execute master..xp_logininfo. > >David > >At 4/07/2004, you wrote: >>xp_logininfo sproc is in master db... so try... >> >>/* -- cut here */ >>DECLARE @sys_usr varchar(100) >>SET @sys_usr = SYSTEM_USER >>SELECT @sys_usr >>EXEC master..xp_logininfo @sys_usr >>/* -- cut here */ >> >>be aware of the execute permissions of this sproc...from bol, it reads: >> >>Execute permissions for xp_logininfo default to members of the db_owner >>fixed database role in the master database and members of the sysadmin >>fixed server role, but can be granted to other users. >> >>HTH >> >>Billy > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > From artful at rogers.com Mon Jul 5 10:00:30 2004 From: artful at rogers.com (Arthur Fuller) Date: Mon, 5 Jul 2004 11:00:30 -0400 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <5.2.0.9.0.20040705112218.00b4ce58@mail.dalyn.co.nz> Message-ID: <02a401c462a0$d0f345f0$6601a8c0@rock> Why do you have pairs of quotes around the 'exec master..xp_logininfo' argument? That may be the problem. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Sunday, July 04, 2004 7:26 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Finding current login group More testing - I have written the following sproc - declare @qs nvarchar(4000) DELETE FROM ttmpTemporary SELECT @qs = ' INSERT INTO ttmpTemporary (F1) SELECT Privilege FROM openquery(localServer, ''exec master..xp_logininfo'')' EXEC (@qs) When run from query analyzer I get the following message - Server: Msg 7357, Level 16, State 2, Line 1 Could not process object 'exec master..xp_logininfo'. The OLE DB provider 'SQLOLEDB' indicates that the object has no columns. OLE DB error trace [Non-interface error: OLE DB provider unable to process object, since the object has no columnsProviderName='SQLOLEDB', Query=exec master..xp_logininfo']. Yet when I run "EXEC master..xp_logininfo" in Query Analyzer I get a result set with the columns expected in BOL. This is starting to get urgent. David At 5/07/2004, you wrote: >OK - getting closer. > >I have a procedure in my FE like this - > > Dim cmd As ADODB.Command, strCurrentUser As String, rst As > ADODB.Recordset > > 'This returns the user (eg egas\david) > Set cmd = basGetCommand("dbo.spGetCurrentUser", adCmdStoredProc) > cmd.Parameters.Append cmd.CreateParameter("@CurrUser", adVarChar, > adParamOutput, 100) > cmd.Execute > strCurrentUser = cmd.Parameters("@CurrUser") > > Set cmd = basGetCommand("master..xp_logininfo", adCmdStoredProc) > cmd.Parameters.Append cmd.CreateParameter("@acctname", adVarChar, > adParamInput, 100, strCurrentUser) > Set rst = cmd.Execute > basGetCurrentRole = "" > If Not (rst.BOF Or rst.EOF) Then 'Record exist <= Error > occurs here > rst.MoveFirst > While Not rst.EOF > 'Users should only belong to 1 login group > If Not IsNull(rst![Permission Path]) Then basGetCurrentRole = > rst![Permission Path] > rst.MoveNext > Wend > End If > >When this is run I get an error on the line above where indicated. The >number is 3704 - Operation is not allowed when object is closed. Why >should it be closed when I have just opened it? > >Billy's code below works ok if run from Query Analyzer. I have given >the >users permissions to execute master..xp_logininfo. > >David > >At 4/07/2004, you wrote: >>xp_logininfo sproc is in master db... so try... >> >>/* -- cut here */ >>DECLARE @sys_usr varchar(100) >>SET @sys_usr = SYSTEM_USER >>SELECT @sys_usr >>EXEC master..xp_logininfo @sys_usr >>/* -- cut here */ >> >>be aware of the execute permissions of this sproc...from bol, it >>reads: >> >>Execute permissions for xp_logininfo default to members of the >>db_owner >>fixed database role in the master database and members of the sysadmin >>fixed server role, but can be granted to other users. >> >>HTH >> >>Billy > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Mon Jul 5 14:43:36 2004 From: davide at dalyn.co.nz (David Emerson) Date: Tue, 06 Jul 2004 07:43:36 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <02a401c462a0$d0f345f0$6601a8c0@rock> References: <5.2.0.9.0.20040705112218.00b4ce58@mail.dalyn.co.nz> Message-ID: <5.2.0.9.0.20040706074225.00b2bc58@mail.dalyn.co.nz> Because openquery requires a string (see BOL). David At 5/07/2004, you wrote: >Why do you have pairs of quotes around the 'exec master..xp_logininfo' >argument? That may be the problem. > >Arthur > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >Emerson >Sent: Sunday, July 04, 2004 7:26 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Finding current login group > > >More testing - I have written the following sproc - > > declare @qs nvarchar(4000) > > DELETE FROM ttmpTemporary > > SELECT @qs = ' INSERT INTO ttmpTemporary (F1) > SELECT Privilege > FROM openquery(localServer, ''exec >master..xp_logininfo'')' > > EXEC (@qs) > >When run from query analyzer I get the following message - > >Server: Msg 7357, Level 16, State 2, Line 1 >Could not process object 'exec master..xp_logininfo'. The OLE DB >provider >'SQLOLEDB' indicates that the object has no columns. >OLE DB error trace [Non-interface error: OLE DB provider unable to >process >object, since the object has no columnsProviderName='SQLOLEDB', >Query=exec >master..xp_logininfo']. > >Yet when I run "EXEC master..xp_logininfo" in Query Analyzer I get a >result >set with the columns expected in BOL. > >This is starting to get urgent. > >David > > >At 5/07/2004, you wrote: > >OK - getting closer. > > > >I have a procedure in my FE like this - > > > > Dim cmd As ADODB.Command, strCurrentUser As String, rst As > > ADODB.Recordset > > > > 'This returns the user (eg egas\david) > > Set cmd = basGetCommand("dbo.spGetCurrentUser", adCmdStoredProc) > > cmd.Parameters.Append cmd.CreateParameter("@CurrUser", adVarChar, > > adParamOutput, 100) > > cmd.Execute > > strCurrentUser = cmd.Parameters("@CurrUser") > > > > Set cmd = basGetCommand("master..xp_logininfo", adCmdStoredProc) > > cmd.Parameters.Append cmd.CreateParameter("@acctname", adVarChar, > > adParamInput, 100, strCurrentUser) > > Set rst = cmd.Execute > > basGetCurrentRole = "" > > If Not (rst.BOF Or rst.EOF) Then 'Record exist <= Error > > occurs here > > rst.MoveFirst > > While Not rst.EOF > > 'Users should only belong to 1 login group > > If Not IsNull(rst![Permission Path]) Then >basGetCurrentRole = > > rst![Permission Path] > > rst.MoveNext > > Wend > > End If > > > >When this is run I get an error on the line above where indicated. The > >number is 3704 - Operation is not allowed when object is closed. Why > >should it be closed when I have just opened it? > > > >Billy's code below works ok if run from Query Analyzer. I have given > >the > >users permissions to execute master..xp_logininfo. > > > >David > > > >At 4/07/2004, you wrote: > >>xp_logininfo sproc is in master db... so try... > >> > >>/* -- cut here */ > >>DECLARE @sys_usr varchar(100) > >>SET @sys_usr = SYSTEM_USER > >>SELECT @sys_usr > >>EXEC master..xp_logininfo @sys_usr > >>/* -- cut here */ > >> > >>be aware of the execute permissions of this sproc...from bol, it > >>reads: > >> > >>Execute permissions for xp_logininfo default to members of the > >>db_owner > >>fixed database role in the master database and members of the sysadmin > > >>fixed server role, but can be granted to other users. > >> > >>HTH > >> > >>Billy > > > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From HARVEYF1 at WESTAT.com Tue Jul 6 08:55:19 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Tue, 6 Jul 2004 09:55:19 -0400 Subject: [dba-SQLServer] Finding current login group Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E941@remail2.westat.com> David, I am catching-up after my holiday, so I probably missed something. You tried CURRENT_USER and didn't like that, so what happened when you tried SUSER_SNAME instead? I'm just working my way through the BOL "Functions That Return User Names and User IDs" article which I assumed was your starting reference. I can setup an account to mimic your conditions if necessary, but I was hoping you could just let us know what the results of this function with your actual account were. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of David Emerson > Sent: Thursday, July 01, 2004 6:12 PM > To: dba-SQLServer at databaseadvisors.com > Subject: [dba-SQLServer] Finding current login group > > > SQL2000 > > I am using Windows Authentication. I have set up Windows > groups that users > belong to. These groups are set up in SQL as logins (this > means that new > users just need to be added to the windows group to be given > access to all > the databases with permissions for the group). > > Within my ADP I need to find out what login the user has > accessed the SQL > database from so that I can show/hide controls etc. However, > when I use > the CURRENT_USER variable in a Sproc it returns the user, not > the group > they have come in by. > > EG - egas\David is a member of egas\BillingUsers Group. > egas\BillingUsers > is set up as a login in SQL (egas\David is not). When > egas\David is using > a database he has accessed it because he is a member of > egas\BillingUsers. Is there a way to find out the login that > was used for > egas\David to get in (CURRENT_USER returns egas\David, I want > egas\BillingUsers)? From HARVEYF1 at WESTAT.com Tue Jul 6 09:18:11 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Tue, 6 Jul 2004 10:18:11 -0400 Subject: [dba-SQLServer] #Deleted-Problem (Cross-posted) Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E942@remail2.westat.com> Michael, I hope you didn't spend all weekend on this as there must be a better answer then going unbound. I am guessing the KB was 275090? It would help if we could read exactly what Microsoft wrote about the problem. Working from that, I did a Google search and ended up with this (WFW), http://groups.google.com/groups?q=275090+access&hl=en&lr=&ie=UTF-8&selm=elcr f%23VVEHA.384%40TK2MSFTNGP10.phx.gbl&rnum=1 which suggests a method for recoding triggers to ensure @@IDENTITY. Since I am just getting back to speed after the holiday, I don't trust myself to think through whether this solves your problem. Does this seem like a workable approach? Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Michael Br?sdorf > Sent: Friday, July 02, 2004 8:50 AM > To: dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] #Deleted-Problem (Cross-posted) > > > Dear group, > > > I have a problem with my Access2000-App. The Backend is SQL > Server 2000 > > A bound form is linked to Table A. Table A has an > insert-trigger, that creates a record in table B. > Both tables have an ID-Field (A_ID and B_ID). > > Whenever I save a new record in the bound form, it either > immediately displays #Deleted# in every field, > or displays an old record(!). > However, the new record is created correctly. > > There's a knowledgebase article, describing that problem. It > states, that Access tries to re-select the > new record using the ID value. It looks like that it is using > the ID-value of table B instead that of table A to do the > re-select. If it finds a record with that ID it displays that > in the new row on the bound form. If it does not find it, the > form displays #Deleted#. > > Is there any way to tell the trigger on table A not to return > the ID of the new record in table B? From HARVEYF1 at WESTAT.com Tue Jul 6 09:31:46 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Tue, 6 Jul 2004 10:31:46 -0400 Subject: [dba-SQLServer] Locking Issue Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E943@remail2.westat.com> Mark, Since the problem seems to be the update, perhaps it would be best to explain how this is being performed. Are you using batch, stored procedures, ...? Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com From michael.broesdorf at web.de Tue Jul 6 09:39:26 2004 From: michael.broesdorf at web.de (=?iso-8859-1?Q?Michael_Br=F6sdorf?=) Date: Tue, 6 Jul 2004 16:39:26 +0200 Subject: AW: [dba-SQLServer] #Deleted-Problem (Cross-posted) In-Reply-To: <446DDE75CFC7E1438061462F85557B0F0481E942@remail2.westat.com> Message-ID: Francis, THAAAANK YOU!!! Unfortunately I already started to go unbound, but guess what: it's pain in the.. and I am more than willing to stay 'bound'. That solution is so simple! However, do you have any information regarding performance implications (a new (temp) table is created every time the trigger fires)? Michael -----Urspr?ngliche Nachricht----- Von: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]Im Auftrag von Francis Harvey Gesendet: Dienstag, 6. Juli 2004 16:18 An: 'dba-sqlserver at databaseadvisors.com' Betreff: RE: [dba-SQLServer] #Deleted-Problem (Cross-posted) Michael, I hope you didn't spend all weekend on this as there must be a better answer then going unbound. I am guessing the KB was 275090? It would help if we could read exactly what Microsoft wrote about the problem. Working from that, I did a Google search and ended up with this (WFW), http://groups.google.com/groups?q=275090+access&hl=en&lr=&ie=UTF-8&selm=elcr f%23VVEHA.384%40TK2MSFTNGP10.phx.gbl&rnum=1 which suggests a method for recoding triggers to ensure @@IDENTITY. Since I am just getting back to speed after the holiday, I don't trust myself to think through whether this solves your problem. Does this seem like a workable approach? Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Michael Br?sdorf > Sent: Friday, July 02, 2004 8:50 AM > To: dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] #Deleted-Problem (Cross-posted) > > > Dear group, > > > I have a problem with my Access2000-App. The Backend is SQL > Server 2000 > > A bound form is linked to Table A. Table A has an > insert-trigger, that creates a record in table B. > Both tables have an ID-Field (A_ID and B_ID). > > Whenever I save a new record in the bound form, it either > immediately displays #Deleted# in every field, > or displays an old record(!). > However, the new record is created correctly. > > There's a knowledgebase article, describing that problem. It > states, that Access tries to re-select the > new record using the ID value. It looks like that it is using > the ID-value of table B instead that of table A to do the > re-select. If it finds a record with that ID it displays that > in the new row on the bound form. If it does not find it, the > form displays #Deleted#. > > Is there any way to tell the trigger on table A not to return > the ID of the new record in table B? _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From michael.broesdorf at web.de Tue Jul 6 09:54:17 2004 From: michael.broesdorf at web.de (=?iso-8859-1?Q?Michael_Br=F6sdorf?=) Date: Tue, 6 Jul 2004 16:54:17 +0200 Subject: AW: [dba-SQLServer] #Deleted-Problem (Cross-posted) In-Reply-To: Message-ID: A little update: I modified the stored proc a little: CREATE PROCEDURE [dbo].[SP_Reset_IDENTITY] (@intID as int) AS DECLARE @strSQL varchar(50) set nocount on --not doing this can confuse Access ADPs as well SET @strSQL=N'SELECT Identity (Int, ' + Cast(@intID As Varchar(20)) + ', 1) AS id INTO #Tmp' EXECUTE (@strSQL) GO The trigger would then look like this: ... Declare @intSPT_ID int -- Remember SPT_ID select @intSPT_ID=SPT_ID from inserted --All the processing affecting @@INSERTED is done here ... --Reset @@IDENTITY exec imisSP_Reset_IDENTITY @intSPT_ID ... The reason is that the processing of the trigger can take some time and other users might insert new records in between, messing up the values in IDENT_CURRENT() Michael -----Urspr?ngliche Nachricht----- Von: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]Im Auftrag von Michael Br?sdorf Gesendet: Dienstag, 6. Juli 2004 16:39 An: dba-sqlserver at databaseadvisors.com Betreff: AW: [dba-SQLServer] #Deleted-Problem (Cross-posted) Francis, THAAAANK YOU!!! Unfortunately I already started to go unbound, but guess what: it's pain in the.. and I am more than willing to stay 'bound'. That solution is so simple! However, do you have any information regarding performance implications (a new (temp) table is created every time the trigger fires)? Michael -----Urspr?ngliche Nachricht----- Von: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]Im Auftrag von Francis Harvey Gesendet: Dienstag, 6. Juli 2004 16:18 An: 'dba-sqlserver at databaseadvisors.com' Betreff: RE: [dba-SQLServer] #Deleted-Problem (Cross-posted) Michael, I hope you didn't spend all weekend on this as there must be a better answer then going unbound. I am guessing the KB was 275090? It would help if we could read exactly what Microsoft wrote about the problem. Working from that, I did a Google search and ended up with this (WFW), http://groups.google.com/groups?q=275090+access&hl=en&lr=&ie=UTF-8&selm=elcr f%23VVEHA.384%40TK2MSFTNGP10.phx.gbl&rnum=1 which suggests a method for recoding triggers to ensure @@IDENTITY. Since I am just getting back to speed after the holiday, I don't trust myself to think through whether this solves your problem. Does this seem like a workable approach? Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Michael Br?sdorf > Sent: Friday, July 02, 2004 8:50 AM > To: dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] #Deleted-Problem (Cross-posted) > > > Dear group, > > > I have a problem with my Access2000-App. The Backend is SQL > Server 2000 > > A bound form is linked to Table A. Table A has an > insert-trigger, that creates a record in table B. > Both tables have an ID-Field (A_ID and B_ID). > > Whenever I save a new record in the bound form, it either > immediately displays #Deleted# in every field, > or displays an old record(!). > However, the new record is created correctly. > > There's a knowledgebase article, describing that problem. It > states, that Access tries to re-select the > new record using the ID value. It looks like that it is using > the ID-value of table B instead that of table A to do the > re-select. If it finds a record with that ID it displays that > in the new row on the bound form. If it does not find it, the > form displays #Deleted#. > > Is there any way to tell the trigger on table A not to return > the ID of the new record in table B? _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From mark at markkaren.com Tue Jul 6 10:05:27 2004 From: mark at markkaren.com (Mark Rider) Date: Tue, 6 Jul 2004 10:05:27 -0500 Subject: [dba-SQLServer] Locking Issue In-Reply-To: <446DDE75CFC7E1438061462F85557B0F0481E943@remail2.westat.com> Message-ID: <200407061505.i66F5mQ03909@databaseadvisors.com> The Update is being done in a SQL statement from VB.Net. The basic procedure is as follows: 1) Import the raw Stock data from a text file (DTS Import) 2) Loop through the raw data and create a temp table for each Stock, including Time, Stock Name and Price 3) Create a Master table with a column for each stock and one for the Time 4) Update the Master Table to hold the Price for each Time for each Stock This gives me a table that I can then manipulate as needed to get the values for any given Stock and Time. All tables are created from within the VB.NET program, so I am pretty sure it is not a permissions issue. The actual update statement is: UPDATE TempMaster SET MarketArray(i) = tmpi.AveragePrice FROM tmpi , TempMaster WHERE tmpi.quoteDate = TempMaster.quoteDate The variable "i" is set in the program, and the necessary punctuation has been removed for ease of reading. quoteDate is a smalldatetime in all tables. MarketArray(i) is the Stock Symbol - varchar(5). AveragePrice id a decimal. This same program runs fine when I point to the original database - it is only on the 'new' DB Server that it has problems. Thanks for the help! -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francis Harvey Sent: Tuesday, July 06, 2004 9:32 AM To: 'dba-sqlserver at databaseadvisors.com' Subject: RE: [dba-SQLServer] Locking Issue Mark, Since the problem seems to be the update, perhaps it would be best to explain how this is being performed. Are you using batch, stored procedures, ...? Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Tue Jul 6 11:58:32 2004 From: davide at dalyn.co.nz (David Emerson) Date: Wed, 07 Jul 2004 04:58:32 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <446DDE75CFC7E1438061462F85557B0F0481E941@remail2.westat.co m> Message-ID: <5.2.0.9.0.20040707042050.00b2baf0@mail.dalyn.co.nz> Thanks Francis, This also returns egas\david which is the Windows user. I am after egas\BillingManager which is the windows group that egas\david belongs to which is the login. I am close. Here is the latest - Billy Pang provided me with the following: DECLARE @sys_usr varchar(100) SET @sys_usr = SYSTEM_USER EXEC master..xp_logininfo @sys_usr When this is run in Query Analyser I get the correct recordset with a column called Permission Path. This has the data in it (in this case 'egas\BillingManager'). I want to turn this into a sproc which returns the value of Permission Path. What I have so far is - ALTER PROCEDURE dbo.spGetCurrentUser DECLARE @sys_usr varchar(100), @qs nvarchar(4000) SET @sys_usr = SYSTEM_USER EXEC master..xp_logininfo @sys_usr When run the sproc from query analyzer I get the recordset. Now, how do I change the sproc so that it returns the value of the permission path column? David At 6/07/2004, you wrote: >David, > >I am catching-up after my holiday, so I probably missed something. >You tried CURRENT_USER and didn't like that, so what happened when you >tried SUSER_SNAME instead? I'm just working my way through the BOL >"Functions That Return User Names and User IDs" article which I >assumed was your starting reference. I can setup an account to mimic >your conditions if necessary, but I was hoping you could just let us >know what the results of this function with your actual account were. > >Francis R Harvey III >WB 303, (301)294-3952 >harveyf1 at westat.com > > > -----Original Message----- > > From: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > > Of David Emerson > > Sent: Thursday, July 01, 2004 6:12 PM > > To: dba-SQLServer at databaseadvisors.com > > Subject: [dba-SQLServer] Finding current login group > > > > > > SQL2000 > > > > I am using Windows Authentication. I have set up Windows > > groups that users > > belong to. These groups are set up in SQL as logins (this > > means that new > > users just need to be added to the windows group to be given > > access to all > > the databases with permissions for the group). > > > > Within my ADP I need to find out what login the user has > > accessed the SQL > > database from so that I can show/hide controls etc. However, > > when I use > > the CURRENT_USER variable in a Sproc it returns the user, not > > the group > > they have come in by. > > > > EG - egas\David is a member of egas\BillingUsers Group. > > egas\BillingUsers > > is set up as a login in SQL (egas\David is not). When > > egas\David is using > > a database he has accessed it because he is a member of > > egas\BillingUsers. Is there a way to find out the login that > > was used for > > egas\David to get in (CURRENT_USER returns egas\David, I want > > egas\BillingUsers)? > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From HARVEYF1 at WESTAT.com Tue Jul 6 15:15:30 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Tue, 6 Jul 2004 16:15:30 -0400 Subject: [dba-SQLServer] Finding current login group Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E947@remail2.westat.com> David, Anything wrong with the normal method of creating a temporary table to hold the stored procedure results and then selecting what you want? Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of David Emerson > Sent: Tuesday, July 06, 2004 12:59 PM > To: dba-sqlserver at databaseadvisors.com > Subject: RE: [dba-SQLServer] Finding current login group > > Now, how do I > change the sproc so that it returns the value of the > permission path column? > > David From cfoust at infostatsystems.com Tue Jul 6 15:38:44 2004 From: cfoust at infostatsystems.com (Charlotte Foust) Date: Tue, 6 Jul 2004 13:38:44 -0700 Subject: [dba-SQLServer] OT-Alternative Front Ends Message-ID: I don't have to google her. Billy Rose mounted (you should pardon the expression) the production and there was a naughty rhyme at the time about the two of them, perhaps a Dorothy Parker gem. I wasn't born yet but I've read a lot about that era and I've seen publicity pictures of Sally, complete with huge ostrich feather fans which she used to more or less cover herself during her dance. Janet Jackson could have learned a lot from Sally. Charlotte Foust -----Original Message----- From: Nicholson, Karen [mailto:knicholson at gpsx.net] Sent: Friday, July 02, 2004 8:24 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends You have to google her. She did a wardrobe malfunction in 1933 or something like that at the World's Fair. Arthur is showing his age. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Charlotte Foust Sent: Friday, July 02, 2004 12:06 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Complete with ostrich feather fans? Sally Rand was a fan dancer, not a stripper. Charlotte Foust -----Original Message----- From: Arthur Fuller [mailto:artful at rogers.com] Sent: Friday, July 02, 2004 7:29 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends You should see my demos! :) -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Nicholson, Karen Sent: Friday, July 02, 2004 11:09 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends A Stripper? Your programming theory is based on a stripper? This is great news, not the stripper, the performance. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Friday, July 02, 2004 11:04 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends I have an ADP that hits a SQL database with approximately 50K customers, most of which have only a few orders, while most of the orders have about 5 details. No problems. Granted, I rely heavily on sprocs to deliver the data, as well as what I call the Sally Rand principle. (Sally was a famous stripper way back when, who coined the phrase, "Show them just enough to maintain their interest." I try to emulate that principle in my designs. I.e., I show one form displaying only a list of company names; select one and then I make visible the subform that shows the details of said customer. Many examples like this; the point is, read in as little data as possible, then wait for a user action.) Strictly for testing purposes, I have created a db called BIG that contains 1M parent rows, 10M child rows and 100M grandchild rows. Relationships are declared and autoForm was used to generate the forms that talk to these tables. I then modified the parent form to include a "finder" on the header that accepts a few letters of the company name, then executes a sproc that performs a LIKE command. The performance is excellent. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence (AccessD) Sent: Thursday, July 01, 2004 11:20 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Alternative Front Ends Hi David: There are FEs that are designed to handle more clients like web based ones. There is a trade off as they are slower and do not have as many features. The new vb.net have the capability to be the FE, data web connection and sever side database interface. I have not actually created an applications with the product yet but if it lives up to current billing... An Access FE will work with hundreds of customers. The main issue is what type of BE do you have. It would have to be a SQL DB; SQL2000, Oracle, MySQL etc. on a server or severs of significant power, depending on the application. That volume of data is far beyond an Access MDB. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Thursday, July 01, 2004 4:48 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Alternative Front Ends Group, A company I am contracting to what to know if there are any "higher" alternatives to Access adp's. They are concerned that Access may not be powerful enough to handle databases with monthly accounts for say 200,000 customers. Any comments? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From HARVEYF1 at WESTAT.com Tue Jul 6 16:57:33 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Tue, 6 Jul 2004 17:57:33 -0400 Subject: [dba-SQLServer] #Deleted-Problem (Cross-posted) Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E94A@remail2.westat.com> Michael, I can't really add anything to the caveats about temporary tables from sql-server-performance.com. I use temporary tables all the time, but in a trigger... If you do decide to use it, let us know how your performance turns out. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Michael Br?sdorf > Sent: Tuesday, July 06, 2004 10:39 AM > To: dba-sqlserver at databaseadvisors.com > Subject: AW: [dba-SQLServer] #Deleted-Problem (Cross-posted) > > > Francis, THAAAANK YOU!!! > > Unfortunately I already started to go unbound, but guess > what: it's pain in > the.. and I am more than willing to > stay 'bound'. > That solution is so simple! However, do you have any > information regarding > performance implications (a new (temp) table is created every time the > trigger fires)? From davide at dalyn.co.nz Tue Jul 6 16:58:49 2004 From: davide at dalyn.co.nz (David Emerson) Date: Wed, 07 Jul 2004 09:58:49 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <446DDE75CFC7E1438061462F85557B0F0481E947@remail2.westat.co m> Message-ID: <5.2.0.9.0.20040707094927.00b2bbe0@mail.dalyn.co.nz> Francis, That is my intention but how do I get the recordset from the sproc. The following doesn't work - SELECT Permission_Path FROM master..xp_logininfo Error message is "Invalid object name 'master..xp_logininfo'." David At 6/07/2004, you wrote: >David, > >Anything wrong with the normal method of creating a temporary table >to hold the stored procedure results and then selecting what you want? > >Francis R Harvey III >WB 303, (301)294-3952 >harveyf1 at westat.com > > > > -----Original Message----- > > From: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > > Of David Emerson > > Sent: Tuesday, July 06, 2004 12:59 PM > > To: dba-sqlserver at databaseadvisors.com > > Subject: RE: [dba-SQLServer] Finding current login group > > > > > Now, how do I > > change the sproc so that it returns the value of the > > permission path column? > > > > David > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From tuxedo_man at hotmail.com Tue Jul 6 20:31:58 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Wed, 07 Jul 2004 01:31:58 +0000 Subject: [dba-SQLServer] Finding current login group Message-ID: perhaps sql server thinks that xp_logininfo is a table in the select statement quoted in your email. if you want to store results from sproc, create a temp table and then put sproc after the insert statement.. using the sp_who as an example... /* cut here */ CREATE TABLE #TT ( spid varchar(100), ecid varchar(100),status varchar(100), loginame varchar(100), hostname varchar(100), blk varchar(100),dbname varchar(100), cmd varchar(100) ) go insert into #TT EXEC sp_who go select spid from #tt go DROP TABLE #TT go /* cut here */ >From: David Emerson >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Finding current login group >Date: Wed, 07 Jul 2004 09:58:49 +1200 > >Francis, > >That is my intention but how do I get the recordset from the sproc. The >following doesn't work - > >SELECT Permission_Path FROM master..xp_logininfo > >Error message is "Invalid object name 'master..xp_logininfo'." > >David > >At 6/07/2004, you wrote: >>David, >> >>Anything wrong with the normal method of creating a temporary table >>to hold the stored procedure results and then selecting what you want? >> >>Francis R Harvey III >>WB 303, (301)294-3952 >>harveyf1 at westat.com >> >> >> > -----Original Message----- >> > From: dba-sqlserver-bounces at databaseadvisors.com >> > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf >> > Of David Emerson >> > Sent: Tuesday, July 06, 2004 12:59 PM >> > To: dba-sqlserver at databaseadvisors.com >> > Subject: RE: [dba-SQLServer] Finding current login group >> > >> >> > Now, how do I >> > change the sproc so that it returns the value of the >> > permission path column? >> > >> > David >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN Premium http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From davide at dalyn.co.nz Wed Jul 7 13:49:57 2004 From: davide at dalyn.co.nz (David Emerson) Date: Thu, 08 Jul 2004 06:49:57 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <5.1.0.14.2.20040707121311.017f1690@pop3.highstream.net> References: <200407071700.i67H0sQ19349@databaseadvisors.com> Message-ID: <5.2.0.9.0.20040708064908.00b2b870@mail.dalyn.co.nz> Thanks Robert but that produces "Incorrect syntax near the keyword 'exec'." error David At 7/07/2004, you wrote: >David, > >Just a WAG here, but I think you might be able to do this... > >DECLARE @sys_usr varchar(100), @qs nvarchar(4000) >SET @sys_usr = SYSTEM_USER >SELECT @qs = (exec master..xp_logininfo @sys_usr) > >At 12:00 PM 07/07/2004 -0500, you wrote: >>Date: Wed, 07 Jul 2004 04:58:32 +1200 >>From: David Emerson >>Subject: RE: [dba-SQLServer] Finding current login group >>To: dba-sqlserver at databaseadvisors.com >>Message-ID: <5.2.0.9.0.20040707042050.00b2baf0 at mail.dalyn.co.nz> >>Content-Type: text/plain; charset="us-ascii"; format=flowed >> >>Thanks Francis, >> >>This also returns egas\david which is the Windows user. I am after >>egas\BillingManager which is the windows group that egas\david belongs to >>which is the login. >> >>I am close. Here is the latest - >> >>Billy Pang provided me with the following: >> >>DECLARE @sys_usr varchar(100) >>SET @sys_usr = SYSTEM_USER >>EXEC master..xp_logininfo @sys_usr >> >>When this is run in Query Analyser I get the correct recordset with a >>column called Permission Path. This has the data in it (in this case >>'egas\BillingManager'). >> >>I want to turn this into a sproc which returns the value of Permission >>Path. What I have so far is - >> >>ALTER PROCEDURE dbo.spGetCurrentUser >> >>DECLARE @sys_usr varchar(100), @qs nvarchar(4000) >>SET @sys_usr = SYSTEM_USER >>EXEC master..xp_logininfo @sys_usr >> >>When run the sproc from query analyzer I get the recordset. Now, how do I >>change the sproc so that it returns the value of the permission path column? >> >>David > > > From HARVEYF1 at WESTAT.com Wed Jul 7 14:13:22 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Wed, 7 Jul 2004 15:13:22 -0400 Subject: [dba-SQLServer] Finding current login group Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E952@remail2.westat.com> David, Sorry, I hope you weren't waiting for a better approach from me. Billy's example is exactly what I had in mind for you to use with xp_logininfo. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Billy Pang > Sent: Tuesday, July 06, 2004 9:32 PM > To: dba-sqlserver at databaseadvisors.com > Subject: RE: [dba-SQLServer] Finding current login group > > > perhaps sql server thinks that xp_logininfo is a table in the select > statement quoted in your email. > > if you want to store results from sproc, create a temp table > and then put > sproc after the insert statement.. > > using the sp_who as an example... > > /* cut here */ > CREATE TABLE #TT > ( > spid varchar(100), > ecid varchar(100),status varchar(100), loginame varchar(100), > hostname varchar(100), blk varchar(100),dbname varchar(100), > cmd varchar(100) > ) > go > insert into #TT > EXEC sp_who > go > select spid from #tt > go > DROP TABLE #TT > go > > /* cut here */ > > > >From: David Emerson > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: RE: [dba-SQLServer] Finding current login group > >Date: Wed, 07 Jul 2004 09:58:49 +1200 > > > >Francis, > > > >That is my intention but how do I get the recordset from the > sproc. The > >following doesn't work - > > > >SELECT Permission_Path FROM master..xp_logininfo > > > >Error message is "Invalid object name 'master..xp_logininfo'." > > > >David From my.lists at verizon.net Wed Jul 7 14:16:27 2004 From: my.lists at verizon.net (Francisco H Tapia) Date: Wed, 07 Jul 2004 12:16:27 -0700 Subject: [dba-SQLServer] Locking Issue In-Reply-To: <200407041329.i64DTGQ29904@databaseadvisors.com> References: <200407041329.i64DTGQ29904@databaseadvisors.com> Message-ID: <40EC4C0B.3040601@verizon.net> Locking issues are generated due to a table or set of rows being reserved for a previous purpose. If in your report you are creating temp databases then it is very possible that the temp DB is locked during the attempt to create a new temp table. This happens mostly when you have a long query such as SELECT * INTO #TempTable FROM SomeTable WHERE blah = @variable To avoid this try creating the temp table first CREATE TABLE #TempTable (Field1 Varchar(25), Field2 INT, Field3 DateTIME) INSERT INTO #TempTable (Field1, Feild2, Field3) SELECT Field1, Field2, Field3 From Some Table Where blah = @variable This should aliviate the problem w/ a locking tempdb, if you problem stems from some other set of code, perhaps providing some generalities of your code so we can disect and inspect what is happening under the hood. BTW, you can open up EM and see which process is doing the locking too. look under your current activity icon in the Management folder. Mark Rider wrote On 7/4/2004 6:28 AM: >I have a database that crunches a bunch of data and the boss wants to crunch >the data based on a totally different set of criteria. Can't do it all on >the same DB since it takes about 6 hours to run and we need the two sets of >results as close to the same time as possible. > >I have set up SQL Server on a new machine and have copied the tables I want >to use from the old SQL Server using DTS. Permissions have been set as they >were on the old machine and the new criteria is in place. The VB.NET >program that runs the numbers through the DB is the same as on the old one, >pointing to the local machine's database to get the data. > >About halfway through the program SQL Server throws an error indicating that >there is a problem with Locking and the SQL server process has terminated. >I have tried running this from other PCs, pointing to the new SQL Server and >get the same error. Tables get created as they are supposed to, and sometime >during the Update statement the failure occurs. The table that is getting >Updated is getting updated at first, so there does not seem to be a >permission issue there. > >The main difference between the 'old' SQL Server and the 'new' one is that >the new one has 1 processor and 1 Gb RAM, while the 'old' SQL Server has 2 >processors and 3 Gb RAM. The new SQL Server runs at just about 100% >processor use for several minutes just before the error. Is the lack of >'power' causing the Lock? I have the Physical memory reserved for SQL >Server, Priority Boosted, 32 Worker threads, and dynamic memory allocation >all set up. > >Is there a way to get around this locking problem? BOL seems to indicate >that it is a memory issue, but I cannot find a way to get SQL to slow down >enough to make this work. > >Any ideas will be greatly appreciated! > >Mark Rider > > > -- -Francisco From artful at rogers.com Wed Jul 7 18:33:33 2004 From: artful at rogers.com (Arthur Fuller) Date: Wed, 7 Jul 2004 19:33:33 -0400 Subject: [dba-SQLServer] Finding current login group In-Reply-To: Message-ID: <010a01c4647a$d1b05b00$6601a8c0@rock> You could also rewrite the sproc as a table UDF, which might be a little cleaner. Just a matter of opinion, I suppose. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang Sent: Tuesday, July 06, 2004 9:32 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Finding current login group perhaps sql server thinks that xp_logininfo is a table in the select statement quoted in your email. if you want to store results from sproc, create a temp table and then put sproc after the insert statement.. using the sp_who as an example... /* cut here */ CREATE TABLE #TT ( spid varchar(100), ecid varchar(100),status varchar(100), loginame varchar(100), hostname varchar(100), blk varchar(100),dbname varchar(100), cmd varchar(100) ) go insert into #TT EXEC sp_who go select spid from #tt go DROP TABLE #TT go /* cut here */ >From: David Emerson >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Finding current login group >Date: Wed, 07 Jul 2004 09:58:49 +1200 > >Francis, > >That is my intention but how do I get the recordset from the sproc. >The >following doesn't work - > >SELECT Permission_Path FROM master..xp_logininfo > >Error message is "Invalid object name 'master..xp_logininfo'." > >David > >At 6/07/2004, you wrote: >>David, >> >>Anything wrong with the normal method of creating a temporary table to >>hold the stored procedure results and then selecting what you want? >> >>Francis R Harvey III >>WB 303, (301)294-3952 >>harveyf1 at westat.com >> >> >> > -----Original Message----- >> > From: dba-sqlserver-bounces at databaseadvisors.com >> > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of >> > David Emerson >> > Sent: Tuesday, July 06, 2004 12:59 PM >> > To: dba-sqlserver at databaseadvisors.com >> > Subject: RE: [dba-SQLServer] Finding current login group >> > >> >> > Now, how do I >> > change the sproc so that it returns the value of the permission >> > path column? >> > >> > David >> >>_______________________________________________ >>dba-SQLServer mailing list >>dba-SQLServer at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>http://www.databaseadvisors.com >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN Premium http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU =http://hotmail.com/enca&HL=Market_MSNIS_Taglines _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From tuxedo_man at hotmail.com Wed Jul 7 22:30:46 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Thu, 08 Jul 2004 03:30:46 +0000 Subject: [dba-SQLServer] Finding current login group Message-ID: it is true that it would be cleaner but it is not possible to use "exec sproc" as source when inserting a table variable nor will they let you use temporary tables within functions. Billy >From: "Arthur Fuller" >Reply-To: dba-sqlserver at databaseadvisors.com >To: >Subject: RE: [dba-SQLServer] Finding current login group >Date: Wed, 7 Jul 2004 19:33:33 -0400 > >You could also rewrite the sproc as a table UDF, which might be a little >cleaner. Just a matter of opinion, I suppose. > >Arthur > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy >Pang >Sent: Tuesday, July 06, 2004 9:32 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Finding current login group > > >perhaps sql server thinks that xp_logininfo is a table in the select >statement quoted in your email. > >if you want to store results from sproc, create a temp table and then >put >sproc after the insert statement.. > >using the sp_who as an example... > >/* cut here */ >CREATE TABLE #TT >( >spid varchar(100), >ecid varchar(100),status varchar(100), loginame varchar(100), hostname >varchar(100), blk varchar(100),dbname varchar(100), cmd varchar(100) >) >go >insert into #TT >EXEC sp_who >go >select spid from #tt >go >DROP TABLE #TT >go > >/* cut here */ > > > >From: David Emerson > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: RE: [dba-SQLServer] Finding current login group > >Date: Wed, 07 Jul 2004 09:58:49 +1200 > > > >Francis, > > > >That is my intention but how do I get the recordset from the sproc. > >The > >following doesn't work - > > > >SELECT Permission_Path FROM master..xp_logininfo > > > >Error message is "Invalid object name 'master..xp_logininfo'." > > > >David > > > >At 6/07/2004, you wrote: > >>David, > >> > >>Anything wrong with the normal method of creating a temporary table to > > >>hold the stored procedure results and then selecting what you want? > >> > >>Francis R Harvey III > >>WB 303, (301)294-3952 > >>harveyf1 at westat.com > >> > >> > >> > -----Original Message----- > >> > From: dba-sqlserver-bounces at databaseadvisors.com > >> > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > >> > David Emerson > >> > Sent: Tuesday, July 06, 2004 12:59 PM > >> > To: dba-sqlserver at databaseadvisors.com > >> > Subject: RE: [dba-SQLServer] Finding current login group > >> > > >> > >> > Now, how do I > >> > change the sproc so that it returns the value of the permission > >> > path column? > >> > > >> > David > >> > >>_______________________________________________ > >>dba-SQLServer mailing list > >>dba-SQLServer at databaseadvisors.com > >>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >>http://www.databaseadvisors.com > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > >_________________________________________________________________ >Tired of spam? Get advanced junk mail protection with MSN Premium >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU >=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN Premium helps eliminate e-mail viruses. Get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From davide at dalyn.co.nz Thu Jul 8 18:45:46 2004 From: davide at dalyn.co.nz (David Emerson) Date: Fri, 09 Jul 2004 11:45:46 +1200 Subject: [dba-SQLServer] Finding current login group In-Reply-To: <446DDE75CFC7E1438061462F85557B0F0481E952@remail2.westat.co m> Message-ID: <5.2.0.9.0.20040709114257.00b4c008@mail.dalyn.co.nz> Thanks Billy and Francis (any anyone else who helped). I finally got it working using Billy's code below. David At 7/07/2004, you wrote: >David, > >Sorry, I hope you weren't waiting for a better approach from me. >Billy's example is exactly what I had in mind for you to use >with xp_logininfo. > >Francis R Harvey III >WB 303, (301)294-3952 >harveyf1 at westat.com > > > > -----Original Message----- > > From: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > > Of Billy Pang > > Sent: Tuesday, July 06, 2004 9:32 PM > > To: dba-sqlserver at databaseadvisors.com > > Subject: RE: [dba-SQLServer] Finding current login group > > > > > > perhaps sql server thinks that xp_logininfo is a table in the select > > statement quoted in your email. > > > > if you want to store results from sproc, create a temp table > > and then put > > sproc after the insert statement.. > > > > using the sp_who as an example... > > > > /* cut here */ > > CREATE TABLE #TT > > ( > > spid varchar(100), > > ecid varchar(100),status varchar(100), loginame varchar(100), > > hostname varchar(100), blk varchar(100),dbname varchar(100), > > cmd varchar(100) > > ) > > go > > insert into #TT > > EXEC sp_who > > go > > select spid from #tt > > go > > DROP TABLE #TT > > go > > > > /* cut here */ > > > > > > >From: David Emerson > > >Reply-To: dba-sqlserver at databaseadvisors.com > > >To: dba-sqlserver at databaseadvisors.com > > >Subject: RE: [dba-SQLServer] Finding current login group > > >Date: Wed, 07 Jul 2004 09:58:49 +1200 > > > > > >Francis, > > > > > >That is my intention but how do I get the recordset from the > > sproc. The > > >following doesn't work - > > > > > >SELECT Permission_Path FROM master..xp_logininfo > > > > > >Error message is "Invalid object name 'master..xp_logininfo'." > > > > > >David > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From paul.hartland at fsmail.net Fri Jul 9 03:56:03 2004 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Fri, 9 Jul 2004 10:56:03 +0200 (CEST) Subject: [dba-SQLServer] Installing SQL Server 7.0 Message-ID: <1960719.1089363363693.JavaMail.www@wwinf3002> To all, I have a development server on which I used to run SQL Server 7.0 the server has Windows 2000 on it and was recently re-installed. I re-installed SQL Server 7.0 and now can?t connect to it. I?m sure I have installed as I have done before but must be missing something. Has anyone any ideas what it could be, or a site which can guide me through the whole setup process again. Thanks in advance for any help. Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From HARVEYF1 at WESTAT.com Fri Jul 9 10:04:04 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Fri, 9 Jul 2004 11:04:04 -0400 Subject: [dba-SQLServer] Locking Issue Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E964@remail2.westat.com> Mark, My first inclination is to suggest a redesign of the Master table. I can't imagine how assigning each stock its own column could provide enough of a performance improvement over just creating a single properly indexed stock column to identify the stock for the current row. Then, you would only need to append your individual stock tables to this single master table. If you need the flattened table for reporting, this would then be done by running a pivot on the master table to create a reporting table. I use this approach in one of my databases. Ignoring this, I have to assume that the temp table for each stock is excessively large. Rather than do a whole temp table in a single update, I would break up the temp tables into smaller updates (perhaps using a criteria on time to divide updates into smaller pieces) to reduce the number of locks that would be needed for each update. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Mark Rider > Sent: Tuesday, July 06, 2004 11:05 AM > To: dba-sqlserver at databaseadvisors.com > Subject: RE: [dba-SQLServer] Locking Issue > > > The Update is being done in a SQL statement from VB.Net. The basic > procedure is as follows: > > 1) Import the raw Stock data from a text file (DTS Import) > 2) Loop through the raw data and create a temp table for each Stock, > including Time, Stock Name and Price > 3) Create a Master table with a column for each stock and one > for the Time > 4) Update the Master Table to hold the Price for each Time > for each Stock > > This gives me a table that I can then manipulate as needed to > get the values > for any given Stock and Time. All tables are created from > within the VB.NET > program, so I am pretty sure it is not a permissions issue. > The actual > update statement is: > > UPDATE TempMaster SET > MarketArray(i) = tmpi.AveragePrice FROM tmpi , TempMaster > WHERE tmpi.quoteDate = TempMaster.quoteDate > > The variable "i" is set in the program, and the necessary > punctuation has > been removed for ease of reading. quoteDate is a smalldatetime in all > tables. MarketArray(i) is the Stock Symbol - varchar(5). > AveragePrice id a > decimal. > > This same program runs fine when I point to the original > database - it is > only on the 'new' DB Server that it has problems. > > Thanks for the help! From HARVEYF1 at WESTAT.com Sun Jul 11 13:26:03 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Sun, 11 Jul 2004 14:26:03 -0400 Subject: [dba-SQLServer] Difference between views and queries Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E96E@remail2.westat.com> Billy, As you suggest, you could do a stored procedure for each permutation in your example, but this is unrealistic. However, you could have one stored procedure which would fill a temporary table with the necessary counts based on a parameter value list using IF statements. Your summary isn't quite right. I am not stating that one should not say certain "coding methods" are never needed. I am sure there are techniques that you would never get to agree to use. I am stating that there are a known group of problems for which dynamic sql is often, but not always, the best solution. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Billy Pang > Sent: Wednesday, June 30, 2004 12:57 AM > To: dba-sqlserver at databaseadvisors.com > Subject: RE: [dba-SQLServer] Difference between views and queries > > > oh boy, can't wait to get into this discussion :)...there is > one example I > can think of.. the example would be based on the physical > storage of the > sproc in a single db. it is not possible for a sproc to > query table in > another db that the sproc does not reside in. > > To illustrate, let's say that there are three copies of the > northwind db on > db server: northwind0, northwind1 and northwind2; all three > have exact db > schema; > > Your goal is to develop a report that counts number of records in the > products table in each of the northwind databases. sometimes > you may only > want to count records in northwind0 and northwind1 but not > northwind2; > sometimes you may only want northwind2 and northwind1 but not > northwind0; > and sometimes you want all three northwind dbs in your count. It is > possible to create a sp for each of the permutation but if a fourth > northwind db is introduced to the system, then the code base > is doubled. > > The alternate solution would be to build dynamic sql to piece > together > select statement referencing tables using the > [db].[owner].[table] format; > which tables are pieced together is based on what the user selects as > criteria for report. Not elegant solution but it is a lot > less code to > maintain. > > With that being said, dynamic sql is not as safe for > reporting compared to > sproc. > > I think what Francis is trying to get at is that it is not > possible for a > developer to claim that a particular "coding method" is never > needed. > Rather, it is more correct to state that it is not likely > that a particular > "coding method" is ever needed. Difference between the words > "impossible" > and "improbable". Similiar to how a judge cannot hand out a > verdict to > court case before the case is presented no matter obvious it may seem. > > Another point of reference on this topic would be look up > "Validating User > Input" in BOL for best practices on this issue. > > Billy From tuxedo_man at hotmail.com Sun Jul 11 13:53:19 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Sun, 11 Jul 2004 18:53:19 +0000 Subject: [dba-SQLServer] Difference between views and queries Message-ID: See below: >Your summary isn't quite right. I am not stating that one should not >say certain "coding methods" are never needed. I am sure there are >techniques that you would never get to agree to use. Oops, sorry about that. Didn't mean to put your words in your mouth :) My apologies. Billy _________________________________________________________________ Free yourself from those irritating pop-up ads with MSn Premium. Get 2months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From HARVEYF1 at WESTAT.com Sun Jul 11 14:19:48 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Sun, 11 Jul 2004 15:19:48 -0400 Subject: [dba-SQLServer] Difference between views and queries Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E96F@remail2.westat.com> Arthur, Your opinion is not the issue, the way in which you present it is. Whether you are personally ignorant or not, your posts on this topic have failed to display much evidence of being aware of the subtleties of the issue although you have not shied from making bold sweeping statements without suitable caveats. Reviewing some of your posts, "Dynamic SQL is NOT the way to go once you port to SQL Server. You need to rethink all these parts of your app and replace them with sprocs that can handle all the parms you might pass to your SQL-construction code." "NO users except sa (and possibly developers) should have access to any SQL table. Everything should be done with views or sprocs or UDFs. No exceptions." "I haven't yet seen a case where dynamic SQL is necessary. All it takes to avoid it is one or more well-constructed sprocs, IMO." Given your most recent comment to Billy, "Good example, and good reasoning, and I agree that dynamic SQL is never out of the question." should I assume that you were never ignorant of an example of a good use for dynamic SQL but just decided to post your claims as if there were no reasonable uses anyway or should I assume as you state in your last post that you were ignorant. Note, I do not care in whether reading the posts from David Lewis or myself on how Billy's problem could be done without using dynamic sql changes your opinion back to no dynamic sql usage again. I just challenge you to question whether you really think you have sufficiently researched this topic to make the kind of claims you originally made. At the least, for those who read your statements to gain knowledge of the subject, if you truly are aware of the issues as you state, you might consider mentioning them in your post. BTW, feel free to requote yourself in more detail if you think you are taken out of context, but I think you will fail to find any qualifications you added to your statements. Your example for different problems with different SQL dialects is actually rather interesting. You present the problems with insisting on no dynamic sql quite well but don't state this is another valid example where dynamic sql may be the only choice. As you have proved the case for usage, I am certainly not going to argue with you. I have no real way of knowing whether you understand dynamic search from your example, but I will be fair and state my references, so you can be sure I do. Working with Sommarskog's dynamic sql summary, http://www.sommarskog.se/dyn-search.html#dynsql, I move to section "Using Static SQL" and try to find your example. You seem to be referring to "Using IF statements" which is cute, but I immediately class myself out of this problem as I do not have just a few primary search parameters. Wrapping the alternatives is, as he says an acceptable variation, but it doesn't change the fact that I can't use this approach. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Arthur Fuller > Sent: Wednesday, June 30, 2004 11:09 AM > To: dba-sqlserver at databaseadvisors.com > Subject: RE: [dba-SQLServer] Difference between views and queries > > > You have a backhanded way of calling me ignorant. In many ways and in > many areas I am ignorant, but just because I hold an opinion that > differs from yours, that's no reason for you to assume that I > am unaware > of the issues you raise. I worked on a project for ABB which > relied on a > database comprising over 400 tables and ran in both Oracle and SQL > Server. Both versions used sprocs of the same name. Where there were > differences in syntax, they were encapsulated in the sprocs. From the > viewpoint of the various Front End modules, it didn't matter which > database you were talking to. The FE had virtually no knowledge of the > back end flavour, other than the connection. Now, granted, should ABB > decide suddenly to support MySQL, and given MySQL's limited support of > sprocs, well then there is a problem. Any fool can recognize > that -- but > substitute Access for MySQL and you have the same problem. This is > beneath discussion. > > Regarding dynamic search, I have done at least one form that > presents 25 > controls and invokes one sproc that in turn invokes others, > depending on > which parameters are null. No problem there. Add a control later in > development, I change a sproc and maybe add another few. No problem > there either. > > Does this constitute research into the issues involved? > > Arthur From HARVEYF1 at WESTAT.com Sun Jul 11 14:33:49 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Sun, 11 Jul 2004 15:33:49 -0400 Subject: [dba-SQLServer] RE: Difference between views and queries (Bil ly Pang) Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E970@remail2.westat.com> David, Okay, let's make this example a little more difficult and see if we can't find something outside a system table. Let's say the table is now the order details table, and Billy needs quartile values of unit price from each Northwind database. I didn't say it would be a good example. Anyway, I'm still stuck appending things to my temp table if I want to keep static SQL. As I didn't even think of your approach when Billy first suggested his example, I am really curious what your approach would be. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of David Lewis > Sent: Wednesday, June 30, 2004 11:26 AM > To: dba-sqlserver at databaseadvisors.com > Cc: tuxedo_man at hotmail.com > Subject: [dba-SQLServer] RE: Difference between views and > queries (Billy Pang) > > > Hi All: > > Regarding Billy Pang's comment: > > > . it is not possible for a sproc to > > query table in > > another db that the sproc does not reside in. > > you note later in your comment that the syntax > [db].[objectowner].[objectname] will make the above possible. > So, to avoid dynamic sql for the problem you've posed one > could do the following: > > 1) if the number/names of the databases is not static, the > user interface (let's assume it is web based) could query the > server or servers and build a list of all available databases. > > 2) if the tables to be examined are another variable, the > next step would be to present a list of [db]..[tablename] > from each database selected. > > 3)a comma delimited string of > [database].[objectowner].[tablename] could be delivered to a > sproc, which would then parse it (a udf can accomplish this, > or it could be done directly in the sproc), after which the > appropriate system tables could be queried. > > This is not to say that dynamic sql is never necessary, but I > think the above approach would allow one to avoid it (if that > was the goal) for the problem you've posed. > > P.S. I think Billy's question has made the dynamic sql vs. > stored procedures topic practical. It was beginning to get a > touch dogmatic, and, dare I say it, personal ... :) > > > Kind regards to all. D. Lewis From HARVEYF1 at WESTAT.com Sun Jul 11 15:07:51 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Sun, 11 Jul 2004 16:07:51 -0400 Subject: [dba-SQLServer] Difference between views and queries Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E971@remail2.westat.com> Francisco, This is almost scary, "terms that have nothing to do w/ SQL Server". I don't know whether to feel pity or just despair. Seriously Francisco, you've moved from accusing me of never posting my search terms despite having requoted them in your own post, having had two initial reposts and then a final third just for you, to classifying them as having nothing to do with SQL Server. Seeing as how others have not had any problem relating these concepts to SQL Server, I guess I will just assume it's you. Francisco, you still don't get the point of a straw man argument. Read your own comments. As you say, my opinion on dynamic sql was made, "w/o any backing and then expecting everyone else to look it up" Exactly, up till that point, you could certainly accuse me of laziness or making unsupported claims but not of distorting the other side's position because I didn't bother to make any arguments at all for either side. Your attempts to get me to defend your pathetic example of a suitable sproc for dynamic sql certainly is a straw man argument. I doubt you even felt that was the best example for debate. If you did, well, hence the research suggestion. Okay, I'll agree this latest example isn't a straw man example, http://www.sqlservercentral.com/columnists/rmarda/whendynamics qlisuseful_printversion.asp although I don't agree with all the justifications either. However, I know what my objections are and to be fair here is my reference http://www.sommarskog.se/dynamic_sql.html, specifically, the "Common Cases when to (Not) Use Dynamic SQL" sections that correspond to each example. What do you find to be a far stretch exactly? I myself am having trouble with example #1; I know there is something wrong with it, but I am so used to having Sommarskog's article to rely on for all the bad examples that I can't quite get it yet. I guess I'd still be willing to defend it, for now, but you have to be a little more specific with your objections. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Francisco H Tapia > Sent: Wednesday, June 30, 2004 11:56 AM > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] Difference between views and queries > > > Yet you keep arguing that it is possible for a need for > Dynamic SQL. :), > w/o any backing and then expecting everyone else to look it up, > including terms that have nothing to do w/ SQL Server, > perhaps you need > a link for strawman. It's sad really, but here's the link if > you need one. > > Straw Man > http://www.nizkor.org/features/fallacies/straw-man.html > Dynamic vs Static > http://www.sqlservercentral.com/columnists/rmarda/whendynamics qlisuseful_printversion.asp in this basic argument (you may need a free registration w/ Sql Server Central to read the article). it is a far stretch just to justify the use of dynamic sql. From HARVEYF1 at WESTAT.com Sun Jul 11 15:15:40 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Sun, 11 Jul 2004 16:15:40 -0400 Subject: [dba-SQLServer] Re: Difference between views and queries Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E972@remail2.westat.com> Robert, Fine, I'll restrict myself to the members of this list, as these posts in fact are. If someone posted a problem where it was obvious there database was non-normalized, would you just issue a blanket statement accusing them of being lazy or would you ask why? As we have just had a locking issue post illustrating this situation, this is not just a possible scenario. I did suggest Mark might normalize his database, but I didn't just assume it wasn't done because of laziness nor did I issue a blanket condemnation. I find that to be the true laziness. Just ask why, or if providing guidelines on proper database creation, suggest there may be exceptions even if you don't list them. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Robert L. Stewart > Sent: Wednesday, June 30, 2004 1:18 PM > To: dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] Re: Difference between views and queries > > > Francis, > > Actually the reason most databases are not fully normalized is not > laziness, but ignorance. Most DBA's know nothing about > normalization and > many developers even less. And, yes I would make such a > blanket statement. > > Robert From HARVEYF1 at WESTAT.com Sun Jul 11 15:21:10 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Sun, 11 Jul 2004 16:21:10 -0400 Subject: [dba-SQLServer] Re: Difference between views and queries Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E973@remail2.westat.com> Robert, Before I start another topic, let's be clear. Are you saying that there is no usage for denormalized design in a transcationsal database or are you just saying it is unlikely in general? Again, I would take exception to the "should be normalized" if you are making a blanket statement for all transactional database, but not if you were to say in general or with possible exceptions. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Robert L. Stewart > Sent: Thursday, July 01, 2004 11:48 AM > To: dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] Re: Difference between views and queries > > > I made the assumption that we were talking about databases that were > transactional and should be normalized. From martyconnelly at shaw.ca Sun Jul 11 15:42:41 2004 From: martyconnelly at shaw.ca (MartyConnelly) Date: Sun, 11 Jul 2004 13:42:41 -0700 Subject: [dba-SQLServer] Difference between views and queries References: <001c01c44f08$a5d922a0$7e01a8c0@colbyws> Message-ID: <40F1A641.1020506@shaw.ca> jwcolby wrote: >Can anyone explain the difference between a view and a query? Views use a >query, plus the view keyword. I have a couple of books that I have read the >chapter on Views, but I so far haven't managed to "get" why you wouldn't >just use the query itself instead of turning it into a view. > > > Interestingly ADOX catalogs describes Access queries as Type VIEW Sub testa() 'Declare a reference to an ADOX Catalog Object Dim cat1 As New ADOX.Catalog Dim cnn1 As ADODB.Connection Dim c As Object Dim cn As ADODB.Connection Set cnn1 = New ADODB.Connection cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb;" 'cnn1.Open "Provider=sqloledb;" & _ ' "Data Source=(local);" & _ ' "Initial Catalog=Pubs;" & _ ' "User Id=sa;" & _ ' "Password=" 'Open an ADO Connection Object 'Assign the connection to the catalog cat1.ActiveConnection = cnn1 'Loop through the tables in the catalog Dim str1 As String Dim tbl1 As ADOX.Table For Each tbl1 In cat1.Tables Debug.Print tbl1.Type & "-"; tbl1.Name If tbl1.Type = "TABLE" Then str1 = str1 & tbl1.Name & vbCr End If Next Debug.Print str1 End Sub -- Marty Connelly Victoria, B.C. Canada From shamil at users.mns.ru Mon Jul 12 13:56:08 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Mon, 12 Jul 2004 22:56:08 +0400 Subject: [dba-SQLServer] Difference between views and queries References: <001c01c44f08$a5d922a0$7e01a8c0@colbyws> <40F1A641.1020506@shaw.ca> Message-ID: <001901c46841$e6cfaf70$0201a8c0@PARIS> > jwcolby wrote: >Can anyone explain the difference between a view and a query? Are you talking about MS SQL 2000 views? If yes, then here is what you can do with views and cannot with just T-SQL queries: - views can be indexed - these indexes use statistics, these statistics could be updated - so with views you can fine tune performance of the data querying; - views may have triggers - you can use such (instead of insert/update) triggers to insert into/update very tricky views, which can't be updated using plain update queries; - views can use WITH CHECK OPTION to prevernt inconsistent updates; - views can use SCHEMABINDING option by thus preventing deletion of the veiws/tables they are defined on before deletion of these queries; - views can be partitioned within one of several data files/servers - this allows advanced perfomance tuning... .... Shamil ----- Original Message ----- From: "MartyConnelly" To: Sent: Monday, July 12, 2004 12:42 AM Subject: Re: [dba-SQLServer] Difference between views and queries > jwcolby wrote: > > >Can anyone explain the difference between a view and a query? Views use a > >query, plus the view keyword. I have a couple of books that I have read the > >chapter on Views, but I so far haven't managed to "get" why you wouldn't > >just use the query itself instead of turning it into a view. > > > > > > > Interestingly ADOX catalogs describes Access queries as Type VIEW > > Sub testa() > 'Declare a reference to an ADOX Catalog Object > Dim cat1 As New ADOX.Catalog > Dim cnn1 As ADODB.Connection > Dim c As Object > Dim cn As ADODB.Connection > Set cnn1 = New ADODB.Connection > > cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ > "Data Source=C:\Program Files\Microsoft > Office\Office\Samples\Northwind.mdb;" > > 'cnn1.Open "Provider=sqloledb;" & _ > ' "Data Source=(local);" & _ > ' "Initial Catalog=Pubs;" & _ > ' "User Id=sa;" & _ > ' "Password=" > > 'Open an ADO Connection Object > 'Assign the connection to the catalog > cat1.ActiveConnection = cnn1 > > 'Loop through the tables in the catalog > Dim str1 As String > Dim tbl1 As ADOX.Table > For Each tbl1 In cat1.Tables > Debug.Print tbl1.Type & "-"; tbl1.Name > If tbl1.Type = "TABLE" Then > str1 = str1 & tbl1.Name & vbCr > > End If > Next > Debug.Print str1 > > End Sub > > > -- > Marty Connelly > Victoria, B.C. > Canada > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From CMackin at Quiznos.com Mon Jul 12 18:36:55 2004 From: CMackin at Quiznos.com (Mackin, Christopher) Date: Mon, 12 Jul 2004 17:36:55 -0600 Subject: [dba-SQLServer] Output to Text File Message-ID: Hi, I have a daily fixed width text file that I need to produce and I am currently generating it via VBA code, but am trying to post it to a SQL Job. I have it set up to output to the proper file, the problem is that at the top of the file there is header info that I need to eliminate. It looks like the following: Job 'VPP' : Step 1, 'Create File' : Began Executing 2114-17-12 17:31:31 OutputLine -------------------------------------------------------------------------------- 813 212111132122111119987 111446349317132114 813 212111132122111119988 111619832817132114 Starting with the 813 is the data that I need in there, everything above needs to go, does anyone know how to do this? Also, what other methods are people using to generate Text files from T-SQL? Thanks, Chris Mackin From shamil at users.mns.ru Tue Jul 13 03:06:56 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Tue, 13 Jul 2004 12:06:56 +0400 Subject: [dba-SQLServer] Output to Text File References: Message-ID: <000701c468b0$5f57aa10$0201a8c0@PARIS> Christopher, You can use bcp - here is a sample(watch line wraps) of one step T-SQL job: -- dropping temp table if exists (select * from tempdb.dbo.sysobjects where name = '##T1') drop table [dbo].[##T1] go -- creating temp table CREATE TABLE ##T1 ( column_1 int, column_2 nvarchar(30)) INSERT ##T1 VALUES (1, 'Row #1') INSERT ##T1 VALUES (2, 'Row #2') INSERT ##T1 VALUES (3, 'Row #3') go -- bcp-ing temp table data master..xp_cmdshell 'bcp ##T1 out d:\temp\export\temp_T1.txt -c -C850 -SYOUR_SERVER_NAME -T' go HTH, Shamil ----- Original Message ----- From: "Mackin, Christopher" To: Sent: Tuesday, July 13, 2004 3:36 AM Subject: [dba-SQLServer] Output to Text File > Hi, > > I have a daily fixed width text file that I need to produce and I am currently generating it via VBA code, but am trying to post it to a SQL Job. I have it set up to output to the proper file, the problem is that at the top of the file there is header info that I need to eliminate. It looks like the following: > > Job 'VPP' : Step 1, 'Create File' : Began Executing 2114-17-12 17:31:31 > > OutputLine > ---------------------------------------------------------------------- ---------- > 813 212111132122111119987 111446349317132114 > 813 212111132122111119988 111619832817132114 > > Starting with the 813 is the data that I need in there, everything above needs to go, does anyone know how to do this? > > Also, what other methods are people using to generate Text files from T-SQL? > > Thanks, > Chris Mackin > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From tuxedo_man at hotmail.com Tue Jul 13 12:38:41 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Tue, 13 Jul 2004 17:38:41 +0000 Subject: [dba-SQLServer] Output to Text File Message-ID: Also, not sure if this is useful to you but QA can output results to text file on local machine without column headers... from QA, press CTNL+SHFT+F all at once when you execute a query and it will prompt for file name. Billy >From: "Shamil Salakhetdinov" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] Output to Text File >Date: Tue, 13 Jul 2004 12:06:56 +0400 > >Christopher, > >You can use bcp - here is a sample(watch line wraps) of one step T-SQL >job: > >-- dropping temp table >if exists (select * from tempdb.dbo.sysobjects where name = '##T1') > drop table [dbo].[##T1] >go >-- creating temp table >CREATE TABLE ##T1 ( column_1 int, column_2 nvarchar(30)) >INSERT ##T1 VALUES (1, 'Row #1') >INSERT ##T1 VALUES (2, 'Row #2') >INSERT ##T1 VALUES (3, 'Row #3') >go >-- bcp-ing temp table data >master..xp_cmdshell 'bcp ##T1 out >d:\temp\export\temp_T1.txt -c -C850 -SYOUR_SERVER_NAME -T' >go > >HTH, >Shamil > >----- Original Message ----- >From: "Mackin, Christopher" >To: >Sent: Tuesday, July 13, 2004 3:36 AM >Subject: [dba-SQLServer] Output to Text File > > > > Hi, > > > > I have a daily fixed width text file that I need to produce and I am >currently generating it via VBA code, but am trying to post it to a SQL >Job. I have it set up to output to the proper file, the problem is that >at the top of the file there is header info that I need to eliminate. >It looks like the following: > > > > Job 'VPP' : Step 1, 'Create File' : Began Executing 2114-17-12 >17:31:31 > > > > OutputLine > > ---------------------------------------------------------------------- >---------- > > 813 212111132122111119987 111446349317132114 > > 813 212111132122111119988 111619832817132114 > > > > Starting with the 813 is the data that I need in there, everything >above needs to go, does anyone know how to do this? > > > > Also, what other methods are people using to generate Text files from >T-SQL? > > > > Thanks, > > Chris Mackin > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ STOP MORE SPAM with the MSN Premium and get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From tuxedo_man at hotmail.com Tue Jul 13 22:34:38 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Wed, 14 Jul 2004 03:34:38 +0000 Subject: [dba-SQLServer] tsql help - propogate that pk Message-ID: Hello: I am wondering, is possible to propogate the values of primary key into a foreign key of another table from a view insert. To illustrate, please see following illustration: /* ---- cut here ---- */ use tempdb go begin tran set nocount on go create table tablea(tablea_id int not null identity(1,1) primary key, tablea_value varchar(50) ); go create table tableb(tableb_id int not null identity(1,1) primary key, tableb_tablea_id int constraint fk_tableb_tablea_id foreign key references tablea(tablea_id), tableb_value varchar(50) ); go create view dd1 as select tablea_id, tablea_value, tableb_id, tableb_value from tablea inner join tableb on tablea_id = tableb_tablea_id go insert into dd1(tablea_value, tableb_value) values('eee1b','eee1b'); /* above insert results with "Server: Msg 4405, Level 16, State 2, Line 1" */ /* View or function 'dd1' is not updatable because the modification affects multiple base tables. */ go rollback; /* ---- cut here ---- */ In the above example, tableb has tablea_id fk. I have a view that joins those two tables together. When a record is insert into the view, I would like it to automatically populate both tablea and tableb (yes, that includes having the tableb_table_id column populated with the value of the tablea_id column that was just created). Sometimes, the insert statement that populates the view might use a SELECT as a source. Can this be done (without using a db cursor)? thanks in advance Billy _________________________________________________________________ MSN Premium: Up to 11 personalized e-mail addresses and 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From paul.hartland at fsmail.net Wed Jul 14 03:04:51 2004 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Wed, 14 Jul 2004 10:04:51 +0200 (CEST) Subject: [dba-SQLServer] Maintenance Plans Message-ID: <16440074.1089792291431.JavaMail.www@wwinf3006> To all, Hope someone can come up with a solution, I have SQL Server 7.0 running on a Windows 2000 server I also have two of my own database?s that I have just finished transferring to SQL Server. But before I start any front-end work I decided to use a maintenance plan using the wizard, have just checked the backup directory where the backups should be and nothing there at all and the backups don?t seem to be anywhere else. Why would a maintenance plan not run, anything I can do to check what happening. Thanks in advance for any help. Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From tuxedo_man at hotmail.com Wed Jul 14 03:58:01 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Wed, 14 Jul 2004 08:58:01 +0000 Subject: [dba-SQLServer] Maintenance Plans Message-ID: perhaps the security login context does not allow the maintenance plans to execute. not sure about ss7.0 but check the sql server agent job history logs to find anything suspicous. >From: paul.hartland at fsmail.net >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver >Subject: [dba-SQLServer] Maintenance Plans >Date: Wed, 14 Jul 2004 10:04:51 +0200 (CEST) > >To all, > >Hope someone can come up with a solution, I have SQL Server 7.0 running on >a Windows 2000 server I also have two of my own database?s that I have just >finished transferring to SQL Server. But before I start any front-end work >I decided to use a maintenance plan using the wizard, have just checked the >backup directory where the backups should be and nothing there at all and >the backups don?t seem to be anywhere else. > >Why would a maintenance plan not run, anything I can do to check what >happening. > >Thanks in advance for any help. > >Paul Hartland > >-- > >Whatever you Wanadoo: >http://www.wanadoo.co.uk/time/ > >This email has been checked for most known viruses - find out more at: >http://www.wanadoo.co.uk/help/id/7098.htm >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN Premium includes powerful parental controls and get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From paul.hartland at fsmail.net Wed Jul 14 04:33:12 2004 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Wed, 14 Jul 2004 11:33:12 +0200 (CEST) Subject: [dba-SQLServer] Maintenance Plans Message-ID: <5883147.1089797592192.JavaMail.www@wwinf3004> Thanks, will have a look at that. Paul Message date : Jul 14 2004, 10:00 AM >From : "Billy Pang" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] Maintenance Plans perhaps the security login context does not allow the maintenance plans to execute. not sure about ss7.0 but check the sql server agent job history logs to find anything suspicous. >From: paul.hartland at fsmail.net >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver >Subject: [dba-SQLServer] Maintenance Plans >Date: Wed, 14 Jul 2004 10:04:51 +0200 (CEST) > >To all, > >Hope someone can come up with a solution, I have SQL Server 7.0 running on >a Windows 2000 server I also have two of my own database?s that I have just >finished transferring to SQL Server. But before I start any front-end work >I decided to use a maintenance plan using the wizard, have just checked the >backup directory where the backups should be and nothing there at all and >the backups don?t seem to be anywhere else. > >Why would a maintenance plan not run, anything I can do to check what >happening. > >Thanks in advance for any help. > >Paul Hartland > >-- > >Whatever you Wanadoo: >http://www.wanadoo.co.uk/time/ > >This email has been checked for most known viruses - find out more at: >http://www.wanadoo.co.uk/help/id/7098.htm >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN Premium includes powerful parental controls and get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From CMackin at Quiznos.com Wed Jul 14 08:55:24 2004 From: CMackin at Quiznos.com (Mackin, Christopher) Date: Wed, 14 Jul 2004 07:55:24 -0600 Subject: [dba-SQLServer] Maintenance Plans Message-ID: You can look at the Jobs and verify the schedule the parts of the plan should be running on and some other info you can verify. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Wednesday, July 14, 2004 3:33 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: [dba-SQLServer] Maintenance Plans Thanks, will have a look at that. Paul Message date : Jul 14 2004, 10:00 AM >From : "Billy Pang" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] Maintenance Plans perhaps the security login context does not allow the maintenance plans to execute. not sure about ss7.0 but check the sql server agent job history logs to find anything suspicous. >From: paul.hartland at fsmail.net >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver >Subject: [dba-SQLServer] Maintenance Plans >Date: Wed, 14 Jul 2004 10:04:51 +0200 (CEST) > >To all, > >Hope someone can come up with a solution, I have SQL Server 7.0 running on >a Windows 2000 server I also have two of my own database's that I have just >finished transferring to SQL Server. But before I start any front-end work >I decided to use a maintenance plan using the wizard, have just checked the >backup directory where the backups should be and nothing there at all and >the backups don't seem to be anywhere else. > >Why would a maintenance plan not run, anything I can do to check what >happening. > >Thanks in advance for any help. > >Paul Hartland > >-- > >Whatever you Wanadoo: >http://www.wanadoo.co.uk/time/ > >This email has been checked for most known viruses - find out more at: >http://www.wanadoo.co.uk/help/id/7098.htm >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN Premium includes powerful parental controls and get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From artful at rogers.com Wed Jul 14 10:30:20 2004 From: artful at rogers.com (Arthur Fuller) Date: Wed, 14 Jul 2004 11:30:20 -0400 Subject: [dba-SQLServer] Difference between views and queries In-Reply-To: <001901c46841$e6cfaf70$0201a8c0@PARIS> Message-ID: <012201c469b7$799c3af0$6601a8c0@rock> Just a followup to Shamil's concise list of cool things about views. Indexed views provide pretty dramatic performance increases, but not without cost. Inserts and updates are slower, so they are best used with tables that are updated/added to relatively rarely. This does not mean that they should be used only with lookup tables. Some transaction applications rarely update data once it's in, and don't do huge volumes of inserts either. Best to check performance on a copy of the real database first, just to see what the cost is going to be. I just wrote a piece about using Instead Of triggers to make un-updatable views updatable. It should appear soon in a e-zine near you :) Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Shamil Salakhetdinov Sent: Monday, July 12, 2004 2:56 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Difference between views and queries > jwcolby wrote: >Can anyone explain the difference between a view and a query? Are you talking about MS SQL 2000 views? If yes, then here is what you can do with views and cannot with just T-SQL queries: - views can be indexed - these indexes use statistics, these statistics could be updated - so with views you can fine tune performance of the data querying; - views may have triggers - you can use such (instead of insert/update) triggers to insert into/update very tricky views, which can't be updated using plain update queries; - views can use WITH CHECK OPTION to prevernt inconsistent updates; - views can use SCHEMABINDING option by thus preventing deletion of the veiws/tables they are defined on before deletion of these queries; - views can be partitioned within one of several data files/servers - this allows advanced perfomance tuning... .... Shamil ----- Original Message ----- From: "MartyConnelly" To: Sent: Monday, July 12, 2004 12:42 AM Subject: Re: [dba-SQLServer] Difference between views and queries > jwcolby wrote: > > >Can anyone explain the difference between a view and a query? Views use a > >query, plus the view keyword. I have a couple of books that I have read the > >chapter on Views, but I so far haven't managed to "get" why you wouldn't > >just use the query itself instead of turning it into a view. > > > > > > > Interestingly ADOX catalogs describes Access queries as Type VIEW > > Sub testa() > 'Declare a reference to an ADOX Catalog Object > Dim cat1 As New ADOX.Catalog > Dim cnn1 As ADODB.Connection > Dim c As Object > Dim cn As ADODB.Connection > Set cnn1 = New ADODB.Connection > > cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ > "Data Source=C:\Program Files\Microsoft > Office\Office\Samples\Northwind.mdb;" > > 'cnn1.Open "Provider=sqloledb;" & _ > ' "Data Source=(local);" & _ > ' "Initial Catalog=Pubs;" & _ > ' "User Id=sa;" & _ > ' "Password=" > > 'Open an ADO Connection Object > 'Assign the connection to the catalog > cat1.ActiveConnection = cnn1 > > 'Loop through the tables in the catalog > Dim str1 As String > Dim tbl1 As ADOX.Table > For Each tbl1 In cat1.Tables > Debug.Print tbl1.Type & "-"; tbl1.Name > If tbl1.Type = "TABLE" Then > str1 = str1 & tbl1.Name & vbCr > > End If > Next > Debug.Print str1 > > End Sub > > > -- > Marty Connelly > Victoria, B.C. > Canada > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From shamil at users.mns.ru Wed Jul 14 14:15:55 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Wed, 14 Jul 2004 23:15:55 +0400 Subject: [dba-SQLServer] tsql help - propogate that pk References: Message-ID: <000701c469d6$fe934a40$0201a8c0@PARIS> Billy, I think that "Instead of Insert" trigger should help you to do the trick. Shamil ----- Original Message ----- From: "Billy Pang" To: Sent: Wednesday, July 14, 2004 7:34 AM Subject: [dba-SQLServer] tsql help - propogate that pk > Hello: > > I am wondering, is possible to propogate the values of primary key into a > foreign key of another table from a view insert. > > To illustrate, please see following illustration: > > /* ---- cut here ---- */ > > use tempdb > go > begin tran > set nocount on > go > create table tablea(tablea_id int not null identity(1,1) primary key, > tablea_value varchar(50) > ); > go > > create table tableb(tableb_id int not null identity(1,1) primary key, > tableb_tablea_id int constraint fk_tableb_tablea_id foreign key references > tablea(tablea_id), > tableb_value varchar(50) > ); > go > create view dd1 as > select tablea_id, tablea_value, tableb_id, tableb_value from tablea inner > join tableb on tablea_id = tableb_tablea_id > go > insert into dd1(tablea_value, tableb_value) values('eee1b','eee1b'); > > /* above insert results with "Server: Msg 4405, Level 16, State 2, Line 1" > */ > > /* View or function 'dd1' is not updatable because the modification affects > multiple base tables. */ > go > rollback; > /* ---- cut here ---- */ > > In the above example, tableb has tablea_id fk. I have a view that joins > those two tables together. When a record is insert into the view, I would > like it to automatically populate both tablea and tableb (yes, that includes > having the tableb_table_id column populated with the value of the tablea_id > column that was just created). Sometimes, the insert statement that > populates the view might use a SELECT as a source. Can this be done > (without using a db cursor)? > > thanks in advance > > Billy > > _________________________________________________________________ > MSN Premium: Up to 11 personalized e-mail addresses and 2 months FREE* > http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From sgeller at cce.umn.edu Wed Jul 14 14:22:10 2004 From: sgeller at cce.umn.edu (Susan Geller) Date: Wed, 14 Jul 2004 14:22:10 -0500 Subject: [dba-SQLServer] Date field type Message-ID: In my sql server 2000 table, I have a date field. When I display that field in a query it displays as yyyy-mm-dd and then a timestamp. I want dd/mm/yyyy and no time. I converted it using this syntax convert(varchar, milestone_dt, 101) and I get what I want, EXCEPT, when I try to sort by that field, it sorts as a varchar, not as a date, so I have all my January's together instead of all my 2004's together. Can I have this format and still keep it as a date field so it will sort correctly? --Susan Susan B. Geller Office of Information Systems College of Continuing Education University of Minnesota 306 Wesbrook Hall 77 Pleasant Street SE Minneapolis, MN 55455 Phone: 612-626-4785 Fax: 612-625-2568 From kens.programming at verizon.net Wed Jul 14 14:49:33 2004 From: kens.programming at verizon.net (Ken Stoker) Date: Wed, 14 Jul 2004 12:49:33 -0700 Subject: [dba-SQLServer] Date field type In-Reply-To: Message-ID: <20040714194855.SUS27801.out008.verizon.net@enterprise> Susan, Someone on here once gave me this option (sorry I don't remember who it was, but he/she was someone smarter than me). CONVERT(datetime, FLOOR(CONVERT(REAL, YourDate))) Hope this helps. Ken -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Geller Sent: Wednesday, July 14, 2004 12:22 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Date field type In my sql server 2000 table, I have a date field. When I display that field in a query it displays as yyyy-mm-dd and then a timestamp. I want dd/mm/yyyy and no time. I converted it using this syntax convert(varchar, milestone_dt, 101) and I get what I want, EXCEPT, when I try to sort by that field, it sorts as a varchar, not as a date, so I have all my January's together instead of all my 2004's together. Can I have this format and still keep it as a date field so it will sort correctly? --Susan Susan B. Geller Office of Information Systems College of Continuing Education University of Minnesota 306 Wesbrook Hall 77 Pleasant Street SE Minneapolis, MN 55455 Phone: 612-626-4785 Fax: 612-625-2568 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From CMackin at Quiznos.com Wed Jul 14 14:54:24 2004 From: CMackin at Quiznos.com (Mackin, Christopher) Date: Wed, 14 Jul 2004 13:54:24 -0600 Subject: [dba-SQLServer] Date field type Message-ID: If you do all your formatting on the report or form that your users use you can avoid that problem. Alternatively, add another field that has the real date in it and sort by that. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Susan Geller Sent: Wednesday, July 14, 2004 1:22 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Date field type In my sql server 2000 table, I have a date field. When I display that field in a query it displays as yyyy-mm-dd and then a timestamp. I want dd/mm/yyyy and no time. I converted it using this syntax convert(varchar, milestone_dt, 101) and I get what I want, EXCEPT, when I try to sort by that field, it sorts as a varchar, not as a date, so I have all my January's together instead of all my 2004's together. Can I have this format and still keep it as a date field so it will sort correctly? --Susan Susan B. Geller Office of Information Systems College of Continuing Education University of Minnesota 306 Wesbrook Hall 77 Pleasant Street SE Minneapolis, MN 55455 Phone: 612-626-4785 Fax: 612-625-2568 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From tuxedo_man at hotmail.com Wed Jul 14 16:24:14 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Wed, 14 Jul 2004 21:24:14 +0000 Subject: [dba-SQLServer] tsql help - propogate that pk Message-ID: how? the "instead of insert" trigger can insert a record into tablea first but how can I get the tablea_id of the records just inserted and insert those values into tableb_tablea_id column? thanks in advance, Billy >From: "Shamil Salakhetdinov" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] tsql help - propogate that pk >Date: Wed, 14 Jul 2004 23:15:55 +0400 > >Billy, > >I think that "Instead of Insert" trigger should help you to do the >trick. > >Shamil > >----- Original Message ----- >From: "Billy Pang" >To: >Sent: Wednesday, July 14, 2004 7:34 AM >Subject: [dba-SQLServer] tsql help - propogate that pk > > > > Hello: > > > > I am wondering, is possible to propogate the values of primary key >into a > > foreign key of another table from a view insert. > > > > To illustrate, please see following illustration: > > > > /* ---- cut here ---- */ > > > > use tempdb > > go > > begin tran > > set nocount on > > go > > create table tablea(tablea_id int not null identity(1,1) primary key, > > tablea_value varchar(50) > > ); > > go > > > > create table tableb(tableb_id int not null identity(1,1) primary key, > > tableb_tablea_id int constraint fk_tableb_tablea_id foreign key >references > > tablea(tablea_id), > > tableb_value varchar(50) > > ); > > go > > create view dd1 as > > select tablea_id, tablea_value, tableb_id, tableb_value from tablea >inner > > join tableb on tablea_id = tableb_tablea_id > > go > > insert into dd1(tablea_value, tableb_value) values('eee1b','eee1b'); > > > > /* above insert results with "Server: Msg 4405, Level 16, State 2, >Line 1" > > */ > > > > /* View or function 'dd1' is not updatable because the modification >affects > > multiple base tables. */ > > go > > rollback; > > /* ---- cut here ---- */ > > > > In the above example, tableb has tablea_id fk. I have a view that >joins > > those two tables together. When a record is insert into the view, I >would > > like it to automatically populate both tablea and tableb (yes, that >includes > > having the tableb_table_id column populated with the value of the >tablea_id > > column that was just created). Sometimes, the insert statement that > > populates the view might use a SELECT as a source. Can this be done > > (without using a db cursor)? > > > > thanks in advance > > > > Billy > > > > _________________________________________________________________ > > MSN Premium: Up to 11 personalized e-mail addresses and 2 months FREE* > > >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Free yourself from those irritating pop-up ads with MSn Premium. Get 2months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From stuart at lexacorp.com.pg Wed Jul 14 17:07:52 2004 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Thu, 15 Jul 2004 08:07:52 +1000 Subject: [dba-SQLServer] Date field type In-Reply-To: Message-ID: <40F63B58.9639.E47A3@lexacorp.com.pg> On 14 Jul 2004 at 14:22, Susan Geller wrote: > In my sql server 2000 table, I have a date field. When I display that > field in a query it displays as yyyy-mm-dd and then a timestamp. I want > dd/mm/yyyy and no time. I converted it using this syntax > convert(varchar, milestone_dt, 101) and I get what I want, EXCEPT, when > I try to sort by that field, it sorts as a varchar, not as a date, so I > have all my January's together instead of all my 2004's together. Can I > have this format and still keep it as a date field so it will sort > correctly? > What sort of a query? If it's an Access query, draw the field as a date from the table and set the Format property of the field in the query design grid. If you don't need to sort dynamically, select the converted date but sort on the actual date field. -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support. From andrew.haslett at ilc.gov.au Thu Jul 15 02:22:39 2004 From: andrew.haslett at ilc.gov.au (Haslett, Andrew) Date: Thu, 15 Jul 2004 16:52:39 +0930 Subject: [dba-SQLServer] Crosstabs - Pivots Message-ID: Greetings all. The infamous crosstab question! I've managed to get the data I require in the following format JOB LEDGER BALANCE 0862 04PRA 68444.85 0862 04PRB 44783.0 0915 04PRA 5092.0 0915 04PRB 46000.0 1045 04PRA 5400.0 1045 04PRB 5400.0 How can I transform it to this: JOB 04PRA 04PRB 0862 68444.85 44783.0 0915 5092.0 46000.0 1045 54000.0 5400.0 A few samples on the net show you how to do it, but they all require a numeric value to pivot on so you can use an aggregate function. I don't want to aggregate anything - just transform (pivot) them... Thanks in advance Andrew IMPORTANT - PLEASE READ ******************** This email and any files transmitted with it are confidential and may contain information protected by law from disclosure. If you have received this message in error, please notify the sender immediately and delete this email from your system. No warranty is given that this email or files, if attached to this email, are free from computer viruses or other defects. They are provided on the basis the user assumes all responsibility for loss, damage or consequence resulting directly or indirectly from their use, whether caused by the negligence of the sender or not. From stuart at lexacorp.com.pg Thu Jul 15 03:40:36 2004 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Thu, 15 Jul 2004 18:40:36 +1000 Subject: [dba-SQLServer] Crosstabs - Pivots In-Reply-To: Message-ID: <40F6CFA4.26499.205C0AD@lexacorp.com.pg> On 15 Jul 2004 at 16:52, Haslett, Andrew wrote: > Greetings all. The infamous crosstab question! > > A few samples on the net show you how to do it, but they all require a > numeric value to pivot on so you can use an aggregate function. > Must use an aggregate function, but it doesn't have to be numeric, just use Min(). -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support. From sgeller at cce.umn.edu Thu Jul 15 13:28:16 2004 From: sgeller at cce.umn.edu (Susan Geller) Date: Thu, 15 Jul 2004 13:28:16 -0500 Subject: [dba-SQLServer] Date field type Message-ID: Actually, what I'm doing is trying to make data easier for users to work with. I have built an application with a very complex normalized data model which people are using. They want to be able to get at the data, do their own queries. They have LOW level Access skills. In general, a table join is above their skill level. So, I am writing a bunch of views that denormalize the data. The views are in SQL Server. I then have an Access database mdb file that links to those views. Users can create their own queries based on these views. I wanted to get rid of the timestamp on the date field values because that is not useful to them, but I want them to be able to sort by any of the many date fields that are in a single view. I didn't want them to have to use functions to display the dates correctly. I realize I could give them each date field twice -- once in a nice format and once to use for sorting, but the views already have so many fields in them that I hate to duplicate data just for this purpose. But, so far I haven't come up with an alternative. --Susan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Wednesday, July 14, 2004 5:08 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Date field type On 14 Jul 2004 at 14:22, Susan Geller wrote: > In my sql server 2000 table, I have a date field. When I display that > field in a query it displays as yyyy-mm-dd and then a timestamp. I > want dd/mm/yyyy and no time. I converted it using this syntax > convert(varchar, milestone_dt, 101) and I get what I want, EXCEPT, > when I try to sort by that field, it sorts as a varchar, not as a > date, so I have all my January's together instead of all my 2004's > together. Can I have this format and still keep it as a date field so > it will sort correctly? > What sort of a query? If it's an Access query, draw the field as a date from the table and set the Format property of the field in the query design grid. If you don't need to sort dynamically, select the converted date but sort on the actual date field. -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From CMackin at Quiznos.com Thu Jul 15 13:44:12 2004 From: CMackin at Quiznos.com (Mackin, Christopher) Date: Thu, 15 Jul 2004 12:44:12 -0600 Subject: [dba-SQLServer] Date field type Message-ID: You can just create an Access query with the SQL view as the data source and format the date fields to m/d/yyy in that query and let the users hit that one to roll their own. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Susan Geller Sent: Thursday, July 15, 2004 12:28 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Date field type Actually, what I'm doing is trying to make data easier for users to work with. I have built an application with a very complex normalized data model which people are using. They want to be able to get at the data, do their own queries. They have LOW level Access skills. In general, a table join is above their skill level. So, I am writing a bunch of views that denormalize the data. The views are in SQL Server. I then have an Access database mdb file that links to those views. Users can create their own queries based on these views. I wanted to get rid of the timestamp on the date field values because that is not useful to them, but I want them to be able to sort by any of the many date fields that are in a single view. I didn't want them to have to use functions to display the dates correctly. I realize I could give them each date field twice -- once in a nice format and once to use for sorting, but the views already have so many fields in them that I hate to duplicate data just for this purpose. But, so far I haven't come up with an alternative. --Susan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Wednesday, July 14, 2004 5:08 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Date field type On 14 Jul 2004 at 14:22, Susan Geller wrote: > In my sql server 2000 table, I have a date field. When I display that > field in a query it displays as yyyy-mm-dd and then a timestamp. I > want dd/mm/yyyy and no time. I converted it using this syntax > convert(varchar, milestone_dt, 101) and I get what I want, EXCEPT, > when I try to sort by that field, it sorts as a varchar, not as a > date, so I have all my January's together instead of all my 2004's > together. Can I have this format and still keep it as a date field so > it will sort correctly? > What sort of a query? If it's an Access query, draw the field as a date from the table and set the Format property of the field in the query design grid. If you don't need to sort dynamically, select the converted date but sort on the actual date field. -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From rl_stewart at highstream.net Thu Jul 15 14:52:23 2004 From: rl_stewart at highstream.net (Robert L. Stewart) Date: Thu, 15 Jul 2004 14:52:23 -0500 Subject: [dba-SQLServer] Re: Date field type In-Reply-To: <200407151712.i6FHCgQ23991@databaseadvisors.com> Message-ID: <5.1.0.14.2.20040715145136.0181c208@pop3.highstream.net> Susan, Why not sort on the unconverted column and not include it in the result set? Robert At 12:12 PM 15/07/2004 -0500, you wrote: >Date: Wed, 14 Jul 2004 14:22:10 -0500 >From: "Susan Geller" >Subject: [dba-SQLServer] Date field type >To: >Message-ID: >Content-Type: text/plain; charset="US-ASCII" > >In my sql server 2000 table, I have a date field. When I display that >field in a query it displays as yyyy-mm-dd and then a timestamp. I want >dd/mm/yyyy and no time. I converted it using this syntax >convert(varchar, milestone_dt, 101) and I get what I want, EXCEPT, when >I try to sort by that field, it sorts as a varchar, not as a date, so I >have all my January's together instead of all my 2004's together. Can I >have this format and still keep it as a date field so it will sort >correctly? > >--Susan From shamil at users.mns.ru Thu Jul 15 15:04:28 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Fri, 16 Jul 2004 00:04:28 +0400 Subject: [dba-SQLServer] tsql help - propogate that pk References: Message-ID: <003c01c46aa6$f38a50a0$0201a8c0@PARIS> Here is a sample, Billy: /// tables CREATE TABLE [dbo].[tblOrder] ( [ordID] [int] IDENTITY (1, 1) NOT NULL , [ordDate] [datetime] NOT NULL , [custId] [int] NOT NULL , [ordCurTotal] [money] NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[tblOrderItem] ( [oitID] [int] IDENTITY (1, 1) NOT NULL , [ordId] [int] NOT NULL , [prodId] [int] NOT NULL , [oitAmount] [int] NOT NULL ) ON [PRIMARY] GO CREATE TABLE [dbo].[tblProduct] ( [prodID] [int] IDENTITY (1, 1) NOT NULL , [prodName] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [prodCurPrice] [money] NOT NULL , [prodCategoryID] [int] NULL ) ON [PRIMARY] GO /// view CREATE VIEW dbo.qselOrder AS SELECT o.ordDate, o.custId, o.ordCurTotal, p.prodName, p.prodCurPrice, i.oitAmount FROM dbo.tblOrder o INNER JOIN dbo.tblOrderItem i ON o.ordID = i.ordId INNER JOIN dbo.tblProduct p ON i.prodId = p.prodID // instead of insert trigger -- //////////////////////////////////////////////////////////////////////// /////// CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] INSTEAD OF INSERT AS declare @ordID int, @prodId int Set NoCount On -- ///////////////////////////////////////////////// Insert Into [dbo].[tblProduct] ( [prodName] , [prodCurPrice] ) select prodName , prodCurPrice from inserted Set @prodID = Cast(SCOPE_IDENTITY() As [int]) -- ///////////////////////////////////////////////// Insert Into [dbo].[tblOrder] ( [ordDate] , [custId] , [ordCurTotal] ) select ordDate , custId , ordCurTotal from inserted Set @ordID = Cast(SCOPE_IDENTITY() As [int]) -- ///////////////////////////////////////////////// Insert Into [dbo].[tblOrderItem] ( [ordId] , [prodId] , [oitAmount] ) select @ordId , @prodId , oitAmount from inserted -- ///////////////////////////////////////////////// Set NoCount Off HTH, Shamil P.S. See BOL for more details... ----- Original Message ----- From: "Billy Pang" To: Sent: Thursday, July 15, 2004 1:24 AM Subject: Re: [dba-SQLServer] tsql help - propogate that pk > how? the "instead of insert" trigger can insert a record into tablea first > but how can I get the tablea_id of the records just inserted and insert > those values into tableb_tablea_id column? > > thanks in advance, > Billy > From tuxedo_man at hotmail.com Thu Jul 15 16:18:36 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Thu, 15 Jul 2004 21:18:36 +0000 Subject: [dba-SQLServer] tsql help - propogate that pk Message-ID: Hi Shamil: Thanks for your assistance. Your solution will only work based on the assumption that records can only be inserted into tblOrder one at a time; if insert statement for tblOrder table has "select" as source, then the tblorderid fk in tblorderitem table may contain incorrect value. Using below example as example, execute the following insert statements: <--- cut here ---> insert into qselOrder(ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount) values(getdate(),1,2,'product name',4,5) insert into qselOrder(ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount) select ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount from qselOrder insert into qselOrder(ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount) select ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount from qselOrder <--- cut here ---> assuming tblorder table is empty from very beginning, it will insert four records into tblorder table as expected and four records into tblorderitems table as expected. however, the fourth record in tblorder table does not have any related records in tblorderitems. One way around this problem is to load the values within the "inserted" pseudo table into a table variable (assuming ss2k) or temporary table and loop through them using database cursor. However, I am wondering if there is another way. sincerely, Billy >From: "Shamil Salakhetdinov" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] tsql help - propogate that pk >Date: Fri, 16 Jul 2004 00:04:28 +0400 > >Here is a sample, Billy: > >/// tables >CREATE TABLE [dbo].[tblOrder] ( > [ordID] [int] IDENTITY (1, 1) NOT NULL , > [ordDate] [datetime] NOT NULL , > [custId] [int] NOT NULL , > [ordCurTotal] [money] NULL >) ON [PRIMARY] >GO > >CREATE TABLE [dbo].[tblOrderItem] ( > [oitID] [int] IDENTITY (1, 1) NOT NULL , > [ordId] [int] NOT NULL , > [prodId] [int] NOT NULL , > [oitAmount] [int] NOT NULL >) ON [PRIMARY] >GO > >CREATE TABLE [dbo].[tblProduct] ( > [prodID] [int] IDENTITY (1, 1) NOT NULL , > [prodName] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT >NULL , > [prodCurPrice] [money] NOT NULL , > [prodCategoryID] [int] NULL >) ON [PRIMARY] >GO > >/// view >CREATE VIEW dbo.qselOrder >AS >SELECT o.ordDate, o.custId, o.ordCurTotal, p.prodName, >p.prodCurPrice, i.oitAmount >FROM dbo.tblOrder o INNER JOIN > dbo.tblOrderItem i ON o.ordID = i.ordId INNER JOIN > dbo.tblProduct p ON i.prodId = p.prodID > >// instead of insert trigger > >-- >//////////////////////////////////////////////////////////////////////// >/////// > >CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] >INSTEAD OF INSERT >AS >declare @ordID int, @prodId int > >Set NoCount On > >-- ///////////////////////////////////////////////// >Insert Into [dbo].[tblProduct] >( > [prodName] > , [prodCurPrice] >) >select > prodName > , prodCurPrice >from inserted > >Set @prodID = Cast(SCOPE_IDENTITY() As [int]) >-- ///////////////////////////////////////////////// >Insert Into [dbo].[tblOrder] >( > [ordDate] > , [custId] > , [ordCurTotal] >) >select > ordDate > , custId > , ordCurTotal >from inserted > >Set @ordID = Cast(SCOPE_IDENTITY() As [int]) >-- ///////////////////////////////////////////////// >Insert Into [dbo].[tblOrderItem] >( > [ordId] > , [prodId] > , [oitAmount] >) >select > @ordId > , @prodId > , oitAmount >from inserted >-- ///////////////////////////////////////////////// > >Set NoCount Off > >HTH, >Shamil > >P.S. See BOL for more details... > >----- Original Message ----- >From: "Billy Pang" >To: >Sent: Thursday, July 15, 2004 1:24 AM >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > how? the "instead of insert" trigger can insert a record into tablea >first > > but how can I get the tablea_id of the records just inserted and >insert > > those values into tableb_tablea_id column? > > > > thanks in advance, > > Billy > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Free yourself from those irritating pop-up ads with MSn Premium. Get 2months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From shamil at users.mns.ru Thu Jul 15 17:32:23 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Fri, 16 Jul 2004 02:32:23 +0400 Subject: [dba-SQLServer] tsql help - propogate that pk References: Message-ID: <001001c46abb$9ac2e8f0$0201a8c0@PARIS> Hi Billy, You didn't ask about inserting several rows using instead of insert trigger, did you? :) Well, I think it can be done without cursors but we have to assume that there is no UNIVERSAL solution for such a case - I mean that for each certain case the cursor-less solution with instead of triggers could have quite different implementation - as always in programming an "optimal" solution is a balance of interests, a compromise: So if we assume that when several rows are inserted against my sample view then this means that: 1. they all belong to one order 2. product name is unique Then one of the the solutons is: - insert all rows into tblProduct from inserted if there is no yet such product, - insert one row into tblOrder from inserted, - insert all rows into tblOrdItem from inserted joined to tblProduct on ProdName See SQL script in P.S. of this message. If you need something more complicated - e.g. inserting several orders against view like in the current sample avoiding cursors' usage by all means - if you need that - then you're welcome to hire me to do that and other tricky work! :) HTH, Shamil P.S. Solution: CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] INSTEAD OF INSERT AS declare @ordID int Set NoCount On -- ///////////////////////////////////////////////// Insert Into [dbo].[tblProduct] ( [prodName] , [prodCurPrice] ) select prodName , prodCurPrice from inserted where (prodName not in (select prodName from tblProduct)) -- ///////////////////////////////////////////////// Insert Into [dbo].[tblOrder] ( [ordDate] , [custId] , [ordCurTotal] ) select top 1 ordDate , custId , ordCurTotal from inserted Set @ordID = Cast(SCOPE_IDENTITY() As [int]) -- ///////////////////////////////////////////////// Insert Into [dbo].[tblOrderItem] ( [ordId] , [prodId] , [oitAmount] ) select @ordId , p.prodId , oitAmount from inserted i inner join tblProduct p on i.prodName = p.prodName -- ///////////////////////////////////////////////// Set NoCount Off ----- Original Message ----- From: "Billy Pang" To: Sent: Friday, July 16, 2004 1:18 AM Subject: Re: [dba-SQLServer] tsql help - propogate that pk > Hi Shamil: > > Thanks for your assistance. Your solution will only work based on the > assumption that records can only be inserted into tblOrder one at a time; if > insert statement for tblOrder table has "select" as source, then the > tblorderid fk in tblorderitem table may contain incorrect value. > > Using below example as example, execute the following insert statements: > > <--- cut here ---> > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, prodCurPrice, > oitAmount) > values(getdate(),1,2,'product name',4,5) > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, prodCurPrice, > oitAmount) > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount from > qselOrder > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, prodCurPrice, > oitAmount) > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount from > qselOrder > <--- cut here ---> > > assuming tblorder table is empty from very beginning, it will insert four > records into tblorder table as expected and four records into tblorderitems > table as expected. however, the fourth record in tblorder table does not > have any related records in tblorderitems. > > One way around this problem is to load the values within the "inserted" > pseudo table into a table variable (assuming ss2k) or temporary table and > loop through them using database cursor. However, I am wondering if there > is another way. > > sincerely, > Billy > From tuxedo_man at hotmail.com Thu Jul 15 18:18:59 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Thu, 15 Jul 2004 23:18:59 +0000 Subject: [dba-SQLServer] tsql help - propogate that pk Message-ID: Thanks Shamil for your time. I was actually hoping for a solution that is quite simple (perhaps I was overlooking something very obvious). I thought that there was a more simple solution because the view insert (where it affects multiple tables) works eloquently in MS Access but not in Sql Server. Regards, Billy >From: "Shamil Salakhetdinov" >Reply-To: dba-sqlserver at databaseadvisors.com >To: "dba-SQLServer" >Subject: Re: [dba-SQLServer] tsql help - propogate that pk >Date: Fri, 16 Jul 2004 02:32:23 +0400 > >Hi Billy, > >You didn't ask about inserting several rows using instead of insert >trigger, did you? :) > >Well, I think it can be done without cursors but we have to assume that >there is no UNIVERSAL solution for such a case - I mean that for each >certain case the cursor-less solution with instead of triggers could >have quite different implementation - as always in programming an >"optimal" solution is a balance of interests, a compromise: > >So if we assume that when several rows are inserted against my sample >view then this means that: > >1. they all belong to one order >2. product name is unique > >Then one of the the solutons is: > >- insert all rows into tblProduct from inserted if there is no yet such >product, >- insert one row into tblOrder from inserted, >- insert all rows into tblOrdItem from inserted joined to tblProduct on >ProdName > >See SQL script in P.S. of this message. > >If you need something more complicated - e.g. inserting several orders >against view like in the current sample avoiding cursors' usage by all >means - if you need that - then you're welcome to hire me to do that and >other tricky work! :) > >HTH, >Shamil > >P.S. Solution: > > >CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] >INSTEAD OF INSERT >AS >declare @ordID int > >Set NoCount On > >-- ///////////////////////////////////////////////// >Insert Into [dbo].[tblProduct] >( > [prodName] > , [prodCurPrice] >) >select > prodName > , prodCurPrice >from inserted where (prodName not in (select prodName from tblProduct)) > >-- ///////////////////////////////////////////////// >Insert Into [dbo].[tblOrder] >( > [ordDate] > , [custId] > , [ordCurTotal] >) >select top 1 > ordDate > , custId > , ordCurTotal >from inserted > >Set @ordID = Cast(SCOPE_IDENTITY() As [int]) >-- ///////////////////////////////////////////////// >Insert Into [dbo].[tblOrderItem] >( > [ordId] > , [prodId] > , [oitAmount] >) >select > @ordId > , p.prodId > , oitAmount >from inserted i inner join tblProduct p on i.prodName = p.prodName >-- ///////////////////////////////////////////////// > >Set NoCount Off >----- Original Message ----- >From: "Billy Pang" >To: >Sent: Friday, July 16, 2004 1:18 AM >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > Hi Shamil: > > > > Thanks for your assistance. Your solution will only work based on the > > assumption that records can only be inserted into tblOrder one at a >time; if > > insert statement for tblOrder table has "select" as source, then the > > tblorderid fk in tblorderitem table may contain incorrect value. > > > > Using below example as example, execute the following insert >statements: > > > > <--- cut here ---> > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, >prodCurPrice, > > oitAmount) > > values(getdate(),1,2,'product name',4,5) > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, >prodCurPrice, > > oitAmount) > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount >from > > qselOrder > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, >prodCurPrice, > > oitAmount) > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount >from > > qselOrder > > <--- cut here ---> > > > > assuming tblorder table is empty from very beginning, it will insert >four > > records into tblorder table as expected and four records into >tblorderitems > > table as expected. however, the fourth record in tblorder table does >not > > have any related records in tblorderitems. > > > > One way around this problem is to load the values within the >"inserted" > > pseudo table into a table variable (assuming ss2k) or temporary table >and > > loop through them using database cursor. However, I am wondering if >there > > is another way. > > > > sincerely, > > Billy > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Add photos to your e-mail with MSN Premium. Get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From shamil at users.mns.ru Fri Jul 16 13:22:25 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Fri, 16 Jul 2004 22:22:25 +0400 Subject: [dba-SQLServer] tsql help - propogate that pk References: Message-ID: <000d01c46b61$dc1d8b60$0201a8c0@PARIS> Billy, What about that sentence from BOL?: "SQL Server 2000 Updatable views can modify more than one table involved in the view. The DELETE, INSERT, and UPDATE statements can reference a view as long as SQL Server can translate the user's update request unambiguously to updates in the base tables referenced in the view's definition. Expect differences in behavior when working with updatable views with more than one table involved in the DELETE, INSERT, or UPDATE statements." > I was actually hoping for a solution that is > quite simple For me the solution looks simple. I called it tricky only because it's not obvious when starting to work with instead of triggers. You can also use a simple stored procedure to fullfill your task... > the view insert (where it > affects multiple tables) works eloquently in MS Access but not in Sql > Server. Are you sure it will work in MS Access for your task? (This question is not an invitation to MS Access vs. MS SQL2000 discussion) Shamil ----- Original Message ----- From: "Billy Pang" To: Sent: Friday, July 16, 2004 3:18 AM Subject: Re: [dba-SQLServer] tsql help - propogate that pk > Thanks Shamil for your time. I was actually hoping for a solution that is > quite simple (perhaps I was overlooking something very obvious). I thought > that there was a more simple solution because the view insert (where it > affects multiple tables) works eloquently in MS Access but not in Sql > Server. > > Regards, > Billy > > > > > >From: "Shamil Salakhetdinov" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: "dba-SQLServer" > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > >Date: Fri, 16 Jul 2004 02:32:23 +0400 > > > >Hi Billy, > > > >You didn't ask about inserting several rows using instead of insert > >trigger, did you? :) > > > >Well, I think it can be done without cursors but we have to assume that > >there is no UNIVERSAL solution for such a case - I mean that for each > >certain case the cursor-less solution with instead of triggers could > >have quite different implementation - as always in programming an > >"optimal" solution is a balance of interests, a compromise: > > > >So if we assume that when several rows are inserted against my sample > >view then this means that: > > > >1. they all belong to one order > >2. product name is unique > > > >Then one of the the solutons is: > > > >- insert all rows into tblProduct from inserted if there is no yet such > >product, > >- insert one row into tblOrder from inserted, > >- insert all rows into tblOrdItem from inserted joined to tblProduct on > >ProdName > > > >See SQL script in P.S. of this message. > > > >If you need something more complicated - e.g. inserting several orders > >against view like in the current sample avoiding cursors' usage by all > >means - if you need that - then you're welcome to hire me to do that and > >other tricky work! :) > > > >HTH, > >Shamil > > > >P.S. Solution: > > > > > >CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] > >INSTEAD OF INSERT > >AS > >declare @ordID int > > > >Set NoCount On > > > >-- ///////////////////////////////////////////////// > >Insert Into [dbo].[tblProduct] > >( > > [prodName] > > , [prodCurPrice] > >) > >select > > prodName > > , prodCurPrice > >from inserted where (prodName not in (select prodName from tblProduct)) > > > >-- ///////////////////////////////////////////////// > >Insert Into [dbo].[tblOrder] > >( > > [ordDate] > > , [custId] > > , [ordCurTotal] > >) > >select top 1 > > ordDate > > , custId > > , ordCurTotal > >from inserted > > > >Set @ordID = Cast(SCOPE_IDENTITY() As [int]) > >-- ///////////////////////////////////////////////// > >Insert Into [dbo].[tblOrderItem] > >( > > [ordId] > > , [prodId] > > , [oitAmount] > >) > >select > > @ordId > > , p.prodId > > , oitAmount > >from inserted i inner join tblProduct p on i.prodName = p.prodName > >-- ///////////////////////////////////////////////// > > > >Set NoCount Off > >----- Original Message ----- > >From: "Billy Pang" > >To: > >Sent: Friday, July 16, 2004 1:18 AM > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > Hi Shamil: > > > > > > Thanks for your assistance. Your solution will only work based on the > > > assumption that records can only be inserted into tblOrder one at a > >time; if > > > insert statement for tblOrder table has "select" as source, then the > > > tblorderid fk in tblorderitem table may contain incorrect value. > > > > > > Using below example as example, execute the following insert > >statements: > > > > > > <--- cut here ---> > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > >prodCurPrice, > > > oitAmount) > > > values(getdate(),1,2,'product name',4,5) > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > >prodCurPrice, > > > oitAmount) > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount > >from > > > qselOrder > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > >prodCurPrice, > > > oitAmount) > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, oitAmount > >from > > > qselOrder > > > <--- cut here ---> > > > > > > assuming tblorder table is empty from very beginning, it will insert > >four > > > records into tblorder table as expected and four records into > >tblorderitems > > > table as expected. however, the fourth record in tblorder table does > >not > > > have any related records in tblorderitems. > > > > > > One way around this problem is to load the values within the > >"inserted" > > > pseudo table into a table variable (assuming ss2k) or temporary table > >and > > > loop through them using database cursor. However, I am wondering if > >there > > > is another way. > > > > > > sincerely, > > > Billy > > > > > > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > > _________________________________________________________________ > Add photos to your e-mail with MSN Premium. Get 2 months FREE* > http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From tuxedo_man at hotmail.com Fri Jul 16 15:05:02 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Fri, 16 Jul 2004 20:05:02 +0000 Subject: [dba-SQLServer] tsql help - propogate that pk Message-ID: Hi Shamil: The sentence from BOL is absolutely correct. But it does not give me what I want; I need to have "identity" values moved from one table to another after a view insert. There is no doubt that a view can update multiple base tables; there is no question about that; and it is possible to reference them unambigiously; however, the fact that it is an "instead of insert", it is not possible to reference any identity values generated from the view (without using scope_identity()). This would not be a problem if it was possible to create an "After" trigger on a view. And yes, it works eloquently in Access. For demonstration purposes, within Access, create two tables with following schema: tablea tablea_id autonumber tablea_value text(50) tableb tableb_id autonumber tableb_tablea_id number long tableb_value text(50) then create a query called qryInsert with the following source: SELECT tablea.tablea_id, tableb.tableb_id, tablea.tablea_value, tableb.tableb_value, tableb.tableb_tablea_id, tablea.tablea_id FROM tablea INNER JOIN tableb ON tablea.tablea_id = tableb.tableb_tablea_id; then create and execute the following query: insert into qryInsert(tablea_value, tableb_value) values('a','b') followed by: insert into qryInsert(tablea_value, tableb_value) select tablea_value, tableb_value from qryInsert and again.. insert into qryInsert(tablea_value, tableb_value) select tablea_value, tableb_value from qryInsert and you will find four records in tablea as expected, four records in tableb as expected and all four records in tablea have related records in tableb. Access was able to do this without any database triggers. And Access was able to accommodate "view inserts" that have SELECT as source. If SQL Server is able to immitate this behavior (without using scope_identity(), of course :) ), then I am would like to know. Kindest regards, Billy >From: "Shamil Salakhetdinov" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] tsql help - propogate that pk >Date: Fri, 16 Jul 2004 22:22:25 +0400 > >Billy, > >What about that sentence from BOL?: > >"SQL Server 2000 >Updatable views can modify more than one table involved in the view. The >DELETE, INSERT, and UPDATE statements can reference a view as long as >SQL Server can translate the user's update request unambiguously to >updates in the base tables referenced in the view's definition. >Expect differences in behavior when working with updatable views with >more than one table involved in the DELETE, INSERT, or UPDATE >statements." > > > I was actually hoping for a solution that is > > quite simple >For me the solution looks simple. I called it tricky only because it's >not obvious when starting to work with instead of triggers. >You can also use a simple stored procedure to fullfill your task... > > > the view insert (where it > > affects multiple tables) works eloquently in MS Access but not in Sql > > Server. >Are you sure it will work in MS Access for your task? (This question is >not an invitation to MS Access vs. MS SQL2000 discussion) > >Shamil > >----- Original Message ----- >From: "Billy Pang" >To: >Sent: Friday, July 16, 2004 3:18 AM >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > Thanks Shamil for your time. I was actually hoping for a solution >that is > > quite simple (perhaps I was overlooking something very obvious). I >thought > > that there was a more simple solution because the view insert (where >it > > affects multiple tables) works eloquently in MS Access but not in Sql > > Server. > > > > Regards, > > Billy > > > > > > > > > > >From: "Shamil Salakhetdinov" > > >Reply-To: dba-sqlserver at databaseadvisors.com > > >To: "dba-SQLServer" > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > >Date: Fri, 16 Jul 2004 02:32:23 +0400 > > > > > >Hi Billy, > > > > > >You didn't ask about inserting several rows using instead of insert > > >trigger, did you? :) > > > > > >Well, I think it can be done without cursors but we have to assume >that > > >there is no UNIVERSAL solution for such a case - I mean that for each > > >certain case the cursor-less solution with instead of triggers could > > >have quite different implementation - as always in programming an > > >"optimal" solution is a balance of interests, a compromise: > > > > > >So if we assume that when several rows are inserted against my sample > > >view then this means that: > > > > > >1. they all belong to one order > > >2. product name is unique > > > > > >Then one of the the solutons is: > > > > > >- insert all rows into tblProduct from inserted if there is no yet >such > > >product, > > >- insert one row into tblOrder from inserted, > > >- insert all rows into tblOrdItem from inserted joined to tblProduct >on > > >ProdName > > > > > >See SQL script in P.S. of this message. > > > > > >If you need something more complicated - e.g. inserting several >orders > > >against view like in the current sample avoiding cursors' usage by >all > > >means - if you need that - then you're welcome to hire me to do that >and > > >other tricky work! :) > > > > > >HTH, > > >Shamil > > > > > >P.S. Solution: > > > > > > > > >CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] > > >INSTEAD OF INSERT > > >AS > > >declare @ordID int > > > > > >Set NoCount On > > > > > >-- ///////////////////////////////////////////////// > > >Insert Into [dbo].[tblProduct] > > >( > > > [prodName] > > > , [prodCurPrice] > > >) > > >select > > > prodName > > > , prodCurPrice > > >from inserted where (prodName not in (select prodName from >tblProduct)) > > > > > >-- ///////////////////////////////////////////////// > > >Insert Into [dbo].[tblOrder] > > >( > > > [ordDate] > > > , [custId] > > > , [ordCurTotal] > > >) > > >select top 1 > > > ordDate > > > , custId > > > , ordCurTotal > > >from inserted > > > > > >Set @ordID = Cast(SCOPE_IDENTITY() As [int]) > > >-- ///////////////////////////////////////////////// > > >Insert Into [dbo].[tblOrderItem] > > >( > > > [ordId] > > > , [prodId] > > > , [oitAmount] > > >) > > >select > > > @ordId > > > , p.prodId > > > , oitAmount > > >from inserted i inner join tblProduct p on i.prodName = p.prodName > > >-- ///////////////////////////////////////////////// > > > > > >Set NoCount Off > > >----- Original Message ----- > > >From: "Billy Pang" > > >To: > > >Sent: Friday, July 16, 2004 1:18 AM > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > > > > Hi Shamil: > > > > > > > > Thanks for your assistance. Your solution will only work based on >the > > > > assumption that records can only be inserted into tblOrder one at >a > > >time; if > > > > insert statement for tblOrder table has "select" as source, then >the > > > > tblorderid fk in tblorderitem table may contain incorrect value. > > > > > > > > Using below example as example, execute the following insert > > >statements: > > > > > > > > <--- cut here ---> > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > >prodCurPrice, > > > > oitAmount) > > > > values(getdate(),1,2,'product name',4,5) > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > >prodCurPrice, > > > > oitAmount) > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, >oitAmount > > >from > > > > qselOrder > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > >prodCurPrice, > > > > oitAmount) > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, >oitAmount > > >from > > > > qselOrder > > > > <--- cut here ---> > > > > > > > > assuming tblorder table is empty from very beginning, it will >insert > > >four > > > > records into tblorder table as expected and four records into > > >tblorderitems > > > > table as expected. however, the fourth record in tblorder table >does > > >not > > > > have any related records in tblorderitems. > > > > > > > > One way around this problem is to load the values within the > > >"inserted" > > > > pseudo table into a table variable (assuming ss2k) or temporary >table > > >and > > > > loop through them using database cursor. However, I am wondering >if > > >there > > > > is another way. > > > > > > > > sincerely, > > > > Billy > > > > > > > > > >_______________________________________________ > > >dba-SQLServer mailing list > > >dba-SQLServer at databaseadvisors.com > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > >http://www.databaseadvisors.com > > > > > > > _________________________________________________________________ > > Add photos to your e-mail with MSN Premium. Get 2 months FREE* > > >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN Premium helps eliminate e-mail viruses. Get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From shamil at users.mns.ru Fri Jul 16 15:23:32 2004 From: shamil at users.mns.ru (Shamil Salakhetdinov) Date: Sat, 17 Jul 2004 00:23:32 +0400 Subject: [dba-SQLServer] tsql help - propogate that pk References: Message-ID: <000901c46b72$c55a26c0$0201a8c0@PARIS> > If SQL Server is able to immitate this behavior (without > using scope_identity(), of course :) ), then I am would > like to know. Billy, I think it can't - sorry I can't help here. Shamil ----- Original Message ----- From: "Billy Pang" To: Sent: Saturday, July 17, 2004 12:05 AM Subject: Re: [dba-SQLServer] tsql help - propogate that pk > Hi Shamil: > > The sentence from BOL is absolutely correct. But it does not give me what I > want; I need to have "identity" values moved from one table to another after > a view insert. There is no doubt that a view can update multiple base > tables; there is no question about that; and it is possible to reference > them unambigiously; however, the fact that it is an "instead of insert", it > is not possible to reference any identity values generated from the view > (without using scope_identity()). This would not be a problem if it was > possible to create an "After" trigger on a view. > > And yes, it works eloquently in Access. For demonstration purposes, within > Access, create two tables with following schema: > > tablea > tablea_id autonumber > tablea_value text(50) > > tableb > tableb_id autonumber > tableb_tablea_id number long > tableb_value text(50) > > then create a query called qryInsert with the following source: > > SELECT tablea.tablea_id, tableb.tableb_id, tablea.tablea_value, > tableb.tableb_value, tableb.tableb_tablea_id, tablea.tablea_id > FROM tablea INNER JOIN tableb ON tablea.tablea_id = tableb.tableb_tablea_id; > > then create and execute the following query: > > insert into qryInsert(tablea_value, tableb_value) values('a','b') > > followed by: > > insert into qryInsert(tablea_value, tableb_value) > select tablea_value, tableb_value > from qryInsert > > and again.. > > insert into qryInsert(tablea_value, tableb_value) > select tablea_value, tableb_value > from qryInsert > > and you will find four records in tablea as expected, four records in tableb > as expected and all four records in tablea have related records in tableb. > > Access was able to do this without any database triggers. And Access was > able to accommodate "view inserts" that have SELECT as source. If SQL > Server is able to immitate this behavior (without using scope_identity(), of > course :) ), then I am would like to know. > > Kindest regards, > Billy > > >From: "Shamil Salakhetdinov" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > >Date: Fri, 16 Jul 2004 22:22:25 +0400 > > > >Billy, > > > >What about that sentence from BOL?: > > > >"SQL Server 2000 > >Updatable views can modify more than one table involved in the view. The > >DELETE, INSERT, and UPDATE statements can reference a view as long as > >SQL Server can translate the user's update request unambiguously to > >updates in the base tables referenced in the view's definition. > >Expect differences in behavior when working with updatable views with > >more than one table involved in the DELETE, INSERT, or UPDATE > >statements." > > > > > I was actually hoping for a solution that is > > > quite simple > >For me the solution looks simple. I called it tricky only because it's > >not obvious when starting to work with instead of triggers. > >You can also use a simple stored procedure to fullfill your task... > > > > > the view insert (where it > > > affects multiple tables) works eloquently in MS Access but not in Sql > > > Server. > >Are you sure it will work in MS Access for your task? (This question is > >not an invitation to MS Access vs. MS SQL2000 discussion) > > > >Shamil > > > >----- Original Message ----- > >From: "Billy Pang" > >To: > >Sent: Friday, July 16, 2004 3:18 AM > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > Thanks Shamil for your time. I was actually hoping for a solution > >that is > > > quite simple (perhaps I was overlooking something very obvious). I > >thought > > > that there was a more simple solution because the view insert (where > >it > > > affects multiple tables) works eloquently in MS Access but not in Sql > > > Server. > > > > > > Regards, > > > Billy > > > > > > > > > > > > > > > >From: "Shamil Salakhetdinov" > > > >Reply-To: dba-sqlserver at databaseadvisors.com > > > >To: "dba-SQLServer" > > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > >Date: Fri, 16 Jul 2004 02:32:23 +0400 > > > > > > > >Hi Billy, > > > > > > > >You didn't ask about inserting several rows using instead of insert > > > >trigger, did you? :) > > > > > > > >Well, I think it can be done without cursors but we have to assume > >that > > > >there is no UNIVERSAL solution for such a case - I mean that for each > > > >certain case the cursor-less solution with instead of triggers could > > > >have quite different implementation - as always in programming an > > > >"optimal" solution is a balance of interests, a compromise: > > > > > > > >So if we assume that when several rows are inserted against my sample > > > >view then this means that: > > > > > > > >1. they all belong to one order > > > >2. product name is unique > > > > > > > >Then one of the the solutons is: > > > > > > > >- insert all rows into tblProduct from inserted if there is no yet > >such > > > >product, > > > >- insert one row into tblOrder from inserted, > > > >- insert all rows into tblOrdItem from inserted joined to tblProduct > >on > > > >ProdName > > > > > > > >See SQL script in P.S. of this message. > > > > > > > >If you need something more complicated - e.g. inserting several > >orders > > > >against view like in the current sample avoiding cursors' usage by > >all > > > >means - if you need that - then you're welcome to hire me to do that > >and > > > >other tricky work! :) > > > > > > > >HTH, > > > >Shamil > > > > > > > >P.S. Solution: > > > > > > > > > > > >CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] > > > >INSTEAD OF INSERT > > > >AS > > > >declare @ordID int > > > > > > > >Set NoCount On > > > > > > > >-- ///////////////////////////////////////////////// > > > >Insert Into [dbo].[tblProduct] > > > >( > > > > [prodName] > > > > , [prodCurPrice] > > > >) > > > >select > > > > prodName > > > > , prodCurPrice > > > >from inserted where (prodName not in (select prodName from > >tblProduct)) > > > > > > > >-- ///////////////////////////////////////////////// > > > >Insert Into [dbo].[tblOrder] > > > >( > > > > [ordDate] > > > > , [custId] > > > > , [ordCurTotal] > > > >) > > > >select top 1 > > > > ordDate > > > > , custId > > > > , ordCurTotal > > > >from inserted > > > > > > > >Set @ordID = Cast(SCOPE_IDENTITY() As [int]) > > > >-- ///////////////////////////////////////////////// > > > >Insert Into [dbo].[tblOrderItem] > > > >( > > > > [ordId] > > > > , [prodId] > > > > , [oitAmount] > > > >) > > > >select > > > > @ordId > > > > , p.prodId > > > > , oitAmount > > > >from inserted i inner join tblProduct p on i.prodName = p.prodName > > > >-- ///////////////////////////////////////////////// > > > > > > > >Set NoCount Off > > > >----- Original Message ----- > > > >From: "Billy Pang" > > > >To: > > > >Sent: Friday, July 16, 2004 1:18 AM > > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > > > > > > > Hi Shamil: > > > > > > > > > > Thanks for your assistance. Your solution will only work based on > >the > > > > > assumption that records can only be inserted into tblOrder one at > >a > > > >time; if > > > > > insert statement for tblOrder table has "select" as source, then > >the > > > > > tblorderid fk in tblorderitem table may contain incorrect value. > > > > > > > > > > Using below example as example, execute the following insert > > > >statements: > > > > > > > > > > <--- cut here ---> > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > >prodCurPrice, > > > > > oitAmount) > > > > > values(getdate(),1,2,'product name',4,5) > > > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > >prodCurPrice, > > > > > oitAmount) > > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, > >oitAmount > > > >from > > > > > qselOrder > > > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > >prodCurPrice, > > > > > oitAmount) > > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, > >oitAmount > > > >from > > > > > qselOrder > > > > > <--- cut here ---> > > > > > > > > > > assuming tblorder table is empty from very beginning, it will > >insert > > > >four > > > > > records into tblorder table as expected and four records into > > > >tblorderitems > > > > > table as expected. however, the fourth record in tblorder table > >does > > > >not > > > > > have any related records in tblorderitems. > > > > > > > > > > One way around this problem is to load the values within the > > > >"inserted" > > > > > pseudo table into a table variable (assuming ss2k) or temporary > >table > > > >and > > > > > loop through them using database cursor. However, I am wondering > >if > > > >there > > > > > is another way. > > > > > > > > > > sincerely, > > > > > Billy > > > > > > > > > > > > >_______________________________________________ > > > >dba-SQLServer mailing list > > > >dba-SQLServer at databaseadvisors.com > > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > >http://www.databaseadvisors.com > > > > > > > > > > _________________________________________________________________ > > > Add photos to your e-mail with MSN Premium. Get 2 months FREE* > > > > >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&S U=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > > > > > _______________________________________________ > > > dba-SQLServer mailing list > > > dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > > _________________________________________________________________ > MSN Premium helps eliminate e-mail viruses. Get 2 months FREE* > http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From tuxedo_man at hotmail.com Fri Jul 16 16:24:58 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Fri, 16 Jul 2004 21:24:58 +0000 Subject: [dba-SQLServer] tsql help - propogate that pk Message-ID: Hi Shamil: I didn't think it was possible anyways. I was really racking my brain trying to figure out it out. I had first concluded it was not possible. However, it is always more prudent to ask peers in same field of work for second opinion. This was a good thread :) Sincerely, Billy >From: "Shamil Salakhetdinov" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] tsql help - propogate that pk >Date: Sat, 17 Jul 2004 00:23:32 +0400 > > > If SQL Server is able to immitate this behavior (without > > using scope_identity(), of course :) ), then I am would > > like to know. >Billy, > >I think it can't - sorry I can't help here. > >Shamil > >----- Original Message ----- >From: "Billy Pang" >To: >Sent: Saturday, July 17, 2004 12:05 AM >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > Hi Shamil: > > > > The sentence from BOL is absolutely correct. But it does not give me >what I > > want; I need to have "identity" values moved from one table to another >after > > a view insert. There is no doubt that a view can update multiple base > > tables; there is no question about that; and it is possible to >reference > > them unambigiously; however, the fact that it is an "instead of >insert", it > > is not possible to reference any identity values generated from the >view > > (without using scope_identity()). This would not be a problem if it >was > > possible to create an "After" trigger on a view. > > > > And yes, it works eloquently in Access. For demonstration purposes, >within > > Access, create two tables with following schema: > > > > tablea > > tablea_id autonumber > > tablea_value text(50) > > > > tableb > > tableb_id autonumber > > tableb_tablea_id number long > > tableb_value text(50) > > > > then create a query called qryInsert with the following source: > > > > SELECT tablea.tablea_id, tableb.tableb_id, tablea.tablea_value, > > tableb.tableb_value, tableb.tableb_tablea_id, tablea.tablea_id > > FROM tablea INNER JOIN tableb ON tablea.tablea_id = >tableb.tableb_tablea_id; > > > > then create and execute the following query: > > > > insert into qryInsert(tablea_value, tableb_value) values('a','b') > > > > followed by: > > > > insert into qryInsert(tablea_value, tableb_value) > > select tablea_value, tableb_value > > from qryInsert > > > > and again.. > > > > insert into qryInsert(tablea_value, tableb_value) > > select tablea_value, tableb_value > > from qryInsert > > > > and you will find four records in tablea as expected, four records in >tableb > > as expected and all four records in tablea have related records in >tableb. > > > > Access was able to do this without any database triggers. And Access >was > > able to accommodate "view inserts" that have SELECT as source. If SQL > > Server is able to immitate this behavior (without using >scope_identity(), of > > course :) ), then I am would like to know. > > > > Kindest regards, > > Billy > > > > >From: "Shamil Salakhetdinov" > > >Reply-To: dba-sqlserver at databaseadvisors.com > > >To: dba-sqlserver at databaseadvisors.com > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > >Date: Fri, 16 Jul 2004 22:22:25 +0400 > > > > > >Billy, > > > > > >What about that sentence from BOL?: > > > > > >"SQL Server 2000 > > >Updatable views can modify more than one table involved in the view. >The > > >DELETE, INSERT, and UPDATE statements can reference a view as long as > > >SQL Server can translate the user's update request unambiguously to > > >updates in the base tables referenced in the view's definition. > > >Expect differences in behavior when working with updatable views with > > >more than one table involved in the DELETE, INSERT, or UPDATE > > >statements." > > > > > > > I was actually hoping for a solution that is > > > > quite simple > > >For me the solution looks simple. I called it tricky only because >it's > > >not obvious when starting to work with instead of triggers. > > >You can also use a simple stored procedure to fullfill your task... > > > > > > > the view insert (where it > > > > affects multiple tables) works eloquently in MS Access but not in >Sql > > > > Server. > > >Are you sure it will work in MS Access for your task? (This question >is > > >not an invitation to MS Access vs. MS SQL2000 discussion) > > > > > >Shamil > > > > > >----- Original Message ----- > > >From: "Billy Pang" > > >To: > > >Sent: Friday, July 16, 2004 3:18 AM > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > > > > Thanks Shamil for your time. I was actually hoping for a solution > > >that is > > > > quite simple (perhaps I was overlooking something very obvious). >I > > >thought > > > > that there was a more simple solution because the view insert >(where > > >it > > > > affects multiple tables) works eloquently in MS Access but not in >Sql > > > > Server. > > > > > > > > Regards, > > > > Billy > > > > > > > > > > > > > > > > > > > > >From: "Shamil Salakhetdinov" > > > > >Reply-To: dba-sqlserver at databaseadvisors.com > > > > >To: "dba-SQLServer" > > > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > >Date: Fri, 16 Jul 2004 02:32:23 +0400 > > > > > > > > > >Hi Billy, > > > > > > > > > >You didn't ask about inserting several rows using instead of >insert > > > > >trigger, did you? :) > > > > > > > > > >Well, I think it can be done without cursors but we have to >assume > > >that > > > > >there is no UNIVERSAL solution for such a case - I mean that for >each > > > > >certain case the cursor-less solution with instead of triggers >could > > > > >have quite different implementation - as always in programming an > > > > >"optimal" solution is a balance of interests, a compromise: > > > > > > > > > >So if we assume that when several rows are inserted against my >sample > > > > >view then this means that: > > > > > > > > > >1. they all belong to one order > > > > >2. product name is unique > > > > > > > > > >Then one of the the solutons is: > > > > > > > > > >- insert all rows into tblProduct from inserted if there is no >yet > > >such > > > > >product, > > > > >- insert one row into tblOrder from inserted, > > > > >- insert all rows into tblOrdItem from inserted joined to >tblProduct > > >on > > > > >ProdName > > > > > > > > > >See SQL script in P.S. of this message. > > > > > > > > > >If you need something more complicated - e.g. inserting several > > >orders > > > > >against view like in the current sample avoiding cursors' usage >by > > >all > > > > >means - if you need that - then you're welcome to hire me to do >that > > >and > > > > >other tricky work! :) > > > > > > > > > >HTH, > > > > >Shamil > > > > > > > > > >P.S. Solution: > > > > > > > > > > > > > > >CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] > > > > >INSTEAD OF INSERT > > > > >AS > > > > >declare @ordID int > > > > > > > > > >Set NoCount On > > > > > > > > > >-- ///////////////////////////////////////////////// > > > > >Insert Into [dbo].[tblProduct] > > > > >( > > > > > [prodName] > > > > > , [prodCurPrice] > > > > >) > > > > >select > > > > > prodName > > > > > , prodCurPrice > > > > >from inserted where (prodName not in (select prodName from > > >tblProduct)) > > > > > > > > > >-- ///////////////////////////////////////////////// > > > > >Insert Into [dbo].[tblOrder] > > > > >( > > > > > [ordDate] > > > > > , [custId] > > > > > , [ordCurTotal] > > > > >) > > > > >select top 1 > > > > > ordDate > > > > > , custId > > > > > , ordCurTotal > > > > >from inserted > > > > > > > > > >Set @ordID = Cast(SCOPE_IDENTITY() As [int]) > > > > >-- ///////////////////////////////////////////////// > > > > >Insert Into [dbo].[tblOrderItem] > > > > >( > > > > > [ordId] > > > > > , [prodId] > > > > > , [oitAmount] > > > > >) > > > > >select > > > > > @ordId > > > > > , p.prodId > > > > > , oitAmount > > > > >from inserted i inner join tblProduct p on i.prodName = >p.prodName > > > > >-- ///////////////////////////////////////////////// > > > > > > > > > >Set NoCount Off > > > > >----- Original Message ----- > > > > >From: "Billy Pang" > > > > >To: > > > > >Sent: Friday, July 16, 2004 1:18 AM > > > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > > > > > > > > > > Hi Shamil: > > > > > > > > > > > > Thanks for your assistance. Your solution will only work >based on > > >the > > > > > > assumption that records can only be inserted into tblOrder one >at > > >a > > > > >time; if > > > > > > insert statement for tblOrder table has "select" as source, >then > > >the > > > > > > tblorderid fk in tblorderitem table may contain incorrect >value. > > > > > > > > > > > > Using below example as example, execute the following insert > > > > >statements: > > > > > > > > > > > > <--- cut here ---> > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > > >prodCurPrice, > > > > > > oitAmount) > > > > > > values(getdate(),1,2,'product name',4,5) > > > > > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > > >prodCurPrice, > > > > > > oitAmount) > > > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, > > >oitAmount > > > > >from > > > > > > qselOrder > > > > > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > > >prodCurPrice, > > > > > > oitAmount) > > > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, > > >oitAmount > > > > >from > > > > > > qselOrder > > > > > > <--- cut here ---> > > > > > > > > > > > > assuming tblorder table is empty from very beginning, it will > > >insert > > > > >four > > > > > > records into tblorder table as expected and four records into > > > > >tblorderitems > > > > > > table as expected. however, the fourth record in tblorder >table > > >does > > > > >not > > > > > > have any related records in tblorderitems. > > > > > > > > > > > > One way around this problem is to load the values within the > > > > >"inserted" > > > > > > pseudo table into a table variable (assuming ss2k) or >temporary > > >table > > > > >and > > > > > > loop through them using database cursor. However, I am >wondering > > >if > > > > >there > > > > > > is another way. > > > > > > > > > > > > sincerely, > > > > > > Billy > > > > > > > > > > > > > > > >_______________________________________________ > > > > >dba-SQLServer mailing list > > > > >dba-SQLServer at databaseadvisors.com > > > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > > >http://www.databaseadvisors.com > > > > > > > > > > > > > _________________________________________________________________ > > > > Add photos to your e-mail with MSN Premium. Get 2 months FREE* > > > > > > > >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&S >U=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > > > > > > > _______________________________________________ > > > > dba-SQLServer mailing list > > > > dba-SQLServer at databaseadvisors.com > > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > > http://www.databaseadvisors.com > > > > > > > > > >_______________________________________________ > > >dba-SQLServer mailing list > > >dba-SQLServer at databaseadvisors.com > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > >http://www.databaseadvisors.com > > > > > > > _________________________________________________________________ > > MSN Premium helps eliminate e-mail viruses. Get 2 months FREE* > > >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ STOP MORE SPAM with the MSN Premium and get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines From martyconnelly at shaw.ca Sat Jul 17 10:48:23 2004 From: martyconnelly at shaw.ca (MartyConnelly) Date: Sat, 17 Jul 2004 08:48:23 -0700 Subject: [dba-SQLServer] Some quick install notes and warnings on SQL Express 2005 References: Message-ID: <40F94A47.1010006@shaw.ca> SQL Express 2005 is Yukon and replacement for MSDE. However, like MSDE, SQL Express does not have any administrative interfaces. Review the installed documentation and its own BOL to learn more about SQL Express. They are supposed to bring out a Beta EM, backward compatible with MSDE. Some notes I have picked up that may help. 1------------------------------------------------- SQL Express can't run on XP Home, so what is the purpose? One of the purposes for SQL Express is deployment with applications instead of JET. Now the software companies involved have to force their clients to buy XP Pro???? Arrrghhhh! There are rumors you may be able to modify TCP ports to get around this. System Requirements for Express http://lab.msdn.microsoft.com/express/sysreqs/ 2 -------------------------------------------------- FAQ: Installing SQL Express side by side with SQL 2000 Enterprise Manager seems to break EM. It is still broken when You uninstall Express. SQLDMO9 is culprit. http://blogs.msdn.com/sqlexpress/archive/2004/07/04/172956.aspx http://blogs.msdn.com/sqlexpress/archive/2004/07.aspx 3 ------------------------------------------- I noticed that the DTS Runtime will not be included. In Access, you get the DTS Runtime when you install MSDE. Does this mean that DTS will not be available in Access? Currently, I use DTS to interact with SQL Server databases hosted at ISPs. It is a quick and easy solution to use the DTS Wizard to upload data from the Access database to the SQL Server database using bulk insert. I would hate to see that go away. 4 ------------------------------------------------- SQL Server Express does not have any connection limits. 4GB max size It doesn't install any test databases but there is a sample pubs database script install from download pages. I think you can install side by side with MSDE but you will break EM 5.-------------------------------------------------- SQL Server 2000 Reporting Services fails after installing SQL Server 2005 Fix here http://blogs.msdn.com/sqlexpress/archive/2004/07/07/175820.aspx -------------------------------------------------------------------- Welcome to the Visual Web Developer 2005 Express Edition Beta Guided Tour http://beta.asp.net/GuidedTour/s2.aspx Beta Private newsgroup -- good for problems microsoft.private.sqlserver2005.express http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&slcid=us Express overview http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/sseoverview.asp -- Marty Connelly Victoria, B.C. Canada From accessd at shaw.ca Sat Jul 17 11:31:37 2004 From: accessd at shaw.ca (Jim Lawrence (AccessD)) Date: Sat, 17 Jul 2004 09:31:37 -0700 Subject: [dba-SQLServer] Some quick install notes and warnings on SQL Express2005 In-Reply-To: <40F94A47.1010006@shaw.ca> Message-ID: Hi Marty: Fine piece of investigation. I was just about to install SQL Empress on my 2003XP server, one with SQL 2000/EM and would have lost the manager. I wondering if there is a work around as I was hoping to have an application put together using Access2003 or VB.Net and SQL Express, by the end of the summer. Looks like that will not be possible for a while. I guess if the application is assembled, using SQL2000, the table structure/SP etc.. should be portable to SQL Express, on a XP box and Express. A little off topic: I have been trying to find some info on reporting capabilities of VB.Net...does it have any or does it require a third-party product like VB6? Has anyone worked or found a good site with code related to extending VB.Net grid capabilities? Any suggestions will be appreciated. Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of MartyConnelly Sent: Saturday, July 17, 2004 8:48 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Some quick install notes and warnings on SQL Express2005 SQL Express 2005 is Yukon and replacement for MSDE. However, like MSDE, SQL Express does not have any administrative interfaces. Review the installed documentation and its own BOL to learn more about SQL Express. They are supposed to bring out a Beta EM, backward compatible with MSDE. Some notes I have picked up that may help. 1------------------------------------------------- SQL Express can't run on XP Home, so what is the purpose? One of the purposes for SQL Express is deployment with applications instead of JET. Now the software companies involved have to force their clients to buy XP Pro???? Arrrghhhh! There are rumors you may be able to modify TCP ports to get around this. System Requirements for Express http://lab.msdn.microsoft.com/express/sysreqs/ 2 -------------------------------------------------- FAQ: Installing SQL Express side by side with SQL 2000 Enterprise Manager seems to break EM. It is still broken when You uninstall Express. SQLDMO9 is culprit. http://blogs.msdn.com/sqlexpress/archive/2004/07/04/172956.aspx http://blogs.msdn.com/sqlexpress/archive/2004/07.aspx 3 ------------------------------------------- I noticed that the DTS Runtime will not be included. In Access, you get the DTS Runtime when you install MSDE. Does this mean that DTS will not be available in Access? Currently, I use DTS to interact with SQL Server databases hosted at ISPs. It is a quick and easy solution to use the DTS Wizard to upload data from the Access database to the SQL Server database using bulk insert. I would hate to see that go away. 4 ------------------------------------------------- SQL Server Express does not have any connection limits. 4GB max size It doesn't install any test databases but there is a sample pubs database script install from download pages. I think you can install side by side with MSDE but you will break EM 5.-------------------------------------------------- SQL Server 2000 Reporting Services fails after installing SQL Server 2005 Fix here http://blogs.msdn.com/sqlexpress/archive/2004/07/07/175820.aspx -------------------------------------------------------------------- Welcome to the Visual Web Developer 2005 Express Edition Beta Guided Tour http://beta.asp.net/GuidedTour/s2.aspx Beta Private newsgroup -- good for problems microsoft.private.sqlserver2005.express http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&sl cid=us Express overview http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/ sseoverview.asp -- Marty Connelly Victoria, B.C. Canada _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From martyconnelly at shaw.ca Sat Jul 17 13:11:19 2004 From: martyconnelly at shaw.ca (MartyConnelly) Date: Sat, 17 Jul 2004 11:11:19 -0700 Subject: [dba-SQLServer] Some quick install notes and warnings on SQL Express2005 References: Message-ID: <40F96BC7.9080007@shaw.ca> There is a new data grid control with vb.net express. You could use SQL Reporting Services, there is a wizard to upgrade Access reports to SQL Service. Or if you want just local reporting with vb.net and you have Access installed you can use Access Reports. Here is some code that should run under vb.net to print locally, preview or email report. You will need the Access mdb to test against. You may have to modify the Access database and play with to get print menu selection working properly. It has a menu toolbar to direct to various printers or email 'http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm ' Acesss97 example With ms-access interface hidden: And here is the method to call it. I tested this with another Access program but should work with VB. You can even remove the Access Key Icon or set to your own in the upper corner, can't remember how but have done it. Option Compare Database Option Explicit Private Const SW_SHOWMAXIMIZED = 3 Private Const SW_SHOWNORMAL = 1 Private Const SW_HIDE = 0 Private Declare Function apiSetForegroundWindow Lib "user32" _ Alias "SetForegroundWindow" _ (ByVal hWnd As Long) As Long Private Declare Function apiShowWindow Lib "user32" _ Alias "ShowWindow" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Sub test() 'http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm ' Acesss97 example With ms-access interface hidden: Dim accRpt As Access.Application Set accRpt = CreateObject("Access.Application") With accRpt .Application.OpenCurrentDatabase ("C:\WordVBA\Kallal Word Merge Easy Samples\WordMerge22\WordMerge22.mdb") .Application.DoCmd.Maximize .Application.Visible = True Call apiSetForegroundWindow(.hWndAccessApp) 'Call apiShowWindow(.hWndAccessApp, SW_SHOWNORMAL) Call apiShowWindow(.hWndAccessApp, SW_SHOWMAXIMIZED) ' Call apiShowWindow(.hWndAccessApp, SW_HIDE) ' .Application.DoCmd.OpenForm "frmDefaultPrinterList" 'displays the custom toolbar named CustomToolbar in all Microsoft Access windows that become active: .Application.DoCmd.ShowToolbar "Rides Print", acToolbarYes 'DoCmd.ShowToolbar .Application.DoCmd.OpenReport "Contacts", Access.AcView.acViewPreview 'Set the focus to MSACCESS 'alternate method 'Dim lngAcc As Long ' lngVal = FindWindow("OMain", ByVal 0&) ' lngAcc = SetFocusAPI(lngVal) 'must close form to exit second app 'acReport=3;acObjStateOpen=1 Do While .SysCmd(acSysCmdGetObjectState, acReport, "Contacts") = acObjStateOpen DoEvents Loop .Quit acQuitSaveNone 'MsgBox "Print" End With Set accRpt = Nothing End Sub Jim Lawrence (AccessD) wrote: >Hi Marty: > >Fine piece of investigation. > >I was just about to install SQL Empress on my 2003XP server, one with SQL >2000/EM and would have lost the manager. I wondering if there is a work >around as I was hoping to have an application put together using Access2003 >or VB.Net and SQL Express, by the end of the summer. > >Looks like that will not be possible for a while. > >I guess if the application is assembled, using SQL2000, the table >structure/SP etc.. should be portable to SQL Express, on a XP box and >Express. > >A little off topic: > >I have been trying to find some info on reporting capabilities of >VB.Net...does it have any or does it require a third-party product like VB6? >Has anyone worked or found a good site with code related to extending VB.Net >grid capabilities? > >Any suggestions will be appreciated. >Jim > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of >MartyConnelly >Sent: Saturday, July 17, 2004 8:48 AM >To: dba-sqlserver at databaseadvisors.com >Subject: [dba-SQLServer] Some quick install notes and warnings on SQL >Express2005 > > >SQL Express 2005 is Yukon and replacement for MSDE. However, like MSDE, SQL >Express does not have any administrative interfaces. Review the installed >documentation and its own BOL to learn more about SQL Express. They are >supposed to bring out a Beta EM, backward compatible with MSDE. > >Some notes I have picked up that may help. > >1------------------------------------------------- > SQL Express can't run on XP Home, so what is the purpose? > >One of the purposes for SQL Express is deployment with >applications instead of JET. Now the software companies >involved have to force their clients to buy XP Pro???? >Arrrghhhh! > >There are rumors you may be able to modify TCP ports to get around this. > >System Requirements for Express > >http://lab.msdn.microsoft.com/express/sysreqs/ > >2 -------------------------------------------------- >FAQ: Installing SQL Express side by side with SQL 2000 Enterprise Manager >seems to break EM. It is still broken when You uninstall Express. SQLDMO9 is >culprit. > >http://blogs.msdn.com/sqlexpress/archive/2004/07/04/172956.aspx >http://blogs.msdn.com/sqlexpress/archive/2004/07.aspx > >3 ------------------------------------------- > I noticed that the DTS Runtime will not be included. In Access, you get the >DTS Runtime when you install MSDE. Does this mean that DTS will not be >available in Access? > >Currently, I use DTS to interact with SQL Server databases hosted at ISPs. >It is a quick and easy solution to use the DTS Wizard to upload data from >the Access database to the SQL Server database using bulk insert. I would >hate to see that go away. > >4 ------------------------------------------------- >SQL Server Express does not have any connection limits. 4GB max size >It doesn't install any test databases but there is a sample pubs database >script install from download pages. >I think you can install side by side with MSDE but you will break EM > >5.-------------------------------------------------- > SQL Server 2000 Reporting Services fails after installing SQL Server 2005 >Fix here >http://blogs.msdn.com/sqlexpress/archive/2004/07/07/175820.aspx > >-------------------------------------------------------------------- >Welcome to the Visual Web Developer 2005 Express Edition Beta Guided Tour > >http://beta.asp.net/GuidedTour/s2.aspx > >Beta Private newsgroup -- good for problems > >microsoft.private.sqlserver2005.express > >http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&sl >cid=us > > >Express overview >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/ >sseoverview.asp > > >-- >Marty Connelly >Victoria, B.C. >Canada > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > > > -- Marty Connelly Victoria, B.C. Canada From martyconnelly at shaw.ca Sat Jul 17 15:16:10 2004 From: martyconnelly at shaw.ca (MartyConnelly) Date: Sat, 17 Jul 2004 13:16:10 -0700 Subject: [dba-SQLServer] Some quick install notes and warnings on SQL Express2005 References: <40F96BC7.9080007@shaw.ca> Message-ID: <40F9890A.5080607@shaw.ca> Two non-Crystal Reports or Accutate alternatives: Latest version of crystal 9.0 is server based and consequentially pricey 1. ActiveReports (DataDynamics): VB people rave about this report writer. The designer is incredibly intuititive (if you've used Access you will be right at home in this designer). Imports Access Reports Price $499 or $1299 Pro http://www.datadynamics.com/Products/ProductOverview.aspx?Product=ARNET 2. XtraReports (DevExpress): This product is pretty new, and is still rough around the edges, but it is less expensive than ActiveReports (especially considering that you get an End User Designer with the basic product, while you have to buy the Pro version of ActiveReports for the same feature). I have found the designer not quite as nice/intuitive as ActiveReports, but still very nice, and one can be productive with it once getting the hang of how the product is put together. Price $199 or $399 with source code http://www.devexpress.com/?section=/products/NET/XtraReports MartyConnelly wrote: > There is a new data grid control with vb.net express. > > You could use SQL Reporting Services, there is a wizard to upgrade > Access reports to SQL Service. > > Or if you want just local reporting with vb.net and you have Access > installed you can use Access Reports. > Here is some code that should run under vb.net to print locally, > preview or email report. > > You will need the Access mdb to test against. > You may have to modify the Access database and play with to get print > menu selection > working properly. > It has a menu toolbar to direct to various printers or email > > 'http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm > ' Acesss97 example With ms-access interface hidden: > > And here is the method to call it. > I tested this with another Access program but should work with VB. > > You can even remove the Access Key Icon or set to your own > in the upper corner, can't remember how but have done it. > > > > Option Compare Database > Option Explicit > Private Const SW_SHOWMAXIMIZED = 3 > Private Const SW_SHOWNORMAL = 1 > Private Const SW_HIDE = 0 > Private Declare Function apiSetForegroundWindow Lib "user32" _ > Alias "SetForegroundWindow" _ > (ByVal hWnd As Long) As Long > Private Declare Function apiShowWindow Lib "user32" _ > Alias "ShowWindow" _ > (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long > Sub test() > 'http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm > ' Acesss97 example With ms-access interface hidden: > Dim accRpt As Access.Application > Set accRpt = CreateObject("Access.Application") > With accRpt > .Application.OpenCurrentDatabase ("C:\WordVBA\Kallal Word Merge Easy > Samples\WordMerge22\WordMerge22.mdb") > .Application.DoCmd.Maximize > .Application.Visible = True > Call apiSetForegroundWindow(.hWndAccessApp) > 'Call apiShowWindow(.hWndAccessApp, SW_SHOWNORMAL) > Call apiShowWindow(.hWndAccessApp, SW_SHOWMAXIMIZED) > ' Call apiShowWindow(.hWndAccessApp, SW_HIDE) > ' .Application.DoCmd.OpenForm "frmDefaultPrinterList" > 'displays the custom toolbar named CustomToolbar in all Microsoft > Access windows that become active: > > .Application.DoCmd.ShowToolbar "Rides Print", acToolbarYes > 'DoCmd.ShowToolbar > .Application.DoCmd.OpenReport "Contacts", Access.AcView.acViewPreview > 'Set the focus to MSACCESS > 'alternate method > 'Dim lngAcc As Long > ' lngVal = FindWindow("OMain", ByVal 0&) > ' lngAcc = SetFocusAPI(lngVal) > 'must close form to exit second app 'acReport=3;acObjStateOpen=1 > > Do While .SysCmd(acSysCmdGetObjectState, acReport, "Contacts") = > acObjStateOpen > DoEvents > Loop > .Quit acQuitSaveNone > > 'MsgBox "Print" > End With > Set accRpt = Nothing > End Sub > > > > > Jim Lawrence (AccessD) wrote: > >> Hi Marty: >> >> Fine piece of investigation. >> >> I was just about to install SQL Empress on my 2003XP server, one with >> SQL >> 2000/EM and would have lost the manager. I wondering if there is a work >> around as I was hoping to have an application put together using >> Access2003 >> or VB.Net and SQL Express, by the end of the summer. >> >> Looks like that will not be possible for a while. >> >> I guess if the application is assembled, using SQL2000, the table >> structure/SP etc.. should be portable to SQL Express, on a XP box and >> Express. >> >> A little off topic: >> >> I have been trying to find some info on reporting capabilities of >> VB.Net...does it have any or does it require a third-party product >> like VB6? >> Has anyone worked or found a good site with code related to extending >> VB.Net >> grid capabilities? >> >> Any suggestions will be appreciated. >> Jim >> >> -----Original Message----- >> From: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of >> MartyConnelly >> Sent: Saturday, July 17, 2004 8:48 AM >> To: dba-sqlserver at databaseadvisors.com >> Subject: [dba-SQLServer] Some quick install notes and warnings on SQL >> Express2005 >> >> >> SQL Express 2005 is Yukon and replacement for MSDE. However, like >> MSDE, SQL >> Express does not have any administrative interfaces. Review the >> installed >> documentation and its own BOL to learn more about SQL Express. They are >> supposed to bring out a Beta EM, backward compatible with MSDE. >> >> Some notes I have picked up that may help. >> >> 1------------------------------------------------- >> SQL Express can't run on XP Home, so what is the purpose? >> >> One of the purposes for SQL Express is deployment with >> applications instead of JET. Now the software companies >> involved have to force their clients to buy XP Pro???? >> Arrrghhhh! >> >> There are rumors you may be able to modify TCP ports to get around this. >> >> System Requirements for Express >> >> http://lab.msdn.microsoft.com/express/sysreqs/ >> >> 2 -------------------------------------------------- >> FAQ: Installing SQL Express side by side with SQL 2000 Enterprise >> Manager >> seems to break EM. It is still broken when You uninstall Express. >> SQLDMO9 is >> culprit. >> >> http://blogs.msdn.com/sqlexpress/archive/2004/07/04/172956.aspx >> http://blogs.msdn.com/sqlexpress/archive/2004/07.aspx >> >> 3 ------------------------------------------- >> I noticed that the DTS Runtime will not be included. In Access, you >> get the >> DTS Runtime when you install MSDE. Does this mean that DTS will not be >> available in Access? >> >> Currently, I use DTS to interact with SQL Server databases hosted at >> ISPs. >> It is a quick and easy solution to use the DTS Wizard to upload data >> from >> the Access database to the SQL Server database using bulk insert. I >> would >> hate to see that go away. >> >> 4 ------------------------------------------------- >> SQL Server Express does not have any connection limits. 4GB max size >> It doesn't install any test databases but there is a sample pubs >> database >> script install from download pages. >> I think you can install side by side with MSDE but you will break EM >> >> 5.-------------------------------------------------- >> SQL Server 2000 Reporting Services fails after installing SQL Server >> 2005 >> Fix here >> http://blogs.msdn.com/sqlexpress/archive/2004/07/07/175820.aspx >> >> -------------------------------------------------------------------- >> Welcome to the Visual Web Developer 2005 Express Edition Beta Guided >> Tour >> >> http://beta.asp.net/GuidedTour/s2.aspx >> >> Beta Private newsgroup -- good for problems >> >> microsoft.private.sqlserver2005.express >> >> http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&sl >> >> cid=us >> >> >> Express overview >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/ >> >> sseoverview.asp >> >> >> -- >> Marty Connelly >> Victoria, B.C. >> Canada >> >> >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> >> > -- Marty Connelly Victoria, B.C. Canada From accessd at shaw.ca Sat Jul 17 20:13:28 2004 From: accessd at shaw.ca (Jim Lawrence (AccessD)) Date: Sat, 17 Jul 2004 18:13:28 -0700 Subject: [dba-SQLServer] Some quick install notes and warnings on SQLExpress2005 In-Reply-To: <40F9890A.5080607@shaw.ca> Message-ID: Thanks for all the information. I was hoping to go around the third-party printer options. VBxxx lack of report support has been the principle reason why I have had to avoid many applications designs in this environment. Many client bulk at the extra costs and we end up settling for Access. Does SQL Reporting server work with SQL Express? That code snippet is just great...I will try it out soon. I owe you a beer; we should get together sometime as you are a local yokel, from Gods-Country and partake in a few brew. Thanks again Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of MartyConnelly Sent: Saturday, July 17, 2004 1:16 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Some quick install notes and warnings on SQLExpress2005 Two non-Crystal Reports or Accutate alternatives: Latest version of crystal 9.0 is server based and consequentially pricey 1. ActiveReports (DataDynamics): VB people rave about this report writer. The designer is incredibly intuititive (if you've used Access you will be right at home in this designer). Imports Access Reports Price $499 or $1299 Pro http://www.datadynamics.com/Products/ProductOverview.aspx?Product=ARNET 2. XtraReports (DevExpress): This product is pretty new, and is still rough around the edges, but it is less expensive than ActiveReports (especially considering that you get an End User Designer with the basic product, while you have to buy the Pro version of ActiveReports for the same feature). I have found the designer not quite as nice/intuitive as ActiveReports, but still very nice, and one can be productive with it once getting the hang of how the product is put together. Price $199 or $399 with source code http://www.devexpress.com/?section=/products/NET/XtraReports MartyConnelly wrote: > There is a new data grid control with vb.net express. > > You could use SQL Reporting Services, there is a wizard to upgrade > Access reports to SQL Service. > > Or if you want just local reporting with vb.net and you have Access > installed you can use Access Reports. > Here is some code that should run under vb.net to print locally, > preview or email report. > > You will need the Access mdb to test against. > You may have to modify the Access database and play with to get print > menu selection > working properly. > It has a menu toolbar to direct to various printers or email > > 'http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm > ' Acesss97 example With ms-access interface hidden: > > And here is the method to call it. > I tested this with another Access program but should work with VB. > > You can even remove the Access Key Icon or set to your own > in the upper corner, can't remember how but have done it. > > > > Option Compare Database > Option Explicit > Private Const SW_SHOWMAXIMIZED = 3 > Private Const SW_SHOWNORMAL = 1 > Private Const SW_HIDE = 0 > Private Declare Function apiSetForegroundWindow Lib "user32" _ > Alias "SetForegroundWindow" _ > (ByVal hWnd As Long) As Long > Private Declare Function apiShowWindow Lib "user32" _ > Alias "ShowWindow" _ > (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long > Sub test() > 'http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm > ' Acesss97 example With ms-access interface hidden: > Dim accRpt As Access.Application > Set accRpt = CreateObject("Access.Application") > With accRpt > .Application.OpenCurrentDatabase ("C:\WordVBA\Kallal Word Merge Easy > Samples\WordMerge22\WordMerge22.mdb") > .Application.DoCmd.Maximize > .Application.Visible = True > Call apiSetForegroundWindow(.hWndAccessApp) > 'Call apiShowWindow(.hWndAccessApp, SW_SHOWNORMAL) > Call apiShowWindow(.hWndAccessApp, SW_SHOWMAXIMIZED) > ' Call apiShowWindow(.hWndAccessApp, SW_HIDE) > ' .Application.DoCmd.OpenForm "frmDefaultPrinterList" > 'displays the custom toolbar named CustomToolbar in all Microsoft > Access windows that become active: > > .Application.DoCmd.ShowToolbar "Rides Print", acToolbarYes > 'DoCmd.ShowToolbar > .Application.DoCmd.OpenReport "Contacts", Access.AcView.acViewPreview > 'Set the focus to MSACCESS > 'alternate method > 'Dim lngAcc As Long > ' lngVal = FindWindow("OMain", ByVal 0&) > ' lngAcc = SetFocusAPI(lngVal) > 'must close form to exit second app 'acReport=3;acObjStateOpen=1 > > Do While .SysCmd(acSysCmdGetObjectState, acReport, "Contacts") = > acObjStateOpen > DoEvents > Loop > .Quit acQuitSaveNone > > 'MsgBox "Print" > End With > Set accRpt = Nothing > End Sub > > > > > Jim Lawrence (AccessD) wrote: > >> Hi Marty: >> >> Fine piece of investigation. >> >> I was just about to install SQL Empress on my 2003XP server, one with >> SQL >> 2000/EM and would have lost the manager. I wondering if there is a work >> around as I was hoping to have an application put together using >> Access2003 >> or VB.Net and SQL Express, by the end of the summer. >> >> Looks like that will not be possible for a while. >> >> I guess if the application is assembled, using SQL2000, the table >> structure/SP etc.. should be portable to SQL Express, on a XP box and >> Express. >> >> A little off topic: >> >> I have been trying to find some info on reporting capabilities of >> VB.Net...does it have any or does it require a third-party product >> like VB6? >> Has anyone worked or found a good site with code related to extending >> VB.Net >> grid capabilities? >> >> Any suggestions will be appreciated. >> Jim >> >> -----Original Message----- >> From: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of >> MartyConnelly >> Sent: Saturday, July 17, 2004 8:48 AM >> To: dba-sqlserver at databaseadvisors.com >> Subject: [dba-SQLServer] Some quick install notes and warnings on SQL >> Express2005 >> >> >> SQL Express 2005 is Yukon and replacement for MSDE. However, like >> MSDE, SQL >> Express does not have any administrative interfaces. Review the >> installed >> documentation and its own BOL to learn more about SQL Express. They are >> supposed to bring out a Beta EM, backward compatible with MSDE. >> >> Some notes I have picked up that may help. >> >> 1------------------------------------------------- >> SQL Express can't run on XP Home, so what is the purpose? >> >> One of the purposes for SQL Express is deployment with >> applications instead of JET. Now the software companies >> involved have to force their clients to buy XP Pro???? >> Arrrghhhh! >> >> There are rumors you may be able to modify TCP ports to get around this. >> >> System Requirements for Express >> >> http://lab.msdn.microsoft.com/express/sysreqs/ >> >> 2 -------------------------------------------------- >> FAQ: Installing SQL Express side by side with SQL 2000 Enterprise >> Manager >> seems to break EM. It is still broken when You uninstall Express. >> SQLDMO9 is >> culprit. >> >> http://blogs.msdn.com/sqlexpress/archive/2004/07/04/172956.aspx >> http://blogs.msdn.com/sqlexpress/archive/2004/07.aspx >> >> 3 ------------------------------------------- >> I noticed that the DTS Runtime will not be included. In Access, you >> get the >> DTS Runtime when you install MSDE. Does this mean that DTS will not be >> available in Access? >> >> Currently, I use DTS to interact with SQL Server databases hosted at >> ISPs. >> It is a quick and easy solution to use the DTS Wizard to upload data >> from >> the Access database to the SQL Server database using bulk insert. I >> would >> hate to see that go away. >> >> 4 ------------------------------------------------- >> SQL Server Express does not have any connection limits. 4GB max size >> It doesn't install any test databases but there is a sample pubs >> database >> script install from download pages. >> I think you can install side by side with MSDE but you will break EM >> >> 5.-------------------------------------------------- >> SQL Server 2000 Reporting Services fails after installing SQL Server >> 2005 >> Fix here >> http://blogs.msdn.com/sqlexpress/archive/2004/07/07/175820.aspx >> >> -------------------------------------------------------------------- >> Welcome to the Visual Web Developer 2005 Express Edition Beta Guided >> Tour >> >> http://beta.asp.net/GuidedTour/s2.aspx >> >> Beta Private newsgroup -- good for problems >> >> microsoft.private.sqlserver2005.express >> >> http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&sl >> >> cid=us >> >> >> Express overview >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/ >> >> sseoverview.asp >> >> >> -- >> Marty Connelly >> Victoria, B.C. >> Canada >> >> >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> >> > -- Marty Connelly Victoria, B.C. Canada _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Sun Jul 18 21:29:41 2004 From: davide at dalyn.co.nz (David Emerson) Date: Mon, 19 Jul 2004 14:29:41 +1200 Subject: [dba-SQLServer] Values for date ranges Message-ID: <5.2.0.9.0.20040719142057.00b41e68@mail.dalyn.co.nz> Group, I have a table with a field for date, and a field for a number. The number relates to all days from the date until the next record when the new date provides a new number. EG 7/1/04 10 7/5/04 12 7/8/04 15 7/15/04 18 The number 10 applies to 7/1 to 7/4 (providing a total of 10 * 4 days = 40) The number 12 applies to 7/5 to 7/7 (providing a total of 12 * 3 days = 36) The number 15 applies to 7/8 to 7/14 (providing a total of 15 * 7 days = 105) I need to write a sproc that calculates the number of days between each date and adds up the numbers applying to those dates. I can only think of using a cursor and looping through the records recording the start and end dates, and making the calculations. Before I launch into actual code I thought I would check to see if there was any quicker way of doing it (apart from changing the table to record first and last dates). Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 From stuart at lexacorp.com.pg Sun Jul 18 21:39:45 2004 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Mon, 19 Jul 2004 12:39:45 +1000 Subject: [dba-SQLServer] Values for date ranges In-Reply-To: <5.2.0.9.0.20040719142057.00b41e68@mail.dalyn.co.nz> Message-ID: <40FBC111.7550.8B3D198@lexacorp.com.pg> On 19 Jul 2004 at 14:29, David Emerson wrote: > Group, > > I have a table with a field for date, and a field for a number. The number > relates to all days from the date until the next record when the new date > provides a new number. EG > > 7/1/04 10 > 7/5/04 12 > 7/8/04 15 > 7/15/04 18 > > The number 10 applies to 7/1 to 7/4 (providing a total of 10 * 4 days = 40) > The number 12 applies to 7/5 to 7/7 (providing a total of 12 * 3 days = 36) > The number 15 applies to 7/8 to 7/14 (providing a total of 15 * 7 days = 105) > > I need to write a sproc that calculates the number of days between each > date and adds up the numbers applying to those dates. I can only think of > using a cursor and looping through the records recording the start and end > dates, and making the calculations. Before I launch into actual code I > thought I would check to see if there was any quicker way of doing it > (apart from changing the table to record first and last dates). > Haven't got time now to do the whole thiing, I'm flying out in an hour or so to do so work for a client on site but.... In pseudocode, I would try something like Sum(numbers * datediff (currentrecorddate, (select max(date) from table where date < currentrecorddate))) -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support. From HARVEYF1 at WESTAT.com Mon Jul 19 09:07:06 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Mon, 19 Jul 2004 10:07:06 -0400 Subject: [dba-SQLServer] Values for date ranges Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E998@remail2.westat.com> David, I'd be tempted to put the data into a table with an identity and then self-link the current and next rows. Any estimate on the size of the table you're working with? Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of David Emerson > Sent: Sunday, July 18, 2004 10:30 PM > To: dba-SQLServer at databaseadvisors.com > Subject: [dba-SQLServer] Values for date ranges > > > Group, > > I have a table with a field for date, and a field for a > number. The number > relates to all days from the date until the next record when > the new date > provides a new number. EG > > 7/1/04 10 > 7/5/04 12 > 7/8/04 15 > 7/15/04 18 > > The number 10 applies to 7/1 to 7/4 (providing a total of 10 > * 4 days = 40) > The number 12 applies to 7/5 to 7/7 (providing a total of 12 > * 3 days = 36) > The number 15 applies to 7/8 to 7/14 (providing a total of 15 > * 7 days = 105) > > I need to write a sproc that calculates the number of days > between each > date and adds up the numbers applying to those dates. I can > only think of > using a cursor and looping through the records recording the > start and end > dates, and making the calculations. Before I launch into > actual code I > thought I would check to see if there was any quicker way of doing it > (apart from changing the table to record first and last dates). > > Regards > > David Emerson > Dalyn Software Ltd > 25 Cunliffe St, Churton Park > Wellington, New Zealand > Ph/Fax (04) 478-7456 > Mobile 027-280-9348 From martyconnelly at shaw.ca Mon Jul 19 13:41:20 2004 From: martyconnelly at shaw.ca (MartyConnelly) Date: Mon, 19 Jul 2004 11:41:20 -0700 Subject: [dba-SQLServer] Some quick install notes and warnings on SQLExpress2005 References: Message-ID: <40FC15D0.4020309@shaw.ca> SQL Reporting Services works with SQL Express Beta with some known bugs using encrypted data. Microsoft has a few 1 hour webcasts TechNet Webcast: Microsoft SQL Server Reporting Services Technical Overview - Level Part 1 http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032255670&Culture=en-US Part 2 http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032255691&Culture=en-US Overview Architecture http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032255609&Culture=en-US There is a new book out that covers SQL 2005 may not be printed yet Hitchhikers Guide to SQL Reporting Services by Addison How to import reports from Microsoft Access to Reporting Services http://support.microsoft.com/?kbid=834306 You could try this limited freeware ASP report tool works with SQL 2000 http://www.apexsql.com/index_asprpt.htm Introduction to SQL Server 2000 Reporting Services By Mike Gunderloy http://www.developer.com/db/article.php/3323401 I tried to get into my local "Honest John's" downtown last week couldn't get near the bar. We had been invaded by half the ship's crew from the "Abraham Lincoln" carrier. Jim Lawrence (AccessD) wrote: >Thanks for all the information. > >I was hoping to go around the third-party printer options. VBxxx lack of >report support has been the principle reason why I have had to avoid many >applications designs in this environment. Many client bulk at the extra >costs and we end up settling for Access. > >Does SQL Reporting server work with SQL Express? > >That code snippet is just great...I will try it out soon. > >I owe you a beer; we should get together sometime as you are a local yokel, >from Gods-Country and partake in a few brew. > >Thanks again >Jim > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of >MartyConnelly >Sent: Saturday, July 17, 2004 1:16 PM >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] Some quick install notes and warnings on >SQLExpress2005 > > > >Two non-Crystal Reports or Accutate alternatives: >Latest version of crystal 9.0 is server based and consequentially pricey > >1. ActiveReports (DataDynamics): VB people rave about this report >writer. The designer is incredibly intuititive (if you've used Access >you will be right at home in this designer). Imports Access Reports >Price $499 or $1299 Pro > >http://www.datadynamics.com/Products/ProductOverview.aspx?Product=ARNET > >2. XtraReports (DevExpress): This product is pretty new, and is still >rough around the edges, but it is less expensive than ActiveReports >(especially considering that you get an End User Designer with the basic >product, while you have to buy the Pro version of ActiveReports for the >same feature). I have found the designer not quite as nice/intuitive as >ActiveReports, but still very nice, and one can be productive with it >once getting the hang of how the product is put together. >Price $199 or $399 with source code > >http://www.devexpress.com/?section=/products/NET/XtraReports > > > >MartyConnelly wrote: > > > >>There is a new data grid control with vb.net express. >> >>You could use SQL Reporting Services, there is a wizard to upgrade >>Access reports to SQL Service. >> >>Or if you want just local reporting with vb.net and you have Access >>installed you can use Access Reports. >>Here is some code that should run under vb.net to print locally, >>preview or email report. >> >>You will need the Access mdb to test against. >>You may have to modify the Access database and play with to get print >>menu selection >>working properly. >>It has a menu toolbar to direct to various printers or email >> >>'http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm >>' Acesss97 example With ms-access interface hidden: >> >>And here is the method to call it. >>I tested this with another Access program but should work with VB. >> >>You can even remove the Access Key Icon or set to your own >>in the upper corner, can't remember how but have done it. >> >> >> >>Option Compare Database >>Option Explicit >>Private Const SW_SHOWMAXIMIZED = 3 >>Private Const SW_SHOWNORMAL = 1 >>Private Const SW_HIDE = 0 >>Private Declare Function apiSetForegroundWindow Lib "user32" _ >> Alias "SetForegroundWindow" _ >> (ByVal hWnd As Long) As Long >>Private Declare Function apiShowWindow Lib "user32" _ >> Alias "ShowWindow" _ >> (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long >>Sub test() >>'http://www.attcanada.net/~kallal.msn/msaccess/DownLoad.htm >>' Acesss97 example With ms-access interface hidden: >>Dim accRpt As Access.Application >>Set accRpt = CreateObject("Access.Application") >>With accRpt >>.Application.OpenCurrentDatabase ("C:\WordVBA\Kallal Word Merge Easy >>Samples\WordMerge22\WordMerge22.mdb") >>.Application.DoCmd.Maximize >>.Application.Visible = True >>Call apiSetForegroundWindow(.hWndAccessApp) >>'Call apiShowWindow(.hWndAccessApp, SW_SHOWNORMAL) >>Call apiShowWindow(.hWndAccessApp, SW_SHOWMAXIMIZED) >>' Call apiShowWindow(.hWndAccessApp, SW_HIDE) >>' .Application.DoCmd.OpenForm "frmDefaultPrinterList" >>'displays the custom toolbar named CustomToolbar in all Microsoft >>Access windows that become active: >> >>.Application.DoCmd.ShowToolbar "Rides Print", acToolbarYes >>'DoCmd.ShowToolbar >>.Application.DoCmd.OpenReport "Contacts", Access.AcView.acViewPreview >>'Set the focus to MSACCESS >>'alternate method >>'Dim lngAcc As Long >>' lngVal = FindWindow("OMain", ByVal 0&) >> ' lngAcc = SetFocusAPI(lngVal) >>'must close form to exit second app 'acReport=3;acObjStateOpen=1 >> >> Do While .SysCmd(acSysCmdGetObjectState, acReport, "Contacts") = >>acObjStateOpen >> DoEvents >> Loop >>.Quit acQuitSaveNone >> >>'MsgBox "Print" >>End With >>Set accRpt = Nothing >>End Sub >> >> >> >> >>Jim Lawrence (AccessD) wrote: >> >> >> >>>Hi Marty: >>> >>>Fine piece of investigation. >>> >>>I was just about to install SQL Empress on my 2003XP server, one with >>>SQL >>>2000/EM and would have lost the manager. I wondering if there is a work >>>around as I was hoping to have an application put together using >>>Access2003 >>>or VB.Net and SQL Express, by the end of the summer. >>> >>>Looks like that will not be possible for a while. >>> >>>I guess if the application is assembled, using SQL2000, the table >>>structure/SP etc.. should be portable to SQL Express, on a XP box and >>>Express. >>> >>>A little off topic: >>> >>>I have been trying to find some info on reporting capabilities of >>>VB.Net...does it have any or does it require a third-party product >>>like VB6? >>>Has anyone worked or found a good site with code related to extending >>>VB.Net >>>grid capabilities? >>> >>>Any suggestions will be appreciated. >>>Jim >>> >>>-----Original Message----- >>>From: dba-sqlserver-bounces at databaseadvisors.com >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of >>>MartyConnelly >>>Sent: Saturday, July 17, 2004 8:48 AM >>>To: dba-sqlserver at databaseadvisors.com >>>Subject: [dba-SQLServer] Some quick install notes and warnings on SQL >>>Express2005 >>> >>> >>>SQL Express 2005 is Yukon and replacement for MSDE. However, like >>>MSDE, SQL >>>Express does not have any administrative interfaces. Review the >>>installed >>>documentation and its own BOL to learn more about SQL Express. They are >>>supposed to bring out a Beta EM, backward compatible with MSDE. >>> >>>Some notes I have picked up that may help. >>> >>>1------------------------------------------------- >>>SQL Express can't run on XP Home, so what is the purpose? >>> >>>One of the purposes for SQL Express is deployment with >>>applications instead of JET. Now the software companies >>>involved have to force their clients to buy XP Pro???? >>>Arrrghhhh! >>> >>>There are rumors you may be able to modify TCP ports to get around this. >>> >>>System Requirements for Express >>> >>>http://lab.msdn.microsoft.com/express/sysreqs/ >>> >>>2 -------------------------------------------------- >>>FAQ: Installing SQL Express side by side with SQL 2000 Enterprise >>>Manager >>>seems to break EM. It is still broken when You uninstall Express. >>>SQLDMO9 is >>>culprit. >>> >>>http://blogs.msdn.com/sqlexpress/archive/2004/07/04/172956.aspx >>>http://blogs.msdn.com/sqlexpress/archive/2004/07.aspx >>> >>>3 ------------------------------------------- >>>I noticed that the DTS Runtime will not be included. In Access, you >>>get the >>>DTS Runtime when you install MSDE. Does this mean that DTS will not be >>>available in Access? >>> >>>Currently, I use DTS to interact with SQL Server databases hosted at >>>ISPs. >>>It is a quick and easy solution to use the DTS Wizard to upload data >>>from >>>the Access database to the SQL Server database using bulk insert. I >>>would >>>hate to see that go away. >>> >>>4 ------------------------------------------------- >>>SQL Server Express does not have any connection limits. 4GB max size >>>It doesn't install any test databases but there is a sample pubs >>>database >>>script install from download pages. >>>I think you can install side by side with MSDE but you will break EM >>> >>>5.-------------------------------------------------- >>>SQL Server 2000 Reporting Services fails after installing SQL Server >>>2005 >>>Fix here >>>http://blogs.msdn.com/sqlexpress/archive/2004/07/07/175820.aspx >>> >>>-------------------------------------------------------------------- >>>Welcome to the Visual Web Developer 2005 Express Edition Beta Guided >>>Tour >>> >>>http://beta.asp.net/GuidedTour/s2.aspx >>> >>>Beta Private newsgroup -- good for problems >>> >>>microsoft.private.sqlserver2005.express >>> >>> >>> >>> >http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005&sl > > >>>cid=us >>> >>> >>>Express overview >>> >>> >>> >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/ > > >>>sseoverview.asp >>> >>> >>>-- >>>Marty Connelly >>>Victoria, B.C. >>>Canada >>> >>> >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >>> >>>_______________________________________________ >>>dba-SQLServer mailing list >>>dba-SQLServer at databaseadvisors.com >>>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >>>http://www.databaseadvisors.com >>> >>> >>> >>> >>> >>> > >-- >Marty Connelly >Victoria, B.C. >Canada > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > > > -- Marty Connelly Victoria, B.C. Canada From davide at dalyn.co.nz Tue Jul 20 01:16:10 2004 From: davide at dalyn.co.nz (David Emerson) Date: Tue, 20 Jul 2004 18:16:10 +1200 Subject: [dba-SQLServer] Values for date ranges In-Reply-To: <40FBC111.7550.8B3D198@lexacorp.com.pg> References: <5.2.0.9.0.20040719142057.00b41e68@mail.dalyn.co.nz> Message-ID: <5.2.0.9.0.20040720180106.00b92970@mail.dalyn.co.nz> Thanks Stuart. I am having trouble converting your pseudocode into SQL. >Sum(numbers * datediff (currentrecorddate, (select max(date) from table >where >date < currentrecorddate))) How can I reference currentrecorddate in the Select part when it is not part of the select statement? David At 19/07/2004, you wrote: >On 19 Jul 2004 at 14:29, David Emerson wrote: > > > Group, > > > > I have a table with a field for date, and a field for a number. The > number > > relates to all days from the date until the next record when the new date > > provides a new number. EG > > > > 7/1/04 10 > > 7/5/04 12 > > 7/8/04 15 > > 7/15/04 18 > > > > The number 10 applies to 7/1 to 7/4 (providing a total of 10 * 4 days = 40) > > The number 12 applies to 7/5 to 7/7 (providing a total of 12 * 3 days = 36) > > The number 15 applies to 7/8 to 7/14 (providing a total of 15 * 7 days > = 105) > > > > I need to write a sproc that calculates the number of days between each > > date and adds up the numbers applying to those dates. I can only think of > > using a cursor and looping through the records recording the start and end > > dates, and making the calculations. Before I launch into actual code I > > thought I would check to see if there was any quicker way of doing it > > (apart from changing the table to record first and last dates). > > > >Haven't got time now to do the whole thiing, I'm flying out in an hour or >so to >do so work for a client on site but.... > >In pseudocode, I would try something like > >Sum(numbers * datediff (currentrecorddate, (select max(date) from table >where >date < currentrecorddate))) > > > >-- >Lexacorp Ltd >http://www.lexacorp.com.pg >Information Technology Consultancy, Software Development,System Support. > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 From davide at dalyn.co.nz Tue Jul 20 01:15:57 2004 From: davide at dalyn.co.nz (David Emerson) Date: Tue, 20 Jul 2004 18:15:57 +1200 Subject: [dba-SQLServer] Values for date ranges In-Reply-To: <446DDE75CFC7E1438061462F85557B0F0481E998@remail2.westat.co m> Message-ID: <5.2.0.9.0.20040720181414.00bbd810@mail.dalyn.co.nz> Francis, The table is not large at this stage (only 700 records with about 60 added each month). I think that what you are suggesting is what I envisaged I need to do - just looking to see if there were any easy tricks. David At 19/07/2004, you wrote: >David, > >I'd be tempted to put the data into a table with an identity and then >self-link the current and next rows. Any estimate on the size of the table >you're working with? > >Francis R Harvey III >WB 303, (301)294-3952 >harveyf1 at westat.com > > > > -----Original Message----- > > From: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > > Of David Emerson > > Sent: Sunday, July 18, 2004 10:30 PM > > To: dba-SQLServer at databaseadvisors.com > > Subject: [dba-SQLServer] Values for date ranges > > > > > > Group, > > > > I have a table with a field for date, and a field for a > > number. The number > > relates to all days from the date until the next record when > > the new date > > provides a new number. EG > > > > 7/1/04 10 > > 7/5/04 12 > > 7/8/04 15 > > 7/15/04 18 > > > > The number 10 applies to 7/1 to 7/4 (providing a total of 10 > > * 4 days = 40) > > The number 12 applies to 7/5 to 7/7 (providing a total of 12 > > * 3 days = 36) > > The number 15 applies to 7/8 to 7/14 (providing a total of 15 > > * 7 days = 105) > > > > I need to write a sproc that calculates the number of days > > between each > > date and adds up the numbers applying to those dates. I can > > only think of > > using a cursor and looping through the records recording the > > start and end > > dates, and making the calculations. Before I launch into > > actual code I > > thought I would check to see if there was any quicker way of doing it > > (apart from changing the table to record first and last dates). > > > > Regards > > > > David Emerson > > Dalyn Software Ltd > > 25 Cunliffe St, Churton Park > > Wellington, New Zealand > > Ph/Fax (04) 478-7456 > > Mobile 027-280-9348 > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 From HARVEYF1 at WESTAT.com Tue Jul 20 06:48:54 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Tue, 20 Jul 2004 07:48:54 -0400 Subject: [dba-SQLServer] Values for date ranges Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E9A2@remail2.westat.com> David, Yeah, that would get too big for it to be practical to load it into a new table with the necessary identity each time. I would not suggest adding the identity to your table as you might delete rows leading to gaps in the row numbers. I would be interested in a comparison of your cursor and Stuart's method if you try both. I am not absolutely convinced that a cursor approach would lose out here. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of David Emerson > Sent: Tuesday, July 20, 2004 2:16 AM > To: dba-sqlserver at databaseadvisors.com > Subject: RE: [dba-SQLServer] Values for date ranges > > > Francis, > > The table is not large at this stage (only 700 records with > about 60 added > each month). > > I think that what you are suggesting is what I envisaged I > need to do - > just looking to see if there were any easy tricks. > > David From HARVEYF1 at WESTAT.com Tue Jul 20 07:24:41 2004 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Tue, 20 Jul 2004 08:24:41 -0400 Subject: [dba-SQLServer] Values for date ranges Message-ID: <446DDE75CFC7E1438061462F85557B0F0481E9A3@remail2.westat.com> David, Maybe: SELECT SUM(PeriodSum) AS PeriodTotalSum FROM ( SELECT t2.PeriodValue * DateDiff (day,t2.PeriodStart, ( SELECT MIN(t1.PeriodStart) FROM dbo.Period as t1 WHERE t1.PeriodStart > t2.PeriodStart ) ) AS PeriodSum FROM dbo.Period as t2 WHERE ( SELECT MIN(t1.PeriodStart) FROM dbo.Period as t1 WHERE t1.PeriodStart > t2.PeriodStart ) IS NOT NULL ) as t3 Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of David Emerson > Sent: Tuesday, July 20, 2004 2:16 AM > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] Values for date ranges > > > Thanks Stuart. I am having trouble converting your > pseudocode into SQL. > > >Sum(numbers * datediff (currentrecorddate, (select > max(date) from table > >where > >date < currentrecorddate))) > > How can I reference currentrecorddate in the Select part when > it is not > part of the select statement? > > David From davide at dalyn.co.nz Tue Jul 20 14:21:49 2004 From: davide at dalyn.co.nz (David Emerson) Date: Wed, 21 Jul 2004 07:21:49 +1200 Subject: [dba-SQLServer] Values for date ranges In-Reply-To: <446DDE75CFC7E1438061462F85557B0F0481E9A3@remail2.westat.co m> Message-ID: <5.2.0.9.0.20040721071943.00b2ddb0@mail.dalyn.co.nz> Thanks Stuart and Francis once again. I have decided to go the way of the cursors because there are extra steps needed such as setting the first and last dates (each could be between records). David At 20/07/2004, you wrote: >David, > >Maybe: > >SELECT SUM(PeriodSum) AS PeriodTotalSum >FROM > ( > SELECT > t2.PeriodValue * > DateDiff > (day,t2.PeriodStart, > ( > SELECT MIN(t1.PeriodStart) > FROM dbo.Period as t1 > WHERE t1.PeriodStart > t2.PeriodStart > ) > ) AS PeriodSum > FROM dbo.Period as t2 > WHERE > ( > SELECT MIN(t1.PeriodStart) > FROM dbo.Period as t1 > WHERE t1.PeriodStart > t2.PeriodStart > ) IS NOT NULL > ) as t3 > >Francis R Harvey III >WB 303, (301)294-3952 >harveyf1 at westat.com > > > > -----Original Message----- > > From: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > > Of David Emerson > > Sent: Tuesday, July 20, 2004 2:16 AM > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] Values for date ranges > > > > > > Thanks Stuart. I am having trouble converting your > > pseudocode into SQL. > > > > >Sum(numbers * datediff (currentrecorddate, (select > > max(date) from table > > >where > > >date < currentrecorddate))) > > > > How can I reference currentrecorddate in the Select part when > > it is not > > part of the select statement? > > > > David > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From paul.hartland at fsmail.net Wed Jul 21 06:59:15 2004 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Wed, 21 Jul 2004 13:59:15 +0200 (CEST) Subject: [dba-SQLServer] Views With Parameters ? Message-ID: <13975403.1090411155251.JavaMail.www@wwinf3001> To all, Is it possible to create a parameter type view in SQL Server 7.0, which I can then call from Visual Basic 6. Something like SELECT * FROM tblPersonnel WHERE tblPersonnel.PayrollNo = ? and then in VB something like rsPerson.Open("Query '" & Me.PayrollNo & "'"),OpenSQLConn etc etc Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From mikedorism at adelphia.net Wed Jul 21 07:23:32 2004 From: mikedorism at adelphia.net (Mike & Doris Manning) Date: Wed, 21 Jul 2004 08:23:32 -0400 Subject: [dba-SQLServer] Views With Parameters ? In-Reply-To: <13975403.1090411155251.JavaMail.www@wwinf3001> Message-ID: <000001c46f1d$8a103830$cc0aa845@hargrove.internal> To my knowledge, views don't take parameters...only Stored Procedures do... Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of paul.hartland at fsmail.net Sent: Wednesday, July 21, 2004 7:59 AM To: dba-sqlserver Subject: [dba-SQLServer] Views With Parameters ? To all, Is it possible to create a parameter type view in SQL Server 7.0, which I can then call from Visual Basic 6. Something like SELECT * FROM tblPersonnel WHERE tblPersonnel.PayrollNo = ? and then in VB something like rsPerson.Open("Query '" & Me.PayrollNo & "'"),OpenSQLConn etc etc Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From paul.hartland at fsmail.net Wed Jul 21 07:27:49 2004 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Wed, 21 Jul 2004 14:27:49 +0200 (CEST) Subject: [dba-SQLServer] Views With Parameters ? Message-ID: <10485429.1090412869654.JavaMail.www@wwinf3001> Thought as much, thank you. Message date : Jul 21 2004, 01:22 PM >From : "Mike & Doris Manning" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] Views With Parameters ? To my knowledge, views don't take parameters...only Stored Procedures do... Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of paul.hartland at fsmail.net Sent: Wednesday, July 21, 2004 7:59 AM To: dba-sqlserver Subject: [dba-SQLServer] Views With Parameters ? To all, Is it possible to create a parameter type view in SQL Server 7.0, which I can then call from Visual Basic 6. Something like SELECT * FROM tblPersonnel WHERE tblPersonnel.PayrollNo = ? and then in VB something like rsPerson.Open("Query '" & Me.PayrollNo & "'"),OpenSQLConn etc etc Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From paul.hartland at fsmail.net Wed Jul 21 10:35:21 2004 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Wed, 21 Jul 2004 17:35:21 +0200 (CEST) Subject: [dba-SQLServer] Update Data From Same Table In Different Database Message-ID: <1495094.1090424121734.JavaMail.www@wwinf3001> To all, I have two database?s in SQL Server 7.0, Genesis and GenesisTest. Genesis contains all tables that have been directly exported from a live Access database, and GenesisTest contains some of the tables from Genesis which I am modifying (field names, lengths, datatypes etc). I have a table called tblPersonnel in both SQL databases, what I want is a query to link the two tables by PayrollNo and update data in certain fields in the GenesisTest database. Whats the best way to do this, I am such a novice at SQL that I first thought about linking them both into an Access database and doing the query in there, but I?m sure there must be a better way. Thanks for any help in advance. Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From CMackin at Quiznos.com Wed Jul 21 10:41:17 2004 From: CMackin at Quiznos.com (Mackin, Christopher) Date: Wed, 21 Jul 2004 09:41:17 -0600 Subject: [dba-SQLServer] Update Data From Same Table In Different Database Message-ID: To reference any SQL table the syntax is ServerName.DatabaseName.CreatedByName.TableName The majority of times you'll see just the last one or two, so dbo.tblPersonnel, but to reference a table in another database you just use: GenesisTest.dbo.tblPersonnel So you scan set up a stright update query using the two tables: GenesisTest.dbo.tblPersonnel and Genesis.dbo.tblPersonnel -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Wednesday, July 21, 2004 9:35 AM To: dba-sqlserver Subject: [dba-SQLServer] Update Data From Same Table In Different Database To all, I have two database's in SQL Server 7.0, Genesis and GenesisTest. Genesis contains all tables that have been directly exported from a live Access database, and GenesisTest contains some of the tables from Genesis which I am modifying (field names, lengths, datatypes etc). I have a table called tblPersonnel in both SQL databases, what I want is a query to link the two tables by PayrollNo and update data in certain fields in the GenesisTest database. Whats the best way to do this, I am such a novice at SQL that I first thought about linking them both into an Access database and doing the query in there, but I'm sure there must be a better way. Thanks for any help in advance. Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From paul.hartland at fsmail.net Thu Jul 22 04:51:45 2004 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Thu, 22 Jul 2004 11:51:45 +0200 (CEST) Subject: [dba-SQLServer] Update Data From Same Table In Different Database Message-ID: <31672489.1090489905926.JavaMail.www@wwinf3003> Thanks for help, I tried the following stored procedure: CREATE PROCEDURE [genesis_update_PersonnelRightToWork] AS SET NOCOUNT ON UPDATE [GenesisTest].[dbo].[tblPersonnel] SET [RightToWorkID] = [Genesis].[dbo].[tblPersonnel].[RightToWorkID] WHERE ( [PayrollNo] = [Genesis].[dbo].[tblPersonnel].[PayrollNo] ) SET NOCOUNT OFF Something like the column prefix [Genesis].[dbo].[tblPersonnel] does not match with a table name or alias Any help anyone ? Thanks in advance Paul Hartland Message date : Jul 21 2004, 04:42 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] Update Data From Same Table In Different Database To reference any SQL table the syntax is ServerName.DatabaseName.CreatedByName.TableName The majority of times you'll see just the last one or two, so dbo.tblPersonnel, but to reference a table in another database you just use: GenesisTest.dbo.tblPersonnel So you scan set up a stright update query using the two tables: GenesisTest.dbo.tblPersonnel and Genesis.dbo.tblPersonnel -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Wednesday, July 21, 2004 9:35 AM To: dba-sqlserver Subject: [dba-SQLServer] Update Data From Same Table In Different Database To all, I have two database's in SQL Server 7.0, Genesis and GenesisTest. Genesis contains all tables that have been directly exported from a live Access database, and GenesisTest contains some of the tables from Genesis which I am modifying (field names, lengths, datatypes etc). I have a table called tblPersonnel in both SQL databases, what I want is a query to link the two tables by PayrollNo and update data in certain fields in the GenesisTest database. Whats the best way to do this, I am such a novice at SQL that I first thought about linking them both into an Access database and doing the query in there, but I'm sure there must be a better way. Thanks for any help in advance. Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From artful at rogers.com Thu Jul 22 10:00:54 2004 From: artful at rogers.com (Arthur Fuller) Date: Thu, 22 Jul 2004 11:00:54 -0400 Subject: [dba-SQLServer] tsql help - propogate that pk In-Reply-To: Message-ID: <02b701c46ffc$b05eefb0$6601a8c0@rock> Have you considered using an "Instead Of" trigger, Billy? That might give you everything you need. I just wrote a SQL Tip for Builder.com on how and when to use "Instead Of" triggers, but since it hasn't been published yet I can't attach it to a public list like this. However, I encourage you to look up "Instead Of Triggers" in BOL, and go from there. From what I have gathered, an Instead Of trigger will let you accomplish exactly what you need. Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang Sent: Friday, July 16, 2004 4:05 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] tsql help - propogate that pk Hi Shamil: The sentence from BOL is absolutely correct. But it does not give me what I want; I need to have "identity" values moved from one table to another after a view insert. There is no doubt that a view can update multiple base tables; there is no question about that; and it is possible to reference them unambigiously; however, the fact that it is an "instead of insert", it is not possible to reference any identity values generated from the view (without using scope_identity()). This would not be a problem if it was possible to create an "After" trigger on a view. And yes, it works eloquently in Access. For demonstration purposes, within Access, create two tables with following schema: tablea tablea_id autonumber tablea_value text(50) tableb tableb_id autonumber tableb_tablea_id number long tableb_value text(50) then create a query called qryInsert with the following source: SELECT tablea.tablea_id, tableb.tableb_id, tablea.tablea_value, tableb.tableb_value, tableb.tableb_tablea_id, tablea.tablea_id FROM tablea INNER JOIN tableb ON tablea.tablea_id = tableb.tableb_tablea_id; then create and execute the following query: insert into qryInsert(tablea_value, tableb_value) values('a','b') followed by: insert into qryInsert(tablea_value, tableb_value) select tablea_value, tableb_value from qryInsert and again.. insert into qryInsert(tablea_value, tableb_value) select tablea_value, tableb_value from qryInsert and you will find four records in tablea as expected, four records in tableb as expected and all four records in tablea have related records in tableb. Access was able to do this without any database triggers. And Access was able to accommodate "view inserts" that have SELECT as source. If SQL Server is able to immitate this behavior (without using scope_identity(), of course :) ), then I am would like to know. Kindest regards, Billy >From: "Shamil Salakhetdinov" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] tsql help - propogate that pk >Date: Fri, 16 Jul 2004 22:22:25 +0400 > >Billy, > >What about that sentence from BOL?: > >"SQL Server 2000 >Updatable views can modify more than one table involved in the view. >The DELETE, INSERT, and UPDATE statements can reference a view as long >as SQL Server can translate the user's update request unambiguously to >updates in the base tables referenced in the view's definition. Expect >differences in behavior when working with updatable views with more >than one table involved in the DELETE, INSERT, or UPDATE statements." > > > I was actually hoping for a solution that is > > quite simple >For me the solution looks simple. I called it tricky only because it's >not obvious when starting to work with instead of triggers. You can >also use a simple stored procedure to fullfill your task... > > > the view insert (where it > > affects multiple tables) works eloquently in MS Access but not in > > Sql Server. >Are you sure it will work in MS Access for your task? (This question >is not an invitation to MS Access vs. MS SQL2000 discussion) > >Shamil > >----- Original Message ----- >From: "Billy Pang" >To: >Sent: Friday, July 16, 2004 3:18 AM >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > Thanks Shamil for your time. I was actually hoping for a solution >that is > > quite simple (perhaps I was overlooking something very obvious). I >thought > > that there was a more simple solution because the view insert (where >it > > affects multiple tables) works eloquently in MS Access but not in > > Sql Server. > > > > Regards, > > Billy > > > > > > > > > > >From: "Shamil Salakhetdinov" > > >Reply-To: dba-sqlserver at databaseadvisors.com > > >To: "dba-SQLServer" > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > >Date: Fri, 16 Jul 2004 02:32:23 +0400 > > > > > >Hi Billy, > > > > > >You didn't ask about inserting several rows using instead of insert > > >trigger, did you? :) > > > > > >Well, I think it can be done without cursors but we have to assume >that > > >there is no UNIVERSAL solution for such a case - I mean that for > > >each certain case the cursor-less solution with instead of triggers > > >could have quite different implementation - as always in > > >programming an "optimal" solution is a balance of interests, a > > >compromise: > > > > > >So if we assume that when several rows are inserted against my > > >sample view then this means that: > > > > > >1. they all belong to one order > > >2. product name is unique > > > > > >Then one of the the solutons is: > > > > > >- insert all rows into tblProduct from inserted if there is no yet >such > > >product, > > >- insert one row into tblOrder from inserted, > > >- insert all rows into tblOrdItem from inserted joined to > > >tblProduct >on > > >ProdName > > > > > >See SQL script in P.S. of this message. > > > > > >If you need something more complicated - e.g. inserting several >orders > > >against view like in the current sample avoiding cursors' usage by >all > > >means - if you need that - then you're welcome to hire me to do > > >that >and > > >other tricky work! :) > > > > > >HTH, > > >Shamil > > > > > >P.S. Solution: > > > > > > > > >CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] > > >INSTEAD OF INSERT > > >AS > > >declare @ordID int > > > > > >Set NoCount On > > > > > >-- ///////////////////////////////////////////////// > > >Insert Into [dbo].[tblProduct] > > >( > > > [prodName] > > > , [prodCurPrice] > > >) > > >select > > > prodName > > > , prodCurPrice > > >from inserted where (prodName not in (select prodName from >tblProduct)) > > > > > >-- ///////////////////////////////////////////////// > > >Insert Into [dbo].[tblOrder] > > >( > > > [ordDate] > > > , [custId] > > > , [ordCurTotal] > > >) > > >select top 1 > > > ordDate > > > , custId > > > , ordCurTotal > > >from inserted > > > > > >Set @ordID = Cast(SCOPE_IDENTITY() As [int]) > > >-- ///////////////////////////////////////////////// > > >Insert Into [dbo].[tblOrderItem] > > >( > > > [ordId] > > > , [prodId] > > > , [oitAmount] > > >) > > >select > > > @ordId > > > , p.prodId > > > , oitAmount > > >from inserted i inner join tblProduct p on i.prodName = p.prodName > > >-- ///////////////////////////////////////////////// > > > > > >Set NoCount Off > > >----- Original Message ----- > > >From: "Billy Pang" > > >To: > > >Sent: Friday, July 16, 2004 1:18 AM > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > > > > Hi Shamil: > > > > > > > > Thanks for your assistance. Your solution will only work based > > > > on >the > > > > assumption that records can only be inserted into tblOrder one > > > > at >a > > >time; if > > > > insert statement for tblOrder table has "select" as source, then >the > > > > tblorderid fk in tblorderitem table may contain incorrect value. > > > > > > > > Using below example as example, execute the following insert > > >statements: > > > > > > > > <--- cut here ---> > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > >prodCurPrice, > > > > oitAmount) > > > > values(getdate(),1,2,'product name',4,5) > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > >prodCurPrice, > > > > oitAmount) > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, >oitAmount > > >from > > > > qselOrder > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > >prodCurPrice, > > > > oitAmount) > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, >oitAmount > > >from > > > > qselOrder > > > > <--- cut here ---> > > > > > > > > assuming tblorder table is empty from very beginning, it will >insert > > >four > > > > records into tblorder table as expected and four records into > > >tblorderitems > > > > table as expected. however, the fourth record in tblorder table >does > > >not > > > > have any related records in tblorderitems. > > > > > > > > One way around this problem is to load the values within the > > >"inserted" > > > > pseudo table into a table variable (assuming ss2k) or temporary >table > > >and > > > > loop through them using database cursor. However, I am > > > > wondering >if > > >there > > > > is another way. > > > > > > > > sincerely, > > > > Billy > > > > > > > > > >_______________________________________________ > > >dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > >http://www.databaseadvisors.com > > > > > > > _________________________________________________________________ > > Add photos to your e-mail with MSN Premium. Get 2 months FREE* > > >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&S >U=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > > > _______________________________________________ > > dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN Premium helps eliminate e-mail viruses. Get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU =http://hotmail.com/enca&HL=Market_MSNIS_Taglines _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From artful at rogers.com Thu Jul 22 10:08:18 2004 From: artful at rogers.com (Arthur Fuller) Date: Thu, 22 Jul 2004 11:08:18 -0400 Subject: [dba-SQLServer] Values for date ranges In-Reply-To: <5.2.0.9.0.20040719142057.00b41e68@mail.dalyn.co.nz> Message-ID: <02bd01c46ffd$b8b07e80$6601a8c0@rock> Just improvising here, so this is not genuine SQL, but.... Join the table to itself, but the second instance is something like SELECT TOP 1 WHERE Date > MyCurrentDate (and of course the join occurs on the PK), so that the joined data looks something like this (you didn't mention the PK so I've added it in parens): (pk) 7/1/04 10 (pk) 7/5/04 12 Assuming that you can join the tables like this, then it's trivial to subtract the first date from the second to give you the number of days. Does this help? Arthur -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Sunday, July 18, 2004 10:30 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Values for date ranges Group, I have a table with a field for date, and a field for a number. The number relates to all days from the date until the next record when the new date provides a new number. EG 7/1/04 10 7/5/04 12 7/8/04 15 7/15/04 18 The number 10 applies to 7/1 to 7/4 (providing a total of 10 * 4 days = 40) The number 12 applies to 7/5 to 7/7 (providing a total of 12 * 3 days = 36) The number 15 applies to 7/8 to 7/14 (providing a total of 15 * 7 days = 105) I need to write a sproc that calculates the number of days between each date and adds up the numbers applying to those dates. I can only think of using a cursor and looping through the records recording the start and end dates, and making the calculations. Before I launch into actual code I thought I would check to see if there was any quicker way of doing it (apart from changing the table to record first and last dates). Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (04) 478-7456 Mobile 027-280-9348 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From kens.programming at verizon.net Thu Jul 22 12:15:08 2004 From: kens.programming at verizon.net (Ken Stoker) Date: Thu, 22 Jul 2004 10:15:08 -0700 Subject: [dba-SQLServer] Crosstabs - Pivots In-Reply-To: Message-ID: <20040722171416.OTOZ1464.out001.verizon.net@enterprise> Someone may have something better, but something like the following is the way I get a crosstab-like query in SQL Server: SELECT JOB, CASE WHEN LEDGER = '04PRA' THEN BALANCE END AS '04PRA', CASE WHEN LEDGER = '04PRB' THEN BALANCE END AS '04PRB' FROM ... This assumes that you know the number of columns that you are 'transforming'. Hope this helps. Ken -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Haslett, Andrew Sent: Thursday, July 15, 2004 12:23 AM To: 'dba-sqlserver at databaseadvisors.com' Subject: [dba-SQLServer] Crosstabs - Pivots Greetings all. The infamous crosstab question! I've managed to get the data I require in the following format JOB LEDGER BALANCE 0862 04PRA 68444.85 0862 04PRB 44783.0 0915 04PRA 5092.0 0915 04PRB 46000.0 1045 04PRA 5400.0 1045 04PRB 5400.0 How can I transform it to this: JOB 04PRA 04PRB 0862 68444.85 44783.0 0915 5092.0 46000.0 1045 54000.0 5400.0 A few samples on the net show you how to do it, but they all require a numeric value to pivot on so you can use an aggregate function. I don't want to aggregate anything - just transform (pivot) them... Thanks in advance Andrew IMPORTANT - PLEASE READ ******************** This email and any files transmitted with it are confidential and may contain information protected by law from disclosure. If you have received this message in error, please notify the sender immediately and delete this email from your system. No warranty is given that this email or files, if attached to this email, are free from computer viruses or other defects. They are provided on the basis the user assumes all responsibility for loss, damage or consequence resulting directly or indirectly from their use, whether caused by the negligence of the sender or not. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Thu Jul 22 14:16:23 2004 From: davide at dalyn.co.nz (David Emerson) Date: Fri, 23 Jul 2004 07:16:23 +1200 Subject: [dba-SQLServer] Values for date ranges In-Reply-To: <02bd01c46ffd$b8b07e80$6601a8c0@rock> References: <5.2.0.9.0.20040719142057.00b41e68@mail.dalyn.co.nz> Message-ID: <5.2.0.9.0.20040723071335.00b2db28@mail.dalyn.co.nz> Thanks Arthur, I ended up needing to us a cursor in the end because there were other factors like needing to select records for a range of dates and changing the first and last dates if they were not exactly on the range. I also needed to make sure that if there was only one record that it was included if it fell within the range. The ideas everyone gave me will certainly be able to be used in the future. David At 22/07/2004, you wrote: >Just improvising here, so this is not genuine SQL, but.... > >Join the table to itself, but the second instance is something like >SELECT TOP 1 WHERE Date > MyCurrentDate (and of course the join occurs >on the PK), so that the joined data looks something like this (you >didn't mention the PK so I've added it in parens): > >(pk) 7/1/04 10 (pk) 7/5/04 12 > >Assuming that you can join the tables like this, then it's trivial to >subtract the first date from the second to give you the number of days. > >Does this help? >Arthur > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >Emerson >Sent: Sunday, July 18, 2004 10:30 PM >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer] Values for date ranges > > >Group, > >I have a table with a field for date, and a field for a number. The >number >relates to all days from the date until the next record when the new >date >provides a new number. EG > >7/1/04 10 >7/5/04 12 >7/8/04 15 >7/15/04 18 > >The number 10 applies to 7/1 to 7/4 (providing a total of 10 * 4 days = >40) The number 12 applies to 7/5 to 7/7 (providing a total of 12 * 3 >days = 36) The number 15 applies to 7/8 to 7/14 (providing a total of 15 >* 7 days = 105) > >I need to write a sproc that calculates the number of days between each >date and adds up the numbers applying to those dates. I can only think >of >using a cursor and looping through the records recording the start and >end >dates, and making the calculations. Before I launch into actual code I >thought I would check to see if there was any quicker way of doing it >(apart from changing the table to record first and last dates). > >Regards > >David Emerson >Dalyn Software Ltd >25 Cunliffe St, Churton Park >Wellington, New Zealand >Ph/Fax (04) 478-7456 >Mobile 027-280-9348 > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From tuxedo_man at hotmail.com Thu Jul 22 19:41:39 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Fri, 23 Jul 2004 00:41:39 +0000 Subject: [dba-SQLServer] tsql help - propogate that pk Message-ID: Thanks Arthur for the tip. The instead of trigger will help me for single inserts into the view because I can use scope_identity value from first insert to populate the child record. Then the instead of trigger may need to incorporate a database cursor to loop through all records in inserted psuedo table to find the scope_identity value and insert the record into the child tables. Sincerely, Billy >From: "Arthur Fuller" >Reply-To: dba-sqlserver at databaseadvisors.com >To: >Subject: RE: [dba-SQLServer] tsql help - propogate that pk >Date: Thu, 22 Jul 2004 11:00:54 -0400 > >Have you considered using an "Instead Of" trigger, Billy? That might >give you everything you need. I just wrote a SQL Tip for Builder.com on >how and when to use "Instead Of" triggers, but since it hasn't been >published yet I can't attach it to a public list like this. However, I >encourage you to look up "Instead Of Triggers" in BOL, and go from >there. From what I have gathered, an Instead Of trigger will let you >accomplish exactly what you need. > >Arthur > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy >Pang >Sent: Friday, July 16, 2004 4:05 PM >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > >Hi Shamil: > >The sentence from BOL is absolutely correct. But it does not give me >what I >want; I need to have "identity" values moved from one table to another >after >a view insert. There is no doubt that a view can update multiple base >tables; there is no question about that; and it is possible to reference > >them unambigiously; however, the fact that it is an "instead of insert", >it >is not possible to reference any identity values generated from the view > >(without using scope_identity()). This would not be a problem if it was > >possible to create an "After" trigger on a view. > >And yes, it works eloquently in Access. For demonstration purposes, >within >Access, create two tables with following schema: > >tablea >tablea_id autonumber >tablea_value text(50) > >tableb >tableb_id autonumber >tableb_tablea_id number long >tableb_value text(50) > >then create a query called qryInsert with the following source: > >SELECT tablea.tablea_id, tableb.tableb_id, tablea.tablea_value, >tableb.tableb_value, tableb.tableb_tablea_id, tablea.tablea_id FROM >tablea INNER JOIN tableb ON tablea.tablea_id = tableb.tableb_tablea_id; > >then create and execute the following query: > >insert into qryInsert(tablea_value, tableb_value) values('a','b') > >followed by: > >insert into qryInsert(tablea_value, tableb_value) >select tablea_value, tableb_value >from qryInsert > >and again.. > >insert into qryInsert(tablea_value, tableb_value) >select tablea_value, tableb_value >from qryInsert > >and you will find four records in tablea as expected, four records in >tableb >as expected and all four records in tablea have related records in >tableb. > >Access was able to do this without any database triggers. And Access >was >able to accommodate "view inserts" that have SELECT as source. If SQL >Server is able to immitate this behavior (without using >scope_identity(), of >course :) ), then I am would like to know. > >Kindest regards, >Billy > > >From: "Shamil Salakhetdinov" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > >Date: Fri, 16 Jul 2004 22:22:25 +0400 > > > >Billy, > > > >What about that sentence from BOL?: > > > >"SQL Server 2000 > >Updatable views can modify more than one table involved in the view. > >The DELETE, INSERT, and UPDATE statements can reference a view as long > >as SQL Server can translate the user's update request unambiguously to > >updates in the base tables referenced in the view's definition. Expect > >differences in behavior when working with updatable views with more > >than one table involved in the DELETE, INSERT, or UPDATE statements." > > > > > I was actually hoping for a solution that is > > > quite simple > >For me the solution looks simple. I called it tricky only because it's > >not obvious when starting to work with instead of triggers. You can > >also use a simple stored procedure to fullfill your task... > > > > > the view insert (where it > > > affects multiple tables) works eloquently in MS Access but not in > > > Sql Server. > >Are you sure it will work in MS Access for your task? (This question > >is not an invitation to MS Access vs. MS SQL2000 discussion) > > > >Shamil > > > >----- Original Message ----- > >From: "Billy Pang" > >To: > >Sent: Friday, July 16, 2004 3:18 AM > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > Thanks Shamil for your time. I was actually hoping for a solution > >that is > > > quite simple (perhaps I was overlooking something very obvious). I > >thought > > > that there was a more simple solution because the view insert (where > >it > > > affects multiple tables) works eloquently in MS Access but not in > > > Sql Server. > > > > > > Regards, > > > Billy > > > > > > > > > > > > > > > >From: "Shamil Salakhetdinov" > > > >Reply-To: dba-sqlserver at databaseadvisors.com > > > >To: "dba-SQLServer" > > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > >Date: Fri, 16 Jul 2004 02:32:23 +0400 > > > > > > > >Hi Billy, > > > > > > > >You didn't ask about inserting several rows using instead of insert > > > > >trigger, did you? :) > > > > > > > >Well, I think it can be done without cursors but we have to assume > >that > > > >there is no UNIVERSAL solution for such a case - I mean that for > > > >each certain case the cursor-less solution with instead of triggers > > > > >could have quite different implementation - as always in > > > >programming an "optimal" solution is a balance of interests, a > > > >compromise: > > > > > > > >So if we assume that when several rows are inserted against my > > > >sample view then this means that: > > > > > > > >1. they all belong to one order > > > >2. product name is unique > > > > > > > >Then one of the the solutons is: > > > > > > > >- insert all rows into tblProduct from inserted if there is no yet > >such > > > >product, > > > >- insert one row into tblOrder from inserted, > > > >- insert all rows into tblOrdItem from inserted joined to > > > >tblProduct > >on > > > >ProdName > > > > > > > >See SQL script in P.S. of this message. > > > > > > > >If you need something more complicated - e.g. inserting several > >orders > > > >against view like in the current sample avoiding cursors' usage by > >all > > > >means - if you need that - then you're welcome to hire me to do > > > >that > >and > > > >other tricky work! :) > > > > > > > >HTH, > > > >Shamil > > > > > > > >P.S. Solution: > > > > > > > > > > > >CREATE TRIGGER [qselInsert] ON [dbo].[qselOrder] > > > >INSTEAD OF INSERT > > > >AS > > > >declare @ordID int > > > > > > > >Set NoCount On > > > > > > > >-- ///////////////////////////////////////////////// > > > >Insert Into [dbo].[tblProduct] > > > >( > > > > [prodName] > > > > , [prodCurPrice] > > > >) > > > >select > > > > prodName > > > > , prodCurPrice > > > >from inserted where (prodName not in (select prodName from > >tblProduct)) > > > > > > > >-- ///////////////////////////////////////////////// > > > >Insert Into [dbo].[tblOrder] > > > >( > > > > [ordDate] > > > > , [custId] > > > > , [ordCurTotal] > > > >) > > > >select top 1 > > > > ordDate > > > > , custId > > > > , ordCurTotal > > > >from inserted > > > > > > > >Set @ordID = Cast(SCOPE_IDENTITY() As [int]) > > > >-- ///////////////////////////////////////////////// > > > >Insert Into [dbo].[tblOrderItem] > > > >( > > > > [ordId] > > > > , [prodId] > > > > , [oitAmount] > > > >) > > > >select > > > > @ordId > > > > , p.prodId > > > > , oitAmount > > > >from inserted i inner join tblProduct p on i.prodName = p.prodName > > > >-- ///////////////////////////////////////////////// > > > > > > > >Set NoCount Off > > > >----- Original Message ----- > > > >From: "Billy Pang" > > > >To: > > > >Sent: Friday, July 16, 2004 1:18 AM > > > >Subject: Re: [dba-SQLServer] tsql help - propogate that pk > > > > > > > > > > > > > Hi Shamil: > > > > > > > > > > Thanks for your assistance. Your solution will only work based > > > > > on > >the > > > > > assumption that records can only be inserted into tblOrder one > > > > > at > >a > > > >time; if > > > > > insert statement for tblOrder table has "select" as source, then > >the > > > > > tblorderid fk in tblorderitem table may contain incorrect value. > > > > > > > > > > Using below example as example, execute the following insert > > > >statements: > > > > > > > > > > <--- cut here ---> > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > >prodCurPrice, > > > > > oitAmount) > > > > > values(getdate(),1,2,'product name',4,5) > > > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > >prodCurPrice, > > > > > oitAmount) > > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, > >oitAmount > > > >from > > > > > qselOrder > > > > > > > > > > insert into qselOrder(ordDate, custId, ordCurTotal, prodName, > > > >prodCurPrice, > > > > > oitAmount) > > > > > select ordDate, custId, ordCurTotal, prodName, prodCurPrice, > >oitAmount > > > >from > > > > > qselOrder > > > > > <--- cut here ---> > > > > > > > > > > assuming tblorder table is empty from very beginning, it will > >insert > > > >four > > > > > records into tblorder table as expected and four records into > > > >tblorderitems > > > > > table as expected. however, the fourth record in tblorder table > >does > > > >not > > > > > have any related records in tblorderitems. > > > > > > > > > > One way around this problem is to load the values within the > > > >"inserted" > > > > > pseudo table into a table variable (assuming ss2k) or temporary > >table > > > >and > > > > > loop through them using database cursor. However, I am > > > > > wondering > >if > > > >there > > > > > is another way. > > > > > > > > > > sincerely, > > > > > Billy > > > > > > > > > > > > >_______________________________________________ > > > >dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com > > > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > >http://www.databaseadvisors.com > > > > > > > > > > _________________________________________________________________ > > > Add photos to your e-mail with MSN Premium. Get 2 months FREE* > > > > >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&S > >U=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > > > > > > _______________________________________________ > > > dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > >_________________________________________________________________ >MSN Premium helps eliminate e-mail viruses. Get 2 months FREE* >http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU >=http://hotmail.com/enca&HL=Market_MSNIS_Taglines > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN? Premium right now and get the first two months FREE*. From jwcolby at colbyconsulting.com Sat Jul 24 10:43:11 2004 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Sat, 24 Jul 2004 11:43:11 -0400 Subject: [dba-SQLServer] What happens when In-Reply-To: <003c01c46aa6$f38a50a0$0201a8c0@PARIS> Message-ID: <000701c47194$f007fb90$80b3fea9@ColbyM6805> What happens in SQL Server when a specific statement fails? I am looking at a process of building a table, then inserting data into that table, building another table, placing related data into that table. All using SQL. The statements that place data in the first table require thaqt the build table statement work of course, and the statements that place data into the second table should not occur unless the entire first sequence occurs since the second table is related to the first. I understand the concept of transactions but what really happens? Psuedo code Start transaction Build table1 Insert Row2 Insert Row3 Insert Row4 Build Table2 Insert row5 Insert row6 Insert Row7 Commit 1) First, can statements that alter the database design be included inside of transaction statements? Whould I need to rearrange that to: Build table1 Build Table2 Start transaction Insert Row2 Insert Row3 Insert Row4 Insert row5 Insert row6 Insert Row7 Commit 2) Suppose that Build Table1 fails? Do the rest of the statements attempt to execute? Does the process fail immediately and report an error, refusing to execute any subsequent statements? 3) Suppose that Insert Row3 fails? Do the rest of the statements attempt to execute or does the process fail and rollback automatically? 4) Is my process that is executng the code responsible for checking for errors after each statement? 5) I have discovered how to create a script for creating the table structure, but how do I create a script for creating the data in the table, given a table with data in it? 6) Can scripts be executed directly (from windows explorer)? I can take a script and paste it into enterprise manager (query analyzer) and execute all statements at one time. John W. Colby From mwp.reid at qub.ac.uk Sat Jul 24 12:14:11 2004 From: mwp.reid at qub.ac.uk (Martin Reid) Date: Sat, 24 Jul 2004 18:14:11 +0100 Subject: [dba-SQLServer] What happens when References: <000701c47194$f007fb90$80b3fea9@ColbyM6805> Message-ID: <001d01c471a1$a4739c90$1b02a8c0@MARTINREID> John As far as I know with a transaction either it all suceeds or it all fails. SO if Build Table 1 fails then the transaction fails totally. The Begin Trans statement makes SQL Server treat everythig that follows as a single statement hence the "all fail" if one fails. RE statements (MSDN) all TSQL Statements with the exception of the following can be useed inside a transaction ALTER DATABASE LOAD DATABASE BACKUP LOG LOAD TRANSACTION CREATE DATABASE RECONFIGURE DISK INIT RESTORE DATABASE DROP DATABASE RESTORE LOG DUMP TRANSACTION UPDATE STATISTICS You should check for errors if your using an SP by testing @@Error if an error occurs and branch out to the error handler. Put this directly following any INSERT statement as its value is subject to change between statement execution. Use DTS for the data task. I am sure you could execute the script from windows but at the command prompt using ISQL. Never tried it via Win Explorer but bet soemone will show a way. How about a little Bat file?? Martin ----- Original Message ----- From: "John W. Colby" To: Sent: Saturday, July 24, 2004 4:43 PM Subject: [dba-SQLServer] What happens when > What happens in SQL Server when a specific statement fails? > > I am looking at a process of building a table, then inserting data into that > table, building another table, placing related data into that table. All > using SQL. The statements that place data in the first table require thaqt > the build table statement work of course, and the statements that place data > into the second table should not occur unless the entire first sequence > occurs since the second table is related to the first. > > I understand the concept of transactions but what really happens? > > Psuedo code > > Start transaction > Build table1 > Insert Row2 > Insert Row3 > Insert Row4 > > Build Table2 > Insert row5 > Insert row6 > Insert Row7 > Commit > > 1) First, can statements that alter the database design be included inside > of transaction statements? Whould I need to rearrange that to: > > Build table1 > Build Table2 > > Start transaction > Insert Row2 > Insert Row3 > Insert Row4 > > Insert row5 > Insert row6 > Insert Row7 > Commit > 2) Suppose that Build Table1 fails? Do the rest of the statements attempt > to execute? Does the process fail immediately and report an error, refusing > to execute any subsequent statements? > > 3) Suppose that Insert Row3 fails? Do the rest of the statements attempt to > execute or does the process fail and rollback automatically? > > 4) Is my process that is executng the code responsible for checking for > errors after each statement? > > 5) I have discovered how to create a script for creating the table > structure, but how do I create a script for creating the data in the table, > given a table with data in it? > > 6) Can scripts be executed directly (from windows explorer)? I can take a > script and paste it into enterprise manager (query analyzer) and execute all > statements at one time. > > John W. Colby > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > >