From paul.hartland at fsmail.net Thu Jun 1 04:00:10 2006 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Thu, 1 Jun 2006 11:00:10 +0200 (CEST) Subject: [dba-SQLServer] SQL Documenter Message-ID: <18582123.1149152410208.JavaMail.www@wwinf3203> To all, Is there a (hopefully freebie) tool somewhere where I can list all tables etc inside a SQL database. Thanks in advance. Paul Hartland From mikedorism at verizon.net Thu Jun 1 11:05:51 2006 From: mikedorism at verizon.net (Mike & Doris Manning) Date: Thu, 01 Jun 2006 12:05:51 -0400 Subject: [dba-SQLServer] SQL Documenter In-Reply-To: <18582123.1149152410208.JavaMail.www@wwinf3203> Message-ID: <000001c68595$427ae750$2f01a8c0@dorismanning> Absolute! It comes with EM. Right click on the database and choose "Generate Script". Doris Manning mikedorism at verizon.net From DavidL at sierranevada.com Thu Jun 1 12:18:40 2006 From: DavidL at sierranevada.com (David Lewis) Date: Thu, 1 Jun 2006 10:18:40 -0700 Subject: [dba-SQLServer] SQL Documenter Message-ID: <00101736F13D774F88C54058CB2663C868EE5C@celebration.sierranevada.corp> ---------------------------------------------------------------------- Message: 1 Date: Thu, 1 Jun 2006 11:00:10 +0200 (CEST) From: paul.hartland at fsmail.net Subject: [dba-SQLServer] SQL Documenter To: dba-sqlserver Message-ID: <18582123.1149152410208.JavaMail.www at wwinf3203> Content-Type: text/plain; charset=UTF-8 To all, Is there a (hopefully freebie) tool somewhere where I can list all tables etc inside a SQL database. Thanks in advance. Paul Hartland There is an excellent tool called DBDocumentor at www.elzaris.com. I have been using it for about a month. It is not free, but is reasonably priced and their support has been excellent. D. Lewis From artful at rogers.com Thu Jun 1 14:18:59 2006 From: artful at rogers.com (Arthur Fuller) Date: Thu, 1 Jun 2006 15:18:59 -0400 (EDT) Subject: [dba-SQLServer] SQL Documenter In-Reply-To: <00101736F13D774F88C54058CB2663C868EE5C@celebration.sierranevada.corp> Message-ID: <20060601191859.64240.qmail@web88207.mail.re2.yahoo.com> You can grab a 30-day eval of SQLDoc from Apex. I highly recommend this software. I used it at work at the bosses were so dazzled they ordered a site licence for the entire Ontario Ministry of Health. I deem this software awesome, and at the price unbeatable. Actually, Apex makes some other great tools, and offers a bundle of them all for an astonishly low price. Google "Apex SQL" for more information and a free 30-day trial. Arthur David Lewis wrote: ---------------------------------------------------------------------- Message: 1 Date: Thu, 1 Jun 2006 11:00:10 +0200 (CEST) From: paul.hartland at fsmail.net Subject: [dba-SQLServer] SQL Documenter To: dba-sqlserver Message-ID: <18582123.1149152410208.JavaMail.www at wwinf3203> Content-Type: text/plain; charset=UTF-8 To all, Is there a (hopefully freebie) tool somewhere where I can list all tables etc inside a SQL database. Thanks in advance. Paul Hartland There is an excellent tool called DBDocumentor at www.elzaris.com. I have been using it for about a month. It is not free, but is reasonably priced and their support has been excellent. D. Lewis _______________________________________________ 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 Jun 1 14:58:24 2006 From: rl_stewart at highstream.net (Robert L. Stewart) Date: Thu, 01 Jun 2006 15:58:24 -0400 Subject: [dba-SQLServer] SQL Documenter In-Reply-To: References: Message-ID: <1149191904.447f46e0712b2@webmail.highstream.net> You can also use the system tables to generate the list for you. Robert L. Stewart The Dyson Group International Software for the Non-profit Enterprise Expanding your Sphere of Knowledge Quoting dba-sqlserver-request at databaseadvisors.com: > From: paul.hartland at fsmail.net > Subject: [dba-SQLServer] SQL Documenter > To: dba-sqlserver > Message-ID: <18582123.1149152410208.JavaMail.www at wwinf3203> > Content-Type: text/plain; charset=UTF-8 > > To all, > Is there a (hopefully freebie) tool somewhere where I can list all tables etc > inside a SQL database. > Thanks in advance. > Paul Hartland From shait at mindspring.com Thu Jun 1 15:18:34 2006 From: shait at mindspring.com (Stephen Hait) Date: Thu, 1 Jun 2006 16:18:34 -0400 Subject: [dba-SQLServer] SQL Documenter In-Reply-To: <1149191904.447f46e0712b2@webmail.highstream.net> References: <1149191904.447f46e0712b2@webmail.highstream.net> Message-ID: Look at the system table, sysobjects, in the database in question. User tables have xtype='U'. On 6/1/06, Robert L. Stewart wrote: > You can also use the system tables to generate the list for you. > > Robert L. Stewart > The Dyson Group International > Software for the Non-profit Enterprise > Expanding your Sphere of Knowledge > > > Quoting dba-sqlserver-request at databaseadvisors.com: > > > From: paul.hartland at fsmail.net > > Subject: [dba-SQLServer] SQL Documenter > > To: dba-sqlserver > > Message-ID: <18582123.1149152410208.JavaMail.www at wwinf3203> > > Content-Type: text/plain; charset=UTF-8 > > > > To all, > > Is there a (hopefully freebie) tool somewhere where I can list all tables etc > > inside a SQL database. > > Thanks in advance. > > Paul Hartland > > > > _______________________________________________ > 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 Thu Jun 1 21:03:11 2006 From: martyconnelly at shaw.ca (MartyConnelly) Date: Thu, 01 Jun 2006 19:03:11 -0700 Subject: [dba-SQLServer] SQL Documenter In-Reply-To: <20060601191859.64240.qmail@web88207.mail.re2.yahoo.com> References: <20060601191859.64240.qmail@web88207.mail.re2.yahoo.com> Message-ID: <447F9C5F.2060302@shaw.ca> I dunno. OHIP and dazzling APEX software in the same breath. I am still struggling with BC Pharmacare. ;) Arthur Fuller wrote: >You can grab a 30-day eval of SQLDoc from Apex. I highly recommend this software. I used it at work at the bosses were so dazzled they ordered a site licence for the entire Ontario Ministry of Health. I deem this software awesome, and at the price unbeatable. Actually, Apex makes some other great tools, and offers a bundle of them all for an astonishly low price. Google "Apex SQL" for more information and a free 30-day trial. > >Arthur > >David Lewis wrote: > >---------------------------------------------------------------------- > >Message: 1 >Date: Thu, 1 Jun 2006 11:00:10 +0200 (CEST) >From: paul.hartland at fsmail.net >Subject: [dba-SQLServer] SQL Documenter >To: dba-sqlserver >Message-ID: <18582123.1149152410208.JavaMail.www at wwinf3203> >Content-Type: text/plain; charset=UTF-8 > >To all, >Is there a (hopefully freebie) tool somewhere where I can list all >tables etc inside a SQL database. >Thanks in advance. >Paul Hartland > > > >There is an excellent tool called DBDocumentor at www.elzaris.com. I >have been using it for about a month. It is not free, but is reasonably >priced and their support has been excellent. > >D. Lewis >_______________________________________________ >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 fhtapia at gmail.com Fri Jun 2 17:45:20 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 2 Jun 2006 15:45:20 -0700 Subject: [dba-SQLServer] Fun with T-Sql Message-ID: This really is a fun job, sometimes you won't find out what people want to report on.. :D. Generally i hate to sit and write reports, as it's always similar to one you just wrote but just enough diffrences that it needs to be a completely new report :|. today I'm writing one on a part list where i need to find parts that have failed a 2nd time within 90 days of the first failure :| so part a fails in 1/1/06, and fails again in 2/28/06... the 2/28 counts, but not the initial one. likewise, if a part fails again on 3/3/06, that counts as well because it's within 90 days of the 2/28 fail. fields are PN, FailDate Initially i'm gonna dump the fields to a temp table so I can work with a smaller subset of data. i think i should dump out the distinct pn list as well, i could create a while loop to find all pn that failed within 90 days of each other and dump out the ones that do not. so in my above example, if a part fails again at 7/1/06, that fail no longer counts as it's > 90 days since the last fail. not really expecting a reply just venting :) -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From fhtapia at gmail.com Fri Jun 2 17:59:57 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 2 Jun 2006 15:59:57 -0700 Subject: [dba-SQLServer] Fun with T-Sql In-Reply-To: References: Message-ID: my buddy just replied... I should just dump the data into a temp table once, where the pn has a count > 1 then inner join the resulting temp table where the dates are within 90 days :) nifty. On 6/2/06, Francisco Tapia wrote: > This really is a fun job, sometimes you won't find out what people > want to report on.. :D. Generally i hate to sit and write reports, as > it's always similar to one you just wrote but just enough diffrences > that it needs to be a completely new report :|. > > today I'm writing one on a part list where i need to find parts that > have failed a 2nd time within 90 days of the first failure :| > > so part a fails in 1/1/06, and fails again in 2/28/06... the 2/28 > counts, but not the initial one. likewise, if a part fails again on > 3/3/06, that counts as well because it's within 90 days of the 2/28 > fail. > > fields are > > PN, FailDate > > Initially i'm gonna dump the fields to a temp table so I can work with > a smaller subset of data. > > i think i should dump out the distinct pn list as well, i could create > a while loop to find all pn that failed within 90 days of each other > and dump out the ones that do not. so in my above example, if a part > fails again at 7/1/06, that fail no longer counts as it's > 90 days > since the last fail. > > not really expecting a reply just venting :) > > > > -- > -Francisco > http://pcthis.blogspot.com |PC news with out the jargon! > http://sqlthis.blogspot.com | Tsql and More... > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From accessd at shaw.ca Sat Jun 3 11:14:04 2006 From: accessd at shaw.ca (Jim Lawrence) Date: Sat, 03 Jun 2006 09:14:04 -0700 Subject: [dba-SQLServer] Fun with T-Sql In-Reply-To: Message-ID: <0J0A0018NKZK3ZA1@l-daemon> So it is just a test against any a list of parts that have failed greater than ninety days and a list of parts that have failed less than ninety days. Does this have to have parts that have failed multiple times within ninety days? Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia Sent: Friday, June 02, 2006 3:45 PM To: SQL Server 2k List; dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Fun with T-Sql This really is a fun job, sometimes you won't find out what people want to report on.. :D. Generally i hate to sit and write reports, as it's always similar to one you just wrote but just enough diffrences that it needs to be a completely new report :|. today I'm writing one on a part list where i need to find parts that have failed a 2nd time within 90 days of the first failure :| so part a fails in 1/1/06, and fails again in 2/28/06... the 2/28 counts, but not the initial one. likewise, if a part fails again on 3/3/06, that counts as well because it's within 90 days of the 2/28 fail. fields are PN, FailDate Initially i'm gonna dump the fields to a temp table so I can work with a smaller subset of data. i think i should dump out the distinct pn list as well, i could create a while loop to find all pn that failed within 90 days of each other and dump out the ones that do not. so in my above example, if a part fails again at 7/1/06, that fail no longer counts as it's > 90 days since the last fail. not really expecting a reply just venting :) -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... _______________________________________________ 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 Mon Jun 5 06:15:08 2006 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Mon, 5 Jun 2006 13:15:08 +0200 (CEST) Subject: [dba-SQLServer] Enterprise Manager Opening, But No Objects !!!! Message-ID: <28339648.1149506108190.JavaMail.www@wwinf3003> To all, Have just come to open my Enterprise Manager and I am getting the error as below: Microsoft SQL-DMO Error 126: General Error If you click the ok button Enterprise Manager opens but it's as if all my registration properties have been lost, I tried right clicking on SQL Server Groups and New SQL Server Registration but then get another error message as below: Server Registration Information Cannot Be Changed On Remote Registeries. Has anyone else ever had the same problem, if so how do I go about resolving this...I have thought about re-installing my SQL Server on my machine, but thought I would see if I can get away without doing this. Thanks in advance for any help on this. Paul Hartland Database Developer. From martyconnelly at shaw.ca Mon Jun 5 12:07:37 2006 From: martyconnelly at shaw.ca (MartyConnelly) Date: Mon, 05 Jun 2006 10:07:37 -0700 Subject: [dba-SQLServer] Enterprise Manager Opening, But No Objects !!!! In-Reply-To: <28339648.1149506108190.JavaMail.www@wwinf3003> References: <28339648.1149506108190.JavaMail.www@wwinf3003> Message-ID: <448464D9.6010504@shaw.ca> Don't know if this fixed in a final released version of SQL 2005 or Express But if you have installed either might be a conflict between SQL-DMO and SQL-SMO. Just a maybe guess .. got this from sqlexpress's WebLog on MSDN http://blogs.msdn.com/sqlexpress This is a cached version as I cant reach it just now FAQ: Installing SQL Express side by side with SQL 2000 Enterprise Manager seems to break it, its still broken when I uninstall express, whats going on? Because of changes in the SQL Server 2005 metadata we have updated SQLDMO, the new version is SQLDMO9, it should work with SQL Server 7/2000 and 2005. For backwards compatibility it is installed by SQL Express so that existing DMO apps should just work. Due to the way that SQLDMO is versioned, only one version can exist on a machine at one time, so when Express is installed the SQLDMO9 version is the one that is registered. Having explained the scenario lets take a look at potential problems: 1/ Looking at permisions of objects in EM does not work. Like the rest of the current version of SQL Express this is a pre-release version, the permissions problem is a bug which we have resolved in the B2 build of SQL Server 2005. If you need to use EM before we update SQLDMO and Express, then go to the version of SQLDMO.dll thats in SQL Server 2000 directory and execute regsvr32 sqldmo.dll. This should enable EM to work as it was before against SQL Server 2000 but neither EM nor DMO will work against SQL Express in this case. 2/ Uninstalling SQL Express breaks DMO and Enterprise Manager When SQL Express installs it registers SQLDMO9 and when it uninstalls, it de-registers it, but if there was a SQLDMO (SQL2000 or SQL7) version on the machine previously this registration is not put back, leaving the machine with no SQLDMO registered. The resolution to this is the same as the above, re-register the right version of SQLDMO. paul.hartland at fsmail.net wrote: >To all, >Have just come to open my Enterprise Manager and I am getting the error as below: >Microsoft SQL-DMO >Error 126: General Error >If you click the ok button Enterprise Manager opens but it's as if all my registration properties have been lost, I tried right clicking on SQL Server Groups and New SQL Server Registration but then get another error message as below: >Server Registration Information Cannot Be Changed On Remote Registeries. >Has anyone else ever had the same problem, if so how do I go about resolving this...I have thought about re-installing my SQL Server on my machine, but thought I would see if I can get away without doing this. >Thanks in advance for any help on this. >Paul Hartland >Database Developer. >_ > > > > -- Marty Connelly Victoria, B.C. Canada From Paul.Hartland at orridge.co.uk Tue Jun 6 02:18:44 2006 From: Paul.Hartland at orridge.co.uk (Paul Hartland) Date: Tue, 6 Jun 2006 08:18:44 +0100 Subject: [dba-SQLServer] Enterprise Manager Opening, But No Objects !!!! Message-ID: <14A7AB003EFD444BBB193A23128DA20E0113A790@AL-PRI.Aldridge.local> Marty, Thanks but although I have often thought f looking at SQL Express at work I never have done.....I only have the SQL Server 2000 client installed on my machine so I don't think that will be the problem. Not to worry I will uninstall my SQL Client and re-install or try a repair. Thanks anyway.. PAUL HARTLAND Database Designer/Programmer paul.hartland at orridge.co.uk DDI - 01922 472031 Mobile - 07730 523179 -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of MartyConnelly Sent: 05 June 2006 18:08 To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Enterprise Manager Opening, But No Objects !!!! Don't know if this fixed in a final released version of SQL 2005 or Express But if you have installed either might be a conflict between SQL-DMO and SQL-SMO. Just a maybe guess .. got this from sqlexpress's WebLog on MSDN http://blogs.msdn.com/sqlexpress This is a cached version as I cant reach it just now FAQ: Installing SQL Express side by side with SQL 2000 Enterprise Manager seems to break it, its still broken when I uninstall express, whats going on? Because of changes in the SQL Server 2005 metadata we have updated SQLDMO, the new version is SQLDMO9, it should work with SQL Server 7/2000 and 2005. For backwards compatibility it is installed by SQL Express so that existing DMO apps should just work. Due to the way that SQLDMO is versioned, only one version can exist on a machine at one time, so when Express is installed the SQLDMO9 version is the one that is registered. Having explained the scenario lets take a look at potential problems: 1/ Looking at permisions of objects in EM does not work. Like the rest of the current version of SQL Express this is a pre-release version, the permissions problem is a bug which we have resolved in the B2 build of SQL Server 2005. If you need to use EM before we update SQLDMO and Express, then go to the version of SQLDMO.dll thats in SQL Server 2000 directory and execute regsvr32 sqldmo.dll. This should enable EM to work as it was before against SQL Server 2000 but neither EM nor DMO will work against SQL Express in this case. 2/ Uninstalling SQL Express breaks DMO and Enterprise Manager When SQL Express installs it registers SQLDMO9 and when it uninstalls, it de-registers it, but if there was a SQLDMO (SQL2000 or SQL7) version on the machine previously this registration is not put back, leaving the machine with no SQLDMO registered. The resolution to this is the same as the above, re-register the right version of SQLDMO. paul.hartland at fsmail.net wrote: >To all, >Have just come to open my Enterprise Manager and I am getting the error as below: >Microsoft SQL-DMO >Error 126: General Error >If you click the ok button Enterprise Manager opens but it's as if all my registration properties have been lost, I tried right clicking on SQL Server Groups and New SQL Server Registration but then get another error message as below: >Server Registration Information Cannot Be Changed On Remote Registeries. >Has anyone else ever had the same problem, if so how do I go about resolving this...I have thought about re-installing my SQL Server on my machine, but thought I would see if I can get away without doing this. >Thanks in advance for any help on this. >Paul Hartland >Database Developer. >_ > > > > -- 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 _______________________________________________ * This message is confidential. * This email, its content and any files transmitted with it are intended solely for the addressee and may be legally privileged and/or confidential. * Access by any other party is unauthorised without the express written permission of the sender. * If you have received this email in error you may not copy or use the contents, attachments or information in any way and any review, use, dissemination, forwarding, disclosure, alteration, printing of this information is strictly prohibited. Please destroy it and notify the sender via return e-mail. * This email has been prepared using information believed by Paul Hartland to be reliable and accurate, but the company makes no warranty as to accuracy or completeness. In particular the author does not accept responsibility for changes made to this email after it was sent. * Any opinions expressed in this document are those of the author and do not necessarily reflect the opinions of the company or its affiliates. The Orridge web site can be found at: http://www.orridge.co.uk From fhtapia at gmail.com Tue Jun 6 15:57:25 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 6 Jun 2006 13:57:25 -0700 Subject: [dba-SQLServer] Fun with T-Sql In-Reply-To: <0J0A0018NKZK3ZA1@l-daemon> References: <0J0A0018NKZK3ZA1@l-daemon> Message-ID: yup pretty much, but I did forget to include the SN, because they'll want to see how many parts failed on "each SN" multiple times. On 6/3/06, Jim Lawrence wrote: > So it is just a test against any a list of parts that have failed greater > than ninety days and a list of parts that have failed less than ninety days. > Does this have to have parts that have failed multiple times within ninety > days? > > Jim > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco > Tapia > Sent: Friday, June 02, 2006 3:45 PM > To: SQL Server 2k List; dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] Fun with T-Sql > > This really is a fun job, sometimes you won't find out what people > want to report on.. :D. Generally i hate to sit and write reports, as > it's always similar to one you just wrote but just enough diffrences > that it needs to be a completely new report :|. > > today I'm writing one on a part list where i need to find parts that > have failed a 2nd time within 90 days of the first failure :| > > so part a fails in 1/1/06, and fails again in 2/28/06... the 2/28 > counts, but not the initial one. likewise, if a part fails again on > 3/3/06, that counts as well because it's within 90 days of the 2/28 > fail. > > fields are > > PN, FailDate > > Initially i'm gonna dump the fields to a temp table so I can work with > a smaller subset of data. > > i think i should dump out the distinct pn list as well, i could create > a while loop to find all pn that failed within 90 days of each other > and dump out the ones that do not. so in my above example, if a part > fails again at 7/1/06, that fail no longer counts as it's > 90 days > since the last fail. > > not really expecting a reply just venting :) > > > > -- > -Francisco > http://pcthis.blogspot.com |PC news with out the jargon! > http://sqlthis.blogspot.com | Tsql and More... > _______________________________________________ > 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 > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From darrend at nimble.com.au Sun Jun 18 22:03:43 2006 From: darrend at nimble.com.au (Darren DICK) Date: Mon, 19 Jun 2006 13:03:43 +1000 Subject: [dba-SQLServer] Current Week in SQL Message-ID: <20060619030342.RTLF5695.omta02ps.mx.bigpond.com@DENZILLAP> Hi all Is there an easy way to determine the date of the Monday in the current week - Also the same for the Sunday of the current week? E.g. - Assume today is Wednesday the 3rd April I need help to determine that Monday is the 1st April 2006 and Sunday would be the 7th April Just need to work our the Monday date and Sunday date of any week we are in Make sense? Many thanks Have a great day Darren From stuart at lexacorp.com.pg Sun Jun 18 23:04:26 2006 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Mon, 19 Jun 2006 14:04:26 +1000 Subject: [dba-SQLServer] Current Week in SQL In-Reply-To: <20060619030342.RTLF5695.omta02ps.mx.bigpond.com@DENZILLAP> Message-ID: <4496AEEA.6984.1AB53E1B@stuart.lexacorp.com.pg> On 19 Jun 2006 at 13:03, Darren DICK wrote: > Hi all > > Is there an easy way to determine the date of the Monday in the > current week - Also the same for the Sunday of the current week? > > E.g. - Assume today is Wednesday the 3rd April > > I need help to determine that Monday is the 1st April 2006 and Sunday > would be the 7th April > > Just need to work our the Monday date and Sunday date of any week we > are in > Does your week start on Monday? There are different conventions for this. Assuming this is so, the following function will get Monday. Slight modifications will get you the Sunday(last day of the week = 7) and by plugging other dates in place of GetDate(), you can do it for any week. declare @date datetime set DATEFIRST 1 /* Set Monday as first day of the week */ set @date = GetDate() select convert(nvarchar(12), at date + 1 - datepart(dw, at date),6) From darrend at nimble.com.au Sun Jun 18 23:50:51 2006 From: darrend at nimble.com.au (Darren DICK) Date: Mon, 19 Jun 2006 14:50:51 +1000 Subject: [dba-SQLServer] Current Week in SQL In-Reply-To: <4496AEEA.6984.1AB53E1B@stuart.lexacorp.com.pg> Message-ID: <20060619045053.NKNX9971.omta01ps.mx.bigpond.com@DENZILLAP> Hi Stuart Brilliant - works wonderfully well Yes the dates and days are Aussie. IE format will be dd/mm/yyyy and using Monday as the start of the (working) week Ended up Using declare @date datetime set DATEFIRST 1 /* Set Monday as first day of the week */ set @date = GetDate() select convert(nvarchar(12), at date + 1 - datepart(dw, at date),6) as 'MondayThisWeek', convert(nvarchar(12), at date + 7 - datepart(dw, at date),6) as 'SundayThisWeek' Again many thanks Darren ------------------ T: 0424 696 433 -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Monday, 19 June 2006 2:04 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Current Week in SQL On 19 Jun 2006 at 13:03, Darren DICK wrote: > Hi all > > Is there an easy way to determine the date of the Monday in the > current week - Also the same for the Sunday of the current week? > > E.g. - Assume today is Wednesday the 3rd April > > I need help to determine that Monday is the 1st April 2006 and Sunday > would be the 7th April > > Just need to work our the Monday date and Sunday date of any week we > are in > Does your week start on Monday? There are different conventions for this. Assuming this is so, the following function will get Monday. Slight modifications will get you the Sunday(last day of the week = 7) and by plugging other dates in place of GetDate(), you can do it for any week. declare @date datetime set DATEFIRST 1 /* Set Monday as first day of the week */ set @date = GetDate() select convert(nvarchar(12), at date + 1 - datepart(dw, at date),6) _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From markamatte at hotmail.com Mon Jun 19 12:26:41 2006 From: markamatte at hotmail.com (Mark A Matte) Date: Mon, 19 Jun 2006 17:26:41 +0000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: <20060619030342.RTLF5695.omta02ps.mx.bigpond.com@DENZILLAP> Message-ID: Hello All, I need a little help on some SQL. I am counting and summing some stuff. This is a very large recordset(80m I think)...and I would like to do this in one pass if possible. Here is what I have: *** SELECT Cus_Customer_ID as Customer_ID, count(Hdr_Transaction_Date) as Frequency, sum(Hdr_Sale_Amount) as Monetary FROM dbo.Customers, dbo.Headers WHERE Cus_Customer_ID = Hdr_Customer_Number AND Hdr_Transaction_Date BETWEEN '06/04/2004' AND '06/03/2006' GROUP BY Cus_Customer_ID *** I need to have the 'Frequency' and 'Monetary' fields split by 12 month periods. So I would end up with 1 row for each Customer with the following Frequency12, Monetary12, Frequency24, Monetary24. Currently they use 2 passes using temp tables to get this and then join the temps. What would be the fastest way of getting this in a single SQL statement ( and the syntax)? Thanks, Mark A. Matte From rl_stewart at highstream.net Mon Jun 19 13:53:48 2006 From: rl_stewart at highstream.net (Robert L. Stewart) Date: Mon, 19 Jun 2006 14:53:48 -0400 Subject: [dba-SQLServer] dba-SQLServer Digest, Vol 40, Issue 7 In-Reply-To: References: Message-ID: <1150743228.4496f2bcbaebd@webmail.highstream.net> Darren, I have a dimension table for date functions that I use. It stores abut 200 years worth of dates. It has each date broken down as completely as I can think of. The only thing that would need to change about it for your use would be the fact that in the US, Sunday is the first day of the week, not the last. Robert L. Stewart The Dyson Group International Software for the Non-profit Enterprise Expanding your Sphere of Knowledge Quoting dba-sqlserver-request at databaseadvisors.com: > Date: Mon, 19 Jun 2006 13:03:43 +1000 > From: "Darren DICK" > Subject: [dba-SQLServer] Current Week in SQL > To: > Message-ID: > <20060619030342.RTLF5695.omta02ps.mx.bigpond.com at DENZILLAP> > Content-Type: text/plain; charset="us-ascii" > > Hi all > > Is there an easy way to determine the date of the Monday in the current week > - > Also the same for the Sunday of the current week? > > E.g. - Assume today is Wednesday the 3rd April > > I need help to determine that Monday is the 1st April 2006 and Sunday would > be > the 7th April > > Just need to work our the Monday date and Sunday date of any week we are in > > Make sense? > > Many thanks > > Have a great day > > Darren From stuart at lexacorp.com.pg Mon Jun 19 16:32:55 2006 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Tue, 20 Jun 2006 07:32:55 +1000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: References: <20060619030342.RTLF5695.omta02ps.mx.bigpond.com@DENZILLAP>, Message-ID: <4497A4A7.14724.20CECCD5@stuart.lexacorp.com.pg> First thing that strikes me is, why include dboCustomers, looks like you are only using Customer_ID and this is in dboHeaders as Customer_Number. Don't know about fastest but one approach would be something like Declare @EndDate DateTime Set @EndDate - '06/03/2006' Select Distinct Hdr_Customer_Number, sum ( Case Hdr_Transaction_Date When > @Date - 365 Then 1 Else 0 End) as Frequency12, sum (Case Hdr_Transaction_Date When > @Date - 365 Then Hdr_Sale_Amount Else 0 End ) as Monetary12, Count(*) as Frequency24, Sum(Hdr_Sales_Amount*) as Monetary24 Where Hdr_Transaction_Date > @Date - 730 GROUP BY Cus_Customer_ID On 19 Jun 2006 at 17:26, Mark A Matte wrote: > Hello All, > > I need a little help on some SQL. I am counting and summing some stuff. > This is a very large recordset(80m I think)...and I would like to do this in > one pass if possible. Here is what I have: *** SELECT Cus_Customer_ID as > Customer_ID, > count(Hdr_Transaction_Date) as Frequency, > sum(Hdr_Sale_Amount) as Monetary > FROM dbo.Customers, dbo.Headers > WHERE Cus_Customer_ID = Hdr_Customer_Number AND > Hdr_Transaction_Date BETWEEN '06/04/2004' AND '06/03/2006' > GROUP BY Cus_Customer_ID > *** > > I need to have the 'Frequency' and 'Monetary' fields split by 12 month > periods. So I would end up with 1 row for each Customer with the following > Frequency12, Monetary12, Frequency24, Monetary24. Currently they use 2 > passes using temp tables to get this and then join the temps. What would be > the fastest way of getting this in a single SQL statement ( and the syntax)? > -- Stuart From darrend at nimble.com.au Mon Jun 19 20:27:56 2006 From: darrend at nimble.com.au (Darren DICK) Date: Tue, 20 Jun 2006 11:27:56 +1000 Subject: [dba-SQLServer] dba-SQLServer Digest, Vol 40, Issue 7 In-Reply-To: <1150743228.4496f2bcbaebd@webmail.highstream.net> Message-ID: <20060620012756.RZYR9971.omta01ps.mx.bigpond.com@DENZILLAP> Hi Robert I'd love to see it if you're keen to chare :-)) Many thanks Darren ------------------ T: 0424 696 433 -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Robert L. Stewart Sent: Tuesday, 20 June 2006 4:54 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] dba-SQLServer Digest, Vol 40, Issue 7 Darren, I have a dimension table for date functions that I use. It stores abut 200 years worth of dates. It has each date broken down as completely as I can think of. The only thing that would need to change about it for your use would be the fact that in the US, Sunday is the first day of the week, not the last. Robert L. Stewart The Dyson Group International Software for the Non-profit Enterprise Expanding your Sphere of Knowledge Quoting dba-sqlserver-request at databaseadvisors.com: > Date: Mon, 19 Jun 2006 13:03:43 +1000 > From: "Darren DICK" > Subject: [dba-SQLServer] Current Week in SQL > To: > Message-ID: > <20060619030342.RTLF5695.omta02ps.mx.bigpond.com at DENZILLAP> > Content-Type: text/plain; charset="us-ascii" > > Hi all > > Is there an easy way to determine the date of the Monday in the current week > - > Also the same for the Sunday of the current week? > > E.g. - Assume today is Wednesday the 3rd April > > I need help to determine that Monday is the 1st April 2006 and Sunday would > be > the 7th April > > Just need to work our the Monday date and Sunday date of any week we are in > > Make sense? > > Many thanks > > Have a great day > > Darren _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From markamatte at hotmail.com Tue Jun 20 09:26:11 2006 From: markamatte at hotmail.com (Mark A Matte) Date: Tue, 20 Jun 2006 14:26:11 +0000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: <4497A4A7.14724.20CECCD5@stuart.lexacorp.com.pg> Message-ID: Thanks Stuart, This is exactly what I need. I stripped down the original query to give this example. Both tables are used in the original query. In your opinion...if you had to get this type of info from 80 mil+ recordset...as far as speed goes...would you go multiple passes into temp tables and join later, or case statements? Thanks, Mark A. Matte >From: "Stuart McLachlan" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] If or Case or 'what'? >Date: Tue, 20 Jun 2006 07:32:55 +1000 > >First thing that strikes me is, why include dboCustomers, looks like you >are only using Customer_ID and this is in dboHeaders as Customer_Number. > >Don't know about fastest but one approach would be something like > >Declare @EndDate DateTime >Set @EndDate - '06/03/2006' > >Select Distinct Hdr_Customer_Number, >sum ( Case Hdr_Transaction_Date > When > @Date - 365 Then 1 > Else 0 > End) as Frequency12, > >sum (Case Hdr_Transaction_Date > When > @Date - 365 Then Hdr_Sale_Amount > Else 0 > End ) as Monetary12, > >Count(*) as Frequency24, >Sum(Hdr_Sales_Amount*) as Monetary24 > >Where Hdr_Transaction_Date > @Date - 730 >GROUP BY Cus_Customer_ID > >On 19 Jun 2006 at 17:26, Mark A Matte wrote: > > > Hello All, > > > > I need a little help on some SQL. I am counting and summing some stuff. > > This is a very large recordset(80m I think)...and I would like to do >this in > > one pass if possible. Here is what I have: *** SELECT Cus_Customer_ID >as > > Customer_ID, > > count(Hdr_Transaction_Date) as Frequency, > > sum(Hdr_Sale_Amount) as Monetary > > FROM dbo.Customers, dbo.Headers > > WHERE Cus_Customer_ID = Hdr_Customer_Number AND > > Hdr_Transaction_Date BETWEEN '06/04/2004' AND '06/03/2006' > > GROUP BY Cus_Customer_ID > > *** > > > > I need to have the 'Frequency' and 'Monetary' fields split by 12 month > > periods. So I would end up with 1 row for each Customer with the >following > > Frequency12, Monetary12, Frequency24, Monetary24. Currently they use 2 > > passes using temp tables to get this and then join the temps. What >would be > > the fastest way of getting this in a single SQL statement ( and the >syntax)? > > >-- >Stuart > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > From Patricia.O'Connor at otda.state.ny.us Tue Jun 20 09:49:46 2006 From: Patricia.O'Connor at otda.state.ny.us (O'Connor, Patricia (OTDA)) Date: Tue, 20 Jun 2006 10:49:46 -0400 Subject: [dba-SQLServer] Training and books References: <20060619030342.RTLF5695.omta02ps.mx.bigpond.com@DENZILLAP>, <4497A4A7.14724.20CECCD5@stuart.lexacorp.com.pg> Message-ID: <01DBAB52E30A9A4AB3D94EF8029EDBE838CA42@EXCNYSM0A1AI.nysemail.nyenet> We will be getting Sql Server in our office soon. I am going to have to upgrade some access backends to this. I may also have to link to an ORACLE backend. Someone wants to extract data from the Oracle and create a table on the Sql. I have used ORACLE and SYBASE along with MS Access but I have not used MS SQL Server. I would like to know what books are good to help learn and use. That would give me good tips and reference. We are also looking to training so any suggestions would be greatly appreciated. Thanks ************************************************************* * Patricia E. O'Connor * Associate Computer Programmer/Analyst * OTDA - BDMA * (W) mailto:Patricia.O'Connor at otda.state.ny.us * (W) mailto:aa1160 at otda.state.ny.us *********************************************************** -------------------------------------------------------- This e-mail, including any attachments, may be confidential, privileged or otherwise legally protected. It is intended only for the addressee. If you received this e-mail in error or from someone who was not authorized to send it to you, do not disseminate, copy or otherwise use this e-mail or its attachments. Please notify the sender immediately by reply e-mail and delete the e-mail from your system. From stuart at lexacorp.com.pg Tue Jun 20 10:23:06 2006 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 21 Jun 2006 01:23:06 +1000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: References: <4497A4A7.14724.20CECCD5@stuart.lexacorp.com.pg>, Message-ID: <44989F7A.13629.24A28E37@stuart.lexacorp.com.pg> On 20 Jun 2006 at 14:26, Mark A Matte wrote: > Thanks Stuart, > > This is exactly what I need. I stripped down the original query to give > this example. Both tables are used in the original query. > > In your opinion...if you had to get this type of info from 80 mil+ > recordset...as far as speed goes...would you go multiple passes into temp > tables and join later, or case statements? > Hard to tell, but I suspect in this situation that the single pass would prove quicker. Why not try both ways and report back :-) -- Stuart From markamatte at hotmail.com Tue Jun 20 11:13:41 2006 From: markamatte at hotmail.com (Mark A Matte) Date: Tue, 20 Jun 2006 16:13:41 +0000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: <44989F7A.13629.24A28E37@stuart.lexacorp.com.pg> Message-ID: I will... The guy I'm helping with this...just shared exactly what he is trying to do...so the next question is...is there a limit to the number of cases you can have in a single statement? ...or is there a better approach to what we are doing? We have a table with all of the data created below(my first email)...then he wants to populate a category field with 1 of about 30 values...depending on the data in the records. Then there is another field treated the same way...another 30 Cases. Is there a limit? and... Case should be the way to go...right? Thanks, Mark >From: "Stuart McLachlan" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] If or Case or 'what'? >Date: Wed, 21 Jun 2006 01:23:06 +1000 > >On 20 Jun 2006 at 14:26, Mark A Matte wrote: > > > Thanks Stuart, > > > > This is exactly what I need. I stripped down the original query to give > > this example. Both tables are used in the original query. > > > > In your opinion...if you had to get this type of info from 80 mil+ > > recordset...as far as speed goes...would you go multiple passes into >temp > > tables and join later, or case statements? > > > >Hard to tell, but I suspect in this situation that the single pass would >prove quicker. Why not try both ways and report back :-) >-- >Stuart > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > From stuart at lexacorp.com.pg Tue Jun 20 12:19:22 2006 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 21 Jun 2006 03:19:22 +1000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: References: <44989F7A.13629.24A28E37@stuart.lexacorp.com.pg>, Message-ID: <4498BABA.5809.250CFE24@stuart.lexacorp.com.pg> On 20 Jun 2006 at 16:13, Mark A Matte wrote: > The guy I'm helping with this...just shared exactly what he is trying to > do...so the next question is...is there a limit to the number of cases you > can have in a single statement? > Not as far as I know. > ...or is there a better approach to what we are doing? We have a table with > all of the data created below(my first email)...then he wants to populate a > category field with 1 of about 30 values...depending on the data in the > records. Then there is another field treated the same way...another 30 > Cases. Is there a limit? and... Case should be the way to go...right? > It may be better to do this using a series of set based updates, particularly if some of the fields you are basing the category on are indexed since SQL Server will be able to optimize the record selection. Update myTable set CategoryA = 1 where........... Update myTable set CategoryA = 2 where........... ... Update myTable set CategoryB = 1 where........... Update myTable set CategoryB = 2 where........... ... -- Stuart From markamatte at hotmail.com Tue Jun 20 13:03:38 2006 From: markamatte at hotmail.com (Mark A Matte) Date: Tue, 20 Jun 2006 18:03:38 +0000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: <4498BABA.5809.250CFE24@stuart.lexacorp.com.pg> Message-ID: Thanks Again Stuart, In this usage...what are the differences/advantages of using CASE vs IF? Thanks, Mark A. Matte >From: "Stuart McLachlan" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] If or Case or 'what'? >Date: Wed, 21 Jun 2006 03:19:22 +1000 > >On 20 Jun 2006 at 16:13, Mark A Matte wrote: > > > The guy I'm helping with this...just shared exactly what he is trying to > > do...so the next question is...is there a limit to the number of cases >you > > can have in a single statement? > > >Not as far as I know. > > > ...or is there a better approach to what we are doing? We have a table >with > > all of the data created below(my first email)...then he wants to >populate a > > category field with 1 of about 30 values...depending on the data in the > > records. Then there is another field treated the same way...another 30 > > Cases. Is there a limit? and... Case should be the way to go...right? > > > >It may be better to do this using a series of set based updates, >particularly if some of the fields you are basing the category on are >indexed since SQL Server will be able to optimize the record selection. > >Update myTable set CategoryA = 1 where........... >Update myTable set CategoryA = 2 where........... >... >Update myTable set CategoryB = 1 where........... >Update myTable set CategoryB = 2 where........... >... > >-- >Stuart > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > From stuart at lexacorp.com.pg Tue Jun 20 17:13:44 2006 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 21 Jun 2006 08:13:44 +1000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: References: <4498BABA.5809.250CFE24@stuart.lexacorp.com.pg>, Message-ID: <4498FFB8.32109.261A80A6@stuart.lexacorp.com.pg> On 20 Jun 2006 at 18:03, Mark A Matte wrote: > Thanks Again Stuart, > > In this usage...what are the differences/advantages of using CASE vs IF? Same as VB/VBA. Once a case situation is matched, execution drops through to the "End" With a string of simple "IF"s, every conditional has to be evaulated. On average, you will only have to evaluate half as many When"s as you will "If"s. By putting the most likely case(s) first, you can dramatically speed up execution of "Case" constructs. Using If.. Else... has the same overhead as Case, but 30 Cases is a llot cleaner to code than 30 nested Ifs :-) -- Stuart From rl_stewart at highstream.net Wed Jun 21 12:17:23 2006 From: rl_stewart at highstream.net (Robert L. Stewart) Date: Wed, 21 Jun 2006 13:17:23 -0400 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: References: Message-ID: <1150910243.44997f235879f@webmail.highstream.net> Actually, the best solution would be to generate 2 lookup tables and link them to the first one based on the key in the fields you are trying to do the case for. It will be much faster, and easier to maintain later. Robert L. Stewart The Dyson Group International Software for the Non-profit Enterprise Expanding your Sphere of Knowledge Quoting dba-sqlserver-request at databaseadvisors.com: > Date: Wed, 21 Jun 2006 03:19:22 +1000 > From: "Stuart McLachlan" > Subject: Re: [dba-SQLServer] If or Case or 'what'? > To: dba-sqlserver at databaseadvisors.com > Message-ID: <4498BABA.5809.250CFE24 at stuart.lexacorp.com.pg> > Content-Type: text/plain; charset=US-ASCII > > On 20 Jun 2006 at 16:13, Mark A Matte wrote: > > > The guy I'm helping with this...just shared exactly what he is trying to > > do...so the next question is...is there a limit to the number of cases you > > can have in a single statement? > > > Not as far as I know. > > > ...or is there a better approach to what we are doing? We have a table > with > > all of the data created below(my first email)...then he wants to populate a > > category field with 1 of about 30 values...depending on the data in the > > records. Then there is another field treated the same way...another 30 > > Cases. Is there a limit? and... Case should be the way to go...right? > > > > It may be better to do this using a series of set based updates, > particularly if some of the fields you are basing the category on are > indexed since SQL Server will be able to optimize the record selection. > > Update myTable set CategoryA = 1 where........... > Update myTable set CategoryA = 2 where........... > ... > Update myTable set CategoryB = 1 where........... > Update myTable set CategoryB = 2 where........... > ... > > -- > Stuart From stuart at lexacorp.com.pg Wed Jun 21 16:08:44 2006 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Thu, 22 Jun 2006 07:08:44 +1000 Subject: [dba-SQLServer] If or Case or 'what'? In-Reply-To: <1150910243.44997f235879f@webmail.highstream.net> References: , <1150910243.44997f235879f@webmail.highstream.net> Message-ID: <449A41FC.2014.2B054F97@stuart.lexacorp.com.pg> On 21 Jun 2006 at 13:17, Robert L. Stewart wrote: > Actually, the best solution would be to generate 2 lookup tables and link > them to the first one based on the key in the fields you are trying to do > the case for. It will be much faster, and easier to maintain later. > As I understand the question, that's what he will be doing. The question is how best to generate the keys in the two fields for 80 million existing records since these keys depend on the vallues in varisou other fields. I've never worked with that big a table, my largest has been about 8 million. Maybe JC has some advise since he was doing a lot of work on a similar sized one a yar or two ago. One reason that I suggested breaking it down into a series of set based updates is that transactional locking for 80 million records on a single pass update query will create a massive overhead. It is likely to be a lot quicker overall to run 30 queries where the row count for each update is reduced by a factor of 20 to 30. -- Stuart From markamatte at hotmail.com Thu Jun 22 09:21:39 2006 From: markamatte at hotmail.com (Mark A Matte) Date: Thu, 22 Jun 2006 14:21:39 +0000 Subject: [dba-SQLServer] If or Case or 'what'? Message-ID: Thanks for all of the advice. After looking at all possibilities, we have combine/modified and came up with 3 approaches. Case statements, series of updates, and lookup tables. I think he is going to start with a combination of the case and the updates. With all of the index changes he made...this should speed it up tremendously. He only uses this about 6 times a year...so the first approach that works in a reasonable amount of time...will end the testing. Thanks again, Mark A. Matte >From: "Stuart McLachlan" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] If or Case or 'what'? >Date: Thu, 22 Jun 2006 07:08:44 +1000 > >On 21 Jun 2006 at 13:17, Robert L. Stewart wrote: > > > Actually, the best solution would be to generate 2 lookup tables and >link > > them to the first one based on the key in the fields you are trying to >do > > the case for. It will be much faster, and easier to maintain later. > > > >As I understand the question, that's what he will be doing. The question is >how best to generate the keys in the two fields for 80 million existing >records since these keys depend on the vallues in varisou other fields. > >I've never worked with that big a table, my largest has been about 8 >million. Maybe JC has some advise since he was doing a lot of work on a >similar sized one a yar or two ago. > >One reason that I suggested breaking it down into a series of set based >updates is that transactional locking for 80 million records on a single >pass update query will create a massive overhead. It is likely to be a lot >quicker overall to run 30 queries where the row count for each update is >reduced by a factor of 20 to 30. > > > >-- >Stuart > > >_______________________________________________ >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 Tue Jun 27 04:48:56 2006 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Tue, 27 Jun 2006 11:48:56 +0200 (CEST) Subject: [dba-SQLServer] SQL Tables No Longer Used Message-ID: <25071157.1151401736678.JavaMail.www@wwinf3002> To all, I have cross posted this just in case anyone else knows of anything, I don't know if this sort of software will be available...I have a SQL Database with a VB6 front-end that the company has decided it's time we totally re-design, now this database has been passed down twice so there are tables in it etc that are no longer used. Is there a piece of software that can run through a SQL database and/or VB6 code that will tell me which tables/queries/views/store procedures are no longer used. If not does anyone have a good strategy plan if they have done this before, this is a big database and I can't see a simple solution to totally re-designing it to also incorporate the existing data. Thanks in advance for any help on this . Paul Hartland From bhorn at pivot-mds.com Wed Jun 28 11:38:04 2006 From: bhorn at pivot-mds.com (Bruce Horn) Date: Wed, 28 Jun 2006 12:38:04 -0400 Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer version Message-ID: <7.0.1.0.0.20060628123756.02074798@pivot-mds.com> Hello List - Can a fully-licensed SQL Server 2000 be installed over an XP Developer version without impacting existing databases? We have two databases in the XP Developer version of SQL Server 2000 and we are going to upgrade to a full license version on the same box (Windows Server 2003). Any information greatly appreciated. Regards, - Bruce ********************************** Bruce T. Horn CIO/CTO Pivot MDS, Llc. Ph: 401-586-6422 www.pivot-mds.com www.pivotsalestrack.com ********************************** From paul.hartland at fsmail.net Wed Jun 28 11:34:37 2006 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Wed, 28 Jun 2006 18:34:37 +0200 (CEST) Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer version Message-ID: <31425839.1151512477956.JavaMail.www@wwinf3204.me-wanadoo.net> I'm not totally sure, but I would back up your existing databases, install the new version then restore them personnaly. Message Received: Jun 28 2006, 05:32 PM From: "Bruce Horn" To: dba-sqlserver at databaseadvisors.com Cc: Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer version Hello List - Can a fully-licensed SQL Server 2000 be installed over an XP Developer version without impacting existing databases? We have two databases in the XP Developer version of SQL Server 2000 and we are going to upgrade to a full license version on the same box (Windows Server 2003). Any information greatly appreciated. Regards, - Bruce ********************************** Bruce T. Horn CIO/CTO Pivot MDS, Llc. Ph: 401-586-6422 www.pivot-mds.com www.pivotsalestrack.com ********************************** _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fhtapia at gmail.com Wed Jun 28 11:50:42 2006 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 28 Jun 2006 09:50:42 -0700 Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer version In-Reply-To: <7.0.1.0.0.20060628123756.02074798@pivot-mds.com> References: <7.0.1.0.0.20060628123756.02074798@pivot-mds.com> Message-ID: I don't think I've ever done it this way... One thing I recommend is backup all your databases. It should be a seamless process tho. On 6/28/06, Bruce Horn wrote: > Hello List - > > Can a fully-licensed SQL Server 2000 be installed over an XP > Developer version without impacting existing databases? > We have two databases in the XP Developer version of SQL Server 2000 > and we are going to upgrade to a full license version on the same box > (Windows Server 2003). > > Any information greatly appreciated. > > Regards, > - Bruce > > > ********************************** > Bruce T. Horn CIO/CTO > Pivot MDS, Llc. > Ph: 401-586-6422 > www.pivot-mds.com > www.pivotsalestrack.com > ********************************** > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com |PC news with out the jargon! http://sqlthis.blogspot.com | Tsql and More... From rl_stewart at highstream.net Wed Jun 28 12:31:08 2006 From: rl_stewart at highstream.net (Robert L. Stewart) Date: Wed, 28 Jun 2006 13:31:08 -0400 Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer In-Reply-To: References: Message-ID: <1151515868.44a2bcdc96158@webmail.highstream.net> Bruce, Detach the databases and move them to a different directory. Uninstall the developer version. Install the full version. Move the databases to where you want them to be. Re-attach them. Just to get it straight, there is not an XP Developer version of SQL Server. There are SQL 2000 and 2005 Developer versions which have all the features of the enterprise version except for the number of users. Robert L. Stewart The Dyson Group International Software for the Non-profit Enterprise Expanding your Sphere of Knowledge Quoting dba-sqlserver-request at databaseadvisors.com: > Date: Wed, 28 Jun 2006 12:38:04 -0400 > From: Bruce Horn > Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer > version > To: dba-sqlserver at databaseadvisors.com > Message-ID: <7.0.1.0.0.20060628123756.02074798 at pivot-mds.com> > Content-Type: text/plain; charset="us-ascii"; format=flowed > > Hello List - > > Can a fully-licensed SQL Server 2000 be installed over an XP > Developer version without impacting existing databases? > We have two databases in the XP Developer version of SQL Server 2000 > and we are going to upgrade to a full license version on the same box > (Windows Server 2003). > > Any information greatly appreciated. > > Regards, > - Bruce From bhorn at pivot-mds.com Wed Jun 28 13:02:03 2006 From: bhorn at pivot-mds.com (Bruce Horn) Date: Wed, 28 Jun 2006 14:02:03 -0400 Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer version Message-ID: <7.0.1.0.0.20060628135154.01de3238@pivot-mds.com> Hi List - I was hoping it might be that straightforward. Easier only if I just had to enter the new license number. Thanks for the responses. Regards, - Bruce From tuxedoman888 at gmail.com Wed Jun 28 15:25:47 2006 From: tuxedoman888 at gmail.com (Billy Pang) Date: Wed, 28 Jun 2006 13:25:47 -0700 Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer version In-Reply-To: <31425839.1151512477956.JavaMail.www@wwinf3204.me-wanadoo.net> References: <31425839.1151512477956.JavaMail.www@wwinf3204.me-wanadoo.net> Message-ID: <7c8826480606281325u5eb89fddh1dab3b814487ed9c@mail.gmail.com> do you mean perform a clean install of a full license version (ie. have the full license version co-exist with the existing installation of developer edition) or uprade the developer edition to full license? i've installed multiple instances of sql server on same machine so they can co-exist; i've done dev-dev configuration but never mixed developer with production database before though. in any case, as many have pointed out, back up your database first before proceeding. On 6/28/06, paul.hartland at fsmail.net wrote: > > I'm not totally sure, but I would back up your existing databases, install > the new version then restore them personnaly. > > > > > > Message Received: Jun 28 2006, 05:32 PM > From: "Bruce Horn" > To: dba-sqlserver at databaseadvisors.com > Cc: > Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Developer > version > > Hello List - > > Can a fully-licensed SQL Server 2000 be installed over an XP > Developer version without impacting existing databases? > We have two databases in the XP Developer version of SQL Server 2000 > and we are going to upgrade to a full license version on the same box > (Windows Server 2003). > > Any information greatly appreciated. > > Regards, > - Bruce > > > ********************************** > Bruce T. Horn CIO/CTO > Pivot MDS, Llc. > Ph: 401-586-6422 > www.pivot-mds.com > www.pivotsalestrack.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 bhorn at pivot-mds.com Thu Jun 29 12:54:55 2006 From: bhorn at pivot-mds.com (Bruce Horn) Date: Thu, 29 Jun 2006 13:54:55 -0400 Subject: [dba-SQLServer] Installing SQL Server 2000 over XP Message-ID: <7.0.1.0.0.20060629134820.01e56a60@pivot-mds.com> Hello List - Bill Pang's response raised another issue for me. Is it possible to upgrade the existing developer edition (thanks for the clarification Robert) to the standard edition without removing and re-installing? It is intended that we only have the/a single installation of SQL Server on this hardware. TIA - Bruce From chizotz at mchsi.com Thu Jun 29 14:57:54 2006 From: chizotz at mchsi.com (Ron Allen) Date: Thu, 29 Jun 2006 19:57:54 +0000 Subject: [dba-SQLServer] formatting smalldatetime textbox (somewhat OT) Message-ID: <062920061957.29179.44A430C2000C23EF000071FB219791299503010CD2079C080C03BF969B019607080C@mchsi.com> Sorry, I know this is a bit OT since I thing the meat of the problem is in C#, but... I have a smalldatetime field bound to a textbox in a C# WinForms project. The entire datetime displays in the textbox, i.e. 01/01/2007 12:00:00 AM I just want to display 01/01/2007 I can use Convert(varchar, my_date, 101) in the selection for the dataset the control is bound to, but that -- apparently -- makes updating the date field impossible. Calling update on the data adapter updates all other fields, but not the date field. I've tried manually altering the update SQL in the data adapter to convert the @my_date field back to smalldatetime, i.e. SET my_date = Convert (smalldatetime, @my_date), but that does not work either. There are several seemingly good solutions on the web, but I can't get them to work either, and several of them seem like overkill for something that "should" be fairly easy. Am I just having a bad day, or is this really that big of a deal? What am I missing? Any assistance or pointers to assistance appreciated. Ron From mikedorism at verizon.net Fri Jun 30 07:24:54 2006 From: mikedorism at verizon.net (Mike & Doris Manning) Date: Fri, 30 Jun 2006 08:24:54 -0400 Subject: [dba-SQLServer] formatting smalldatetime textbox (somewhat OT) In-Reply-To: <062920061957.29179.44A430C2000C23EF000071FB219791299503010CD2079C080C03BF969B019607080C@mchsi.com> Message-ID: <000001c69c40$328d2a30$2f01a8c0@dorismanning> The easiest solution would be to make sure the stored procedure includes a reference to both the original date field and the converted date. Bind the textbox to the converted date. In your Update stored procedure, put the update parameter on the original date field and not the converted one. In your code just before you call the data adapter update, add an Update parameter to pass the value of the textbox to the associated Update parameter. Doris Manning mikedorism at verizon.net From chizotz at mchsi.com Fri Jun 30 11:23:50 2006 From: chizotz at mchsi.com (Ron Allen) Date: Fri, 30 Jun 2006 16:23:50 +0000 Subject: [dba-SQLServer] formatting smalldatetime textbox (somewhat OT) Message-ID: <063020061623.21960.44A5501600001CEA000055C8219791336303010CD2079C080C03BF969B019607080C@mchsi.com> Hi Doris, Thanks. I'll keep playing with this today. I think I tried something similar yesterday and couldn't get it to work, but chances are I was just having an attack of brain gas :) Ron > The easiest solution would be to make sure the stored procedure includes a > reference to both the original date field and the converted date. > > Bind the textbox to the converted date. > > In your Update stored procedure, put the update parameter on the original > date field and not the converted one. > > In your code just before you call the data adapter update, add an Update > parameter to pass the value of the textbox to the associated Update > parameter. > > Doris Manning > mikedorism at verizon.net > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com >