From fuller.artful at gmail.com Tue Sep 2 09:25:49 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 2 Sep 2008 11:25:49 -0300 Subject: [dba-SQLServer] Reporting Services Question Message-ID: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com> I'm building a report whose data set is based on a parameterized stored procedure. The params are @CategoryID and @SubCategoryID. I have opened the Report Parameters screen and changed both parameters to combo boxes and specified the value field and label field. Ok fine. Only problem is I'm getting repeated values in the Preview mode, rather than a unique list of all categories. When I open the toolbox, at the top it says Datasets. This implies that I could add two more datasets to the report, and use them as the dataset for the combo boxes. But after a couple of hours of poking around, I cannot find out how to add another dataset. If you can only have one, why does the toolbox label say Datasets? Anybody know if it's possible, and if so how to do it? Or some other way of populating my combo box parameters? TIA, Arthur From James at fcidms.com Tue Sep 2 10:03:33 2008 From: James at fcidms.com (James Barash) Date: Tue, 2 Sep 2008 11:03:33 -0400 Subject: [dba-SQLServer] Reporting Services Question In-Reply-To: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com> Message-ID: <02e401c90d0d$11edc1a0$680101c0@fci.local> Arthur: Are you using Visual Studio to create the report? If so, you should see three tabs in the Report Designer: Data, Layout and Preview. If you open the Data tab, you should see a combo box for Dataset. If you dropdown the combo box, you will see an option for . Use that to create a dataset for unique Categories and then you can point your Parameters combo box at the new dataset. Hope that helps. James Barash -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Tuesday, September 02, 2008 10:26 AM To: Discussion concerning MS SQL Server Cc: Joe Michel Subject: [dba-SQLServer] Reporting Services Question I'm building a report whose data set is based on a parameterized stored procedure. The params are @CategoryID and @SubCategoryID. I have opened the Report Parameters screen and changed both parameters to combo boxes and specified the value field and label field. Ok fine. Only problem is I'm getting repeated values in the Preview mode, rather than a unique list of all categories. When I open the toolbox, at the top it says Datasets. This implies that I could add two more datasets to the report, and use them as the dataset for the combo boxes. But after a couple of hours of poking around, I cannot find out how to add another dataset. If you can only have one, why does the toolbox label say Datasets? Anybody know if it's possible, and if so how to do it? Or some other way of populating my combo box parameters? TIA, Arthur _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fuller.artful at gmail.com Tue Sep 2 11:35:16 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 2 Sep 2008 13:35:16 -0300 Subject: [dba-SQLServer] Reporting Services Question In-Reply-To: <02e401c90d0d$11edc1a0$680101c0@fci.local> References: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com> <02e401c90d0d$11edc1a0$680101c0@fci.local> Message-ID: <29f585dd0809020935y518fc9f7ud8dd723587006cae@mail.gmail.com> Thanks. Now I have another question. I did finally stumble upon it, and now I have the opposite problem. How do I delete a dataset? TIA, Arthur On Tue, Sep 2, 2008 at 12:03 PM, James Barash wrote: > Arthur: > > Are you using Visual Studio to create the report? If so, you should see > three tabs in the Report Designer: Data, Layout and Preview. If you open > the > Data tab, you should see a combo box for Dataset. If you dropdown the combo > box, you will see an option for . Use that to create a dataset > for unique Categories and then you can point your Parameters combo box at > the new dataset. > > Hope that helps. > > James Barash > > > From nancy.lytle at gmail.com Tue Sep 2 11:55:07 2008 From: nancy.lytle at gmail.com (Nancy Lytle) Date: Tue, 2 Sep 2008 11:55:07 -0500 Subject: [dba-SQLServer] Reporting Services Question In-Reply-To: <29f585dd0809020935y518fc9f7ud8dd723587006cae@mail.gmail.com> References: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com> <02e401c90d0d$11edc1a0$680101c0@fci.local> <29f585dd0809020935y518fc9f7ud8dd723587006cae@mail.gmail.com> Message-ID: Select it in that same dataset combo box in the Data tab (visual studio) and hit the delete button next to it.Nancy Lytle N_Lytle at terpalum.umd.edu EMAILING FOR THE GREATER GOODJoin me > Date: Tue, 2 Sep 2008 13:35:16 -0300> From: fuller.artful at gmail.com> To: dba-sqlserver at databaseadvisors.com> Subject: Re: [dba-SQLServer] Reporting Services Question> > Thanks. Now I have another question. I did finally stumble upon it, and now> I have the opposite problem. How do I delete a dataset?> > TIA,> Arthur> > On Tue, Sep 2, 2008 at 12:03 PM, James Barash wrote:> > > Arthur:> >> > Are you using Visual Studio to create the report? If so, you should see> > three tabs in the Report Designer: Data, Layout and Preview. If you open> > the> > Data tab, you should see a combo box for Dataset. If you dropdown the combo> > box, you will see an option for . Use that to create a dataset> > for unique Categories and then you can point your Parameters combo box at> > the new dataset.> >> > Hope that helps.> >> > James Barash> >> >> >> _______________________________________________> 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 Tue Sep 2 22:01:28 2008 From: kens.programming at verizon.net (KensProgramming) Date: Tue, 02 Sep 2008 20:01:28 -0700 Subject: [dba-SQLServer] Inserting Images into SS2K In-Reply-To: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com> References: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com> Message-ID: <002c01c90d71$5d3db340$6401a8c0@Stoker.com> I have a client who has a table that contains the paths to images for records. However, this client has now decided that they want to have these images stored internally in SQL Server. I have a table then that is set up to store these images, but I don't know how to go from the table with the paths listed to the table with these images stored internally. I have googled and looked through BOL, but haven't been able to find anything that appears to help me. I could just be slow and blind. I could really use anyone's help and actually need something to help me get started asap. Thanks Ken Business Analyst From stuart at lexacorp.com.pg Tue Sep 2 22:21:31 2008 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 03 Sep 2008 13:21:31 +1000 Subject: [dba-SQLServer] Inserting Images into SS2K In-Reply-To: <002c01c90d71$5d3db340$6401a8c0@Stoker.com> References: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com>, <002c01c90d71$5d3db340$6401a8c0@Stoker.com> Message-ID: <48BE02BB.11245.72188C4E@stuart.lexacorp.com.pg> Here's an old reference to using BLOBs in Access: http://support.microsoft.com/default.aspx?scid=kb;en-us;103257 The VBA functions to read/write disk files to/from OLE Object fields given should work just the same with an ODBC connection to SQLServer with an image (long binary) data field. -- Stuart On 2 Sep 2008 at 20:01, KensProgramming wrote: > > > I have a client who has a table that contains the paths to images for > records. However, this client has now decided that they want to have these > images stored internally in SQL Server. I have a table then that is set up > to store these images, but I don't know how to go from the table with the > paths listed to the table with these images stored internally. I have > googled and looked through BOL, but haven't been able to find anything that > appears to help me. I could just be slow and blind. I could really use > anyone's help and actually need something to help me get started asap. > > Thanks > > Ken > Business Analyst > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > -- Stuart Mclachlan From dbdoug at gmail.com Tue Sep 2 22:52:47 2008 From: dbdoug at gmail.com (Doug Steele) Date: Tue, 2 Sep 2008 20:52:47 -0700 Subject: [dba-SQLServer] Inserting Images into SS2K In-Reply-To: <002c01c90d71$5d3db340$6401a8c0@Stoker.com> References: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com> <002c01c90d71$5d3db340$6401a8c0@Stoker.com> Message-ID: <4dd71a0c0809022052h6529abfl9332ba087bb538d7@mail.gmail.com> Would this be of any help?: http://www.motobit.com/tips/detpg_read-write-sql-image-file/ Doug Steele On Tue, Sep 2, 2008 at 8:01 PM, KensProgramming < kens.programming at verizon.net> wrote: > > > I have a client who has a table that contains the paths to images for > records. However, this client has now decided that they want to have these > images stored internally in SQL Server. I have a table then that is set up > to store these images, but I don't know how to go from the table with the > paths listed to the table with these images stored internally. I have > googled and looked through BOL, but haven't been able to find anything that > appears to help me. I could just be slow and blind. I could really use > anyone's help and actually need something to help me get started asap. > > Thanks > > Ken > Business Analyst > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jlawrenc1 at shaw.ca Thu Sep 4 02:32:34 2008 From: jlawrenc1 at shaw.ca (Jim Lawrence) Date: Thu, 4 Sep 2008 00:32:34 -0700 Subject: [dba-SQLServer] Inserting Images into SS2K In-Reply-To: <48BE02BB.11245.72188C4E@stuart.lexacorp.com.pg> References: <29f585dd0809020725o62c18fc0j46a1c2f358805c8e@mail.gmail.com> <002c01c90d71$5d3db340$6401a8c0@Stoker.com> <48BE02BB.11245.72188C4E@stuart.lexacorp.com.pg> Message-ID: <9360992A144B429AB92331377C52296B@creativesystemdesigns.com> Hi Stuart and Ken: The 'chunk' method is actually an older algorithm of copying images to and from a SQL DB. The new a much faster method is to use ADO streaming: http://www.freevbcode.com/ShowCode.Asp?ID=1802 HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Tuesday, September 02, 2008 8:22 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Inserting Images into SS2K Here's an old reference to using BLOBs in Access: http://support.microsoft.com/default.aspx?scid=kb;en-us;103257 The VBA functions to read/write disk files to/from OLE Object fields given should work just the same with an ODBC connection to SQLServer with an image (long binary) data field. -- Stuart On 2 Sep 2008 at 20:01, KensProgramming wrote: > > > I have a client who has a table that contains the paths to images for > records. However, this client has now decided that they want to have these > images stored internally in SQL Server. I have a table then that is set up > to store these images, but I don't know how to go from the table with the > paths listed to the table with these images stored internally. I have > googled and looked through BOL, but haven't been able to find anything that > appears to help me. I could just be slow and blind. I could really use > anyone's help and actually need something to help me get started asap. > > Thanks > > Ken > Business Analyst > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > -- Stuart Mclachlan _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From ssharkins at gmail.com Wed Sep 10 14:33:59 2008 From: ssharkins at gmail.com (Susan Harkins) Date: Wed, 10 Sep 2008 15:33:59 -0400 Subject: [dba-SQLServer] full transaction logs Message-ID: <0a0b01c9137c$42ebec80$2f8601c7@SusanOne> Are full transaction logs still a problem in 2005 and 2008? I'm just wondering if they've done anything automatic to warn the administrator or to avoid the problem altogether. Susan H. From fuller.artful at gmail.com Wed Sep 10 14:59:17 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Wed, 10 Sep 2008 16:59:17 -0300 Subject: [dba-SQLServer] Very strange behavior Message-ID: <29f585dd0809101259w710b3cfehd2d80cce6c7c22a2@mail.gmail.com> The following code declares a cursor and then generates one SQL statement per table in the current database, placing the statement into the cursor. We then walk the cursor and either print or execute each statement. Run the code as is against any database. In this example I'm using Northwind: -- Build Cursor of UPDATE STATISTICS Statements DECLARE Statement_Cursor CURSOR FOR SELECT CHAR(39) + 'UPDATE STATISTICS ' + SCHEMA_NAME() + '.' + sysobjects.NAME + CHAR(39) FROM sysobjects WHERE TYPE = 'U' OPEN Statement_Cursor FETCH NEXT FROM Statement_Cursor INTO @statement WHILE @@FETCH_STATUS = 0 BEGIN -- SET @statement = CHAR(39)+ at statement+CHAR(39) -- This is the test statement to ensure that it works print @statement -- This is the production statement that will take a long time -- EXEC (@statement) FETCH NEXT FROM Statement_Cursor INTO @statement END CLOSE Statement_Cursor DEALLOCATE Statement_Cursor -- example: /* USE NorthwindCS DECLARE @sql VARCHAR(255) SET @sql = 'UPDATE STATISTICS dbo.Employees' --print @sql EXEC (@sql) */ To repeat my experiments, do this: 1. Run the code as is. It will print out lovely SQL statements. 2. Uncomment the EXEC(@statement) line and run the code again. You will get a bunch of errors. 3. Select the code within the example and run it. The code works and you get a nice message. The string being passed to the EXEC in the example is identical to those produced in the main code. Why it works in one case and not the other baffles me. Got any ideas? I think this can be a cool and useful chunk of code once I figure a way out of this problem. I have had my colleague Matthew look at it and he too is baffled. So we need a third and maybe fourth and maybe fifth set of eyes. TIA, Arthur From fuller.artful at gmail.com Wed Sep 10 15:31:47 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Wed, 10 Sep 2008 17:31:47 -0300 Subject: [dba-SQLServer] full transaction logs In-Reply-To: <0a0b01c9137c$42ebec80$2f8601c7@SusanOne> References: <0a0b01c9137c$42ebec80$2f8601c7@SusanOne> Message-ID: <29f585dd0809101331i34eeba39nfd12c2eae8c6ac74@mail.gmail.com> I know that some people have received a message that their transaction log is full, but I personally never have. I don't know what I'm doing right. Recently we changed our strategy on transaction logs. Now we back up the log (only the log) four times a day and nightly do a dbcc shrinkfile, so the living log is peanuts compared to what it used to be. Before I got here there was a nightly process that dropped a table and then recreated it and did thousands of inserts. As a result, the log file was huge -- way larger than the 18 gig db itself. We changed that process dramatically and the log file shrank dramatically too. Arthur On Wed, Sep 10, 2008 at 4:33 PM, Susan Harkins wrote: > Are full transaction logs still a problem in 2005 and 2008? I'm just > wondering if they've done anything automatic to warn the administrator or > to > avoid the problem altogether. > > Susan H. > From James at fcidms.com Wed Sep 10 15:42:53 2008 From: James at fcidms.com (James Barash) Date: Wed, 10 Sep 2008 16:42:53 -0400 Subject: [dba-SQLServer] Very strange behavior In-Reply-To: <29f585dd0809101259w710b3cfehd2d80cce6c7c22a2@mail.gmail.com> Message-ID: <010c01c91385$cca4cba0$680101c0@fci.local> Arthur: I think the problem is with the CHAR(39) that you wrap the Update in. I tried running it without those and it run file except for tables that have a space in the tablename. I modified it to: DECLARE Statement_Cursor CURSOR FOR SELECT 'UPDATE STATISTICS [' + SCHEMA_NAME() + '].[' + sysobjects.NAME + ']' FROM sysobjects WHERE TYPE = 'U' However, there is an easier way to accomplish this: EXEC sp_MSForeachtable 'UPDATE STATISTICS ?' This uses an undocumented stored procedure in the Master database. It works in SQL Server 2000/2005 at least. I don't know about other versions. Hope this helps. James Barash -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Wednesday, September 10, 2008 3:59 PM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] Very strange behavior The following code declares a cursor and then generates one SQL statement per table in the current database, placing the statement into the cursor. We then walk the cursor and either print or execute each statement. Run the code as is against any database. In this example I'm using Northwind: -- Build Cursor of UPDATE STATISTICS Statements DECLARE Statement_Cursor CURSOR FOR SELECT CHAR(39) + 'UPDATE STATISTICS ' + SCHEMA_NAME() + '.' + sysobjects.NAME + CHAR(39) FROM sysobjects WHERE TYPE = 'U' OPEN Statement_Cursor FETCH NEXT FROM Statement_Cursor INTO @statement WHILE @@FETCH_STATUS = 0 BEGIN -- SET @statement = CHAR(39)+ at statement+CHAR(39) -- This is the test statement to ensure that it works print @statement -- This is the production statement that will take a long time -- EXEC (@statement) FETCH NEXT FROM Statement_Cursor INTO @statement END CLOSE Statement_Cursor DEALLOCATE Statement_Cursor -- example: /* USE NorthwindCS DECLARE @sql VARCHAR(255) SET @sql = 'UPDATE STATISTICS dbo.Employees' --print @sql EXEC (@sql) */ To repeat my experiments, do this: 1. Run the code as is. It will print out lovely SQL statements. 2. Uncomment the EXEC(@statement) line and run the code again. You will get a bunch of errors. 3. Select the code within the example and run it. The code works and you get a nice message. The string being passed to the EXEC in the example is identical to those produced in the main code. Why it works in one case and not the other baffles me. Got any ideas? I think this can be a cool and useful chunk of code once I figure a way out of this problem. I have had my colleague Matthew look at it and he too is baffled. So we need a third and maybe fourth and maybe fifth set of eyes. TIA, Arthur _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From mwp.reid at qub.ac.uk Wed Sep 10 15:45:00 2008 From: mwp.reid at qub.ac.uk (Martin Reid) Date: Wed, 10 Sep 2008 21:45:00 +0100 Subject: [dba-SQLServer] OT Arthur Message-ID: Hey Arthur Got your card. Looks lovely and wish I was there. Great to see you having fun Martin Martin WP Reid Information Services Queen's University Riddel Hall 185 Stranmillis Road Belfast BT9 5EE Tel : 02890974465 Email : mwp.reid at qub.ac.uk ________________________________________ From ab-mi at post3.tele.dk Wed Sep 10 17:17:57 2008 From: ab-mi at post3.tele.dk (Asger Blond) Date: Thu, 11 Sep 2008 00:17:57 +0200 Subject: [dba-SQLServer] full transaction logs In-Reply-To: <29f585dd0809101331i34eeba39nfd12c2eae8c6ac74@mail.gmail.com> Message-ID: <000301c91393$14ca91f0$2401a8c0@AB> Hi Susan and Arthur, The transaction is only truncated if you: 1. Set the database to SIMPLE RECOVERY MODEL. This recovery model equals the obsolete command SET TRUNCATE ON CHECKPOINT ON, meaning that the log is automatically truncated when a checkpoint is performed (normally every 1 minute). However, setting the database to SIMPLE RECOVERY MODEL will not allow you to make backups of the transaction log - so this is not a reasonable choice for an OLTP-database. OR: 2. Perform a manual truncation of the log issuing the command BACKUP LOG WITH TRUNCATE_ONLY. This command should only be used as an emergency if the database log for some reason is bloating. OR: 3. Perform a log-backup at regular intervals. Notice that only a log-backup will truncate the log, a full or differential backup won't. Of these options I normally would prefer the last for an OLTP-database. If I'm not wrong this may be an answer to Arthur's statement: "I don't know what I'm doing right." Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arthur Fuller Sendt: 10. september 2008 22:32 Til: Discussion concerning MS SQL Server Emne: Re: [dba-SQLServer] full transaction logs I know that some people have received a message that their transaction log is full, but I personally never have. I don't know what I'm doing right. Recently we changed our strategy on transaction logs. Now we back up the log (only the log) four times a day and nightly do a dbcc shrinkfile, so the living log is peanuts compared to what it used to be. Before I got here there was a nightly process that dropped a table and then recreated it and did thousands of inserts. As a result, the log file was huge -- way larger than the 18 gig db itself. We changed that process dramatically and the log file shrank dramatically too. Arthur On Wed, Sep 10, 2008 at 4:33 PM, Susan Harkins wrote: > Are full transaction logs still a problem in 2005 and 2008? I'm just > wondering if they've done anything automatic to warn the administrator or > to > avoid the problem altogether. > > Susan H. > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From ssharkins at gmail.com Wed Sep 10 17:39:52 2008 From: ssharkins at gmail.com (Susan Harkins) Date: Wed, 10 Sep 2008 18:39:52 -0400 Subject: [dba-SQLServer] full transaction logs References: <000301c91393$14ca91f0$2401a8c0@AB> Message-ID: <004901c91396$26adb430$2f8601c7@SusanOne> If I'm not wrong this may be an answer to Arthur's statement: "I don't know what I'm doing right." ======Well, redesigning that huge transaction certainly helps too. Susan H. From ab-mi at post3.tele.dk Wed Sep 10 18:09:08 2008 From: ab-mi at post3.tele.dk (Asger Blond) Date: Thu, 11 Sep 2008 01:09:08 +0200 Subject: [dba-SQLServer] full transaction logs In-Reply-To: <000301c91393$14ca91f0$2401a8c0@AB> Message-ID: <000401c9139a$3a813f50$2401a8c0@AB> Just a second comment for Arthur: You wrote: "Now we back up the log (only the log) four times a day and nightly do a dbcc shrinkfile" To my mind a DBCC SHRINKFILE is an emergency command which should NOT be included in an automated administrative task. DBCC SHRINKFILE will free truncated file-space to the operating system. This may be a reasonable action if the log-file has been bloating. Otherwise it certainly is not: freeing truncated file-space to the operation system will force SQL Server to allocate new file-space for the log as needed, and this will be a great invitation for file fragmentation at the disk level. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger Blond Sendt: 11. september 2008 00:18 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] full transaction logs Hi Susan and Arthur, The transaction is only truncated if you: 1. Set the database to SIMPLE RECOVERY MODEL. This recovery model equals the obsolete command SET TRUNCATE ON CHECKPOINT ON, meaning that the log is automatically truncated when a checkpoint is performed (normally every 1 minute). However, setting the database to SIMPLE RECOVERY MODEL will not allow you to make backups of the transaction log - so this is not a reasonable choice for an OLTP-database. OR: 2. Perform a manual truncation of the log issuing the command BACKUP LOG WITH TRUNCATE_ONLY. This command should only be used as an emergency if the database log for some reason is bloating. OR: 3. Perform a log-backup at regular intervals. Notice that only a log-backup will truncate the log, a full or differential backup won't. Of these options I normally would prefer the last for an OLTP-database. If I'm not wrong this may be an answer to Arthur's statement: "I don't know what I'm doing right." Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arthur Fuller Sendt: 10. september 2008 22:32 Til: Discussion concerning MS SQL Server Emne: Re: [dba-SQLServer] full transaction logs I know that some people have received a message that their transaction log is full, but I personally never have. I don't know what I'm doing right. Recently we changed our strategy on transaction logs. Now we back up the log (only the log) four times a day and nightly do a dbcc shrinkfile, so the living log is peanuts compared to what it used to be. Before I got here there was a nightly process that dropped a table and then recreated it and did thousands of inserts. As a result, the log file was huge -- way larger than the 18 gig db itself. We changed that process dramatically and the log file shrank dramatically too. Arthur On Wed, Sep 10, 2008 at 4:33 PM, Susan Harkins wrote: > Are full transaction logs still a problem in 2005 and 2008? I'm just > wondering if they've done anything automatic to warn the administrator or > to > avoid the problem altogether. > > Susan H. > _______________________________________________ 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 fuller.artful at gmail.com Wed Sep 10 23:14:43 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Thu, 11 Sep 2008 01:14:43 -0300 Subject: [dba-SQLServer] Very strange behavior In-Reply-To: <010c01c91385$cca4cba0$680101c0@fci.local> References: <29f585dd0809101259w710b3cfehd2d80cce6c7c22a2@mail.gmail.com> <010c01c91385$cca4cba0$680101c0@fci.local> Message-ID: <29f585dd0809102114u25ff1991xd9ec9723c4f6482f@mail.gmail.com> In the simple case of Northwind you are correct, but try it against Adventureworks and you will see the problem. Try running these statements: EXEC sp_MSForeachtable ('ALTER INDEX ALL ON ' + schema_name() + '.' ? + 'REBUILD WITH ( PAD_INDEX = OFF, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON )') EXEC sp_MSForeachtable ('ALTER INDEX ALL ON ? REBUILD WITH ( PAD_INDEX = OFF, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON )') From fuller.artful at gmail.com Thu Sep 11 04:50:06 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Thu, 11 Sep 2008 06:50:06 -0300 Subject: [dba-SQLServer] full transaction logs In-Reply-To: <000401c9139a$3a813f50$2401a8c0@AB> References: <000301c91393$14ca91f0$2401a8c0@AB> <000401c9139a$3a813f50$2401a8c0@AB> Message-ID: <29f585dd0809110250o363275d7md50c31d07b4c54a1@mail.gmail.com> Thanks for that, Asger. I will bring it up at our next meeting (I'm the new guy on this team so the decision won't necessarily be in my hands, but on the other hand I am respected for having resources like this group at my fingertips). Thanks, Arthur On Wed, Sep 10, 2008 at 8:09 PM, Asger Blond wrote: > Just a second comment for Arthur: > > You wrote: "Now we back up the log (only the log) four times a day and > nightly do a dbcc shrinkfile" > > To my mind a DBCC SHRINKFILE is an emergency command which should NOT be > included in an automated administrative task. > > DBCC SHRINKFILE will free truncated file-space to the operating system. > This > may be a reasonable action if the log-file has been bloating. Otherwise it > certainly is not: freeing truncated file-space to the operation system will > force SQL Server to allocate new file-space for the log as needed, and this > will be a great invitation for file fragmentation at the disk level. > > Asger > From fuller.artful at gmail.com Thu Sep 11 11:48:00 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Thu, 11 Sep 2008 13:48:00 -0300 Subject: [dba-SQLServer] Question about Error Logs Message-ID: <29f585dd0809110948p7aa9ee85k6eae7784607c6e24@mail.gmail.com> I don't understand how the SQL error logs work. The last error log I have is dated 8/21/2008. Does the database engine create an error log only when there is an error or a warning? I had assumed that it would create one every day, even if only to post a message that there were no errors, but maybe that assumption is self-contradictory. Arthur From paul.hartland at googlemail.com Fri Sep 12 02:25:51 2008 From: paul.hartland at googlemail.com (Paul Hartland) Date: Fri, 12 Sep 2008 08:25:51 +0100 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer Message-ID: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> To all, Over the last two days we have been losing personnel off our main database, and have had to retrieve them from one of my many backups. However I can't seem to see why or where this is happening in my application (VB6)...Does anybody know how to view the LDF files, so that I can see each transaction as it takes place, or if there is something I can do when a record is deleted from tblPersonnel, or if I can turn on some sort of monitoring system ? Thanks in advance for any help on this. -- Paul Hartland paul.hartland at googlemail.com From fuller.artful at gmail.com Fri Sep 12 07:00:06 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Fri, 12 Sep 2008 09:00:06 -0300 Subject: [dba-SQLServer] Very strange behavior In-Reply-To: <010c01c91385$cca4cba0$680101c0@fci.local> References: <29f585dd0809101259w710b3cfehd2d80cce6c7c22a2@mail.gmail.com> <010c01c91385$cca4cba0$680101c0@fci.local> Message-ID: <29f585dd0809120500o69512264r85f5e4a8eb91c3c7@mail.gmail.com> In the simple case of Northwind you are correct, but try it against Adventureworks and you will see the problem. Try running these statements: EXEC sp_MSForeachtable ('ALTER INDEX ALL ON ' + schema_name() + '.' ? + 'REBUILD WITH ( PAD_INDEX = OFF, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON )') EXEC sp_MSForeachtable ('ALTER INDEX ALL ON ? REBUILD WITH ( PAD_INDEX = OFF, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON )') The apparent failure of sp_MSForEachTable to handle these variations on the statement is what motivated me to look beyond sp_MSForEachTable. A. On Wed, Sep 10, 2008 at 5:42 PM, James Barash wrote: > Arthur: > > I think the problem is with the CHAR(39) that you wrap the Update in. I > tried running it without those and it run file except for tables that have > a > space in the tablename. I modified it to: > > DECLARE Statement_Cursor CURSOR > FOR SELECT > 'UPDATE STATISTICS [' + SCHEMA_NAME() + '].[' + sysobjects.NAME + ']' > > FROM > sysobjects > WHERE > TYPE = 'U' > > However, there is an easier way to accomplish this: > > EXEC sp_MSForeachtable 'UPDATE STATISTICS ?' > > From fhtapia at gmail.com Fri Sep 12 09:39:07 2008 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 12 Sep 2008 07:39:07 -0700 Subject: [dba-SQLServer] Very strange behavior In-Reply-To: <29f585dd0809102114u25ff1991xd9ec9723c4f6482f@mail.gmail.com> References: <29f585dd0809101259w710b3cfehd2d80cce6c7c22a2@mail.gmail.com> <010c01c91385$cca4cba0$680101c0@fci.local> <29f585dd0809102114u25ff1991xd9ec9723c4f6482f@mail.gmail.com> Message-ID: Arthur... I have built my defrag indexes scripts for Sql 2005 following this model... that I wrote up on my blog http://sqlthis.blogspot.com/2005/04/defrag-those-indexes-maintenance.html the initial simply finds the fragmented indexes... I have a much more complete script that I can post later today, but here is the basic portion on the defrag section... in where I simply defrag... SET NOCOUNT ON DECLARE @TableName AS VARCHAR(500), @TableOwner AS VARCHAR(500), @Rows AS BIGINT, @aAvg AS DECIMAL(10,3), @SQL AS VARCHAR (1000) WHILE EXISTS(SELECT * FROM db_defrag) BEGIN SELECT TOP 1 @TableOwner = TableOwner, @TableName = TableName --TableName, AVG(avg_fragmentation_in_percent)aAvg, AVG(ROWS) aRows, , at Rows = AVG(ROWS), @aAvg = AVG([avg_fragmentation_in_percent]) FROM db_defrag GROUP BY TableOwner, TableName ORDER BY AVG(ROWS) DESC SET @SQL = 'BEGIN TRY ' + 'ALTER INDEX ALL ON ' + @TableOwner + '.[' + @TableName + '] REBUILD WITH(MAXDOP=2, ONLINE=ON)' + ' END TRY ' + + ' BEGIN CATCH ' + 'ALTER INDEX ALL ON ' + @TableOwner + '.[' + @TableName + '] REBUILD WITH(MAXDOP=2, ONLINE=OFF)' + ' END CATCH ' IF GETDATE() < '5/4/08 23:59'--CONVERT(VARCHAR(12), GETDATE(), 110) + ' 22:00' BEGIN PRINT 'Defragging TABLE ' + @TableName EXECUTE(@SQL) PRINT 'Clearing from db_defrag table' DELETE FROM db_defrag WHERE TableName = @TableName INSERT INTO db_defrag_complete(TableOwner, TableName, ROWS) VALUES(@TableOwner, @TableName, @Rows) SET @SQL = 'UPDATE STATISTICS ' + @TableOwner + '.' + @TableName EXEC(@SQL) END ELSE BEGIN PRINT 'Skipping TABLE ' + @TableName DELETE FROM db_defrag WHERE TableName = @TableName INSERT INTO db_defrag_skipped(TableOwner, TableName, ROWS, [avg_fragmentation_in_percent]) VALUES(@TableOwner, @TableName, @Rows, @aAvg) END END -Francisco http://sqlthis.blogspot.com | Tsql and More... On Wed, Sep 10, 2008 at 9:14 PM, Arthur Fuller wrote: > In the simple case of Northwind you are correct, but try it against > Adventureworks and you will see the problem. Try running these statements: > > > EXEC > sp_MSForeachtable ('ALTER INDEX ALL ON ' + schema_name() + '.' ? + 'REBUILD > WITH ( PAD_INDEX = OFF, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON > )') > > EXEC > sp_MSForeachtable ('ALTER INDEX ALL ON ? REBUILD WITH ( PAD_INDEX = OFF, > SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON )') > _______________________________________________ > 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 Fri Sep 12 09:44:36 2008 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 12 Sep 2008 07:44:36 -0700 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer In-Reply-To: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> References: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> Message-ID: One method to ensure you block what is happening.... you can run profiler and monitor for just the tblPersonnel, there are also products out there I think there is one by quest software that will allow you to view the transaction long (you can download the demo and review). Along with profiler you can also add some security simply lock down the security to prevent deletes in this table. hopefully your app uses a uid that is not the sa or administrative account. once that occurs you can deterime once and for all if it is your app (or if it's someone else) hth -Francisco http://sqlthis.blogspot.com | Tsql and More... On Fri, Sep 12, 2008 at 12:25 AM, Paul Hartland < paul.hartland at googlemail.com> wrote: > To all, > > Over the last two days we have been losing personnel off our main database, > and have had to retrieve them from one of my many backups. However I can't > seem to see why or where this is happening in my application (VB6)...Does > anybody know how to view the LDF files, so that I can see each transaction > as it takes place, or if there is something I can do when a record is > deleted from tblPersonnel, or if I can turn on some sort of monitoring > system ? > > Thanks in advance for any help on this. > > -- > Paul Hartland > paul.hartland at googlemail.com > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fuller.artful at gmail.com Fri Sep 12 11:09:16 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Fri, 12 Sep 2008 13:09:16 -0300 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer In-Reply-To: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> References: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> Message-ID: <29f585dd0809120909q5ffb5eal8359c20fbd2bc6c0@mail.gmail.com> Visit www.apexsql.com and download an eval copy of Apex SQL Log. It costs $2000 with a year of support and updates, or $1499 alone. That's a lot of money but I can see that it could save my bacon. Arthur On Fri, Sep 12, 2008 at 4:25 AM, Paul Hartland wrote: > To all, > > Over the last two days we have been losing personnel off our main database, > and have had to retrieve them from one of my many backups. However I can't > seem to see why or where this is happening in my application (VB6)...Does > anybody know how to view the LDF files, so that I can see each transaction > as it takes place, or if there is something I can do when a record is > deleted from tblPersonnel, or if I can turn on some sort of monitoring > system ? > > Thanks in advance for any help on this. > > -- > Paul Hartland > paul.hartland at googlemail.com > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From ab-mi at post3.tele.dk Fri Sep 12 16:59:28 2008 From: ab-mi at post3.tele.dk (Asger Blond) Date: Fri, 12 Sep 2008 23:59:28 +0200 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer In-Reply-To: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> Message-ID: <000001c91522$d43d2c60$2401a8c0@AB> For this I would create an audittable and a FOR DELETE TRIGGER. Suppose your tblPersonnel has columns like PersonnelID, FirstName, and LastName. You want to audit the record deleted plus the time of the event, and the user performing the deletion: CREATE TABLE AuditDelete (PersonnelID int, FirstName varchar(30), LastName varchar (30), Deletion varchar(100) DEFAULT CONVERT(varchar(50), GETDATE()) + '. By: ' + SUSER_SNAME()) GO CREATE TRIGGER tr_tblPersonnel_Delete ON tblPersonnel FOR DELETE AS INSERT INTO AuditTable (PersonnelID, FirstName, LastName) SELECT PersonnelID, FirstName, LastName FROM deleted GO Using a delete-trigger your can also cancel the event issuing a rollback. Suppose you want to prevent deletion of multiple rows in the personnel table, you could create the trigger like this: CREATE TRIGGER tr_tblPersonnel_Delete ON tblPersonnel FOR DELETE AS IF (SELECT COUNT(*) FROM deleted) > 1 BEGIN RAISERROR ('Deletion of multiple records not permitted!',16,1) ROLLBACK TRANSACTION END ELSE INSERT INTO AuditTable (PersonnelID, FirstName, LastName) SELECT PersonnelID, FirstName, LastName FROM deleted GO Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Paul Hartland Sendt: 12. september 2008 09:26 Til: Access List; SQLServerList Emne: [dba-SQLServer] SQL Server 2005 LDF Viewer To all, Over the last two days we have been losing personnel off our main database, and have had to retrieve them from one of my many backups. However I can't seem to see why or where this is happening in my application (VB6)...Does anybody know how to view the LDF files, so that I can see each transaction as it takes place, or if there is something I can do when a record is deleted from tblPersonnel, or if I can turn on some sort of monitoring system ? Thanks in advance for any help on this. -- Paul Hartland paul.hartland at googlemail.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fuller.artful at gmail.com Fri Sep 12 17:00:13 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Fri, 12 Sep 2008 19:00:13 -0300 Subject: [dba-SQLServer] Very strange behavior In-Reply-To: References: <29f585dd0809101259w710b3cfehd2d80cce6c7c22a2@mail.gmail.com> <010c01c91385$cca4cba0$680101c0@fci.local> <29f585dd0809102114u25ff1991xd9ec9723c4f6482f@mail.gmail.com> Message-ID: <29f585dd0809121500r1b5db6d5lb7de7841d3b96aaa@mail.gmail.com> Thanks Francisco. I assume the tables mentioned are user tables? On Fri, Sep 12, 2008 at 11:39 AM, Francisco Tapia wrote: > Arthur... I have built my defrag indexes scripts for Sql 2005 following > this > model... that I wrote up on my blog > http://sqlthis.blogspot.com/2005/04/defrag-those-indexes-maintenance.html > > the initial simply finds the fragmented indexes... I have a much more > complete script that I can post later today, but here is the basic portion > on the defrag section... in where I simply defrag... > > > > SET NOCOUNT ON > > DECLARE @TableName AS VARCHAR(500), > @TableOwner AS VARCHAR(500), > @Rows AS BIGINT, > @aAvg AS DECIMAL(10,3), > @SQL AS VARCHAR (1000) > > WHILE EXISTS(SELECT * FROM db_defrag) > BEGIN > SELECT TOP 1 > @TableOwner = TableOwner, > @TableName = TableName --TableName, > AVG(avg_fragmentation_in_percent)aAvg, AVG(ROWS) aRows, > , at Rows = AVG(ROWS), @aAvg = AVG([avg_fragmentation_in_percent]) > FROM db_defrag > GROUP BY TableOwner, TableName > ORDER BY AVG(ROWS) DESC > > SET @SQL = 'BEGIN TRY ' + > 'ALTER INDEX ALL ON ' + @TableOwner + '.[' + @TableName + '] REBUILD > WITH(MAXDOP=2, ONLINE=ON)' > + ' END TRY ' + > + ' BEGIN CATCH ' > + 'ALTER INDEX ALL ON ' + @TableOwner + '.[' + @TableName + '] REBUILD > WITH(MAXDOP=2, ONLINE=OFF)' > + ' END CATCH ' > > IF GETDATE() < '5/4/08 23:59'--CONVERT(VARCHAR(12), GETDATE(), 110) + > ' 22:00' > BEGIN > PRINT 'Defragging TABLE ' + @TableName > EXECUTE(@SQL) > PRINT 'Clearing from db_defrag table' > DELETE FROM db_defrag WHERE TableName = @TableName > INSERT INTO db_defrag_complete(TableOwner, TableName, ROWS) > VALUES(@TableOwner, @TableName, @Rows) > SET @SQL = 'UPDATE STATISTICS ' + @TableOwner + '.' + @TableName > EXEC(@SQL) > END > ELSE > BEGIN > PRINT 'Skipping TABLE ' + @TableName > DELETE FROM db_defrag WHERE TableName = @TableName > INSERT INTO db_defrag_skipped(TableOwner, TableName, ROWS, > [avg_fragmentation_in_percent]) VALUES(@TableOwner, @TableName, @Rows, > @aAvg) > END > > END > > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Wed, Sep 10, 2008 at 9:14 PM, Arthur Fuller >wrote: > > > In the simple case of Northwind you are correct, but try it against > > Adventureworks and you will see the problem. Try running these > statements: > > > > > > EXEC > > sp_MSForeachtable ('ALTER INDEX ALL ON ' + schema_name() + '.' ? + > 'REBUILD > > WITH ( PAD_INDEX = OFF, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON > > )') > > > > EXEC > > sp_MSForeachtable ('ALTER INDEX ALL ON ? REBUILD WITH ( PAD_INDEX = OFF, > > SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON )') > > _______________________________________________ > > 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 fhtapia at gmail.com Fri Sep 12 17:03:32 2008 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 12 Sep 2008 15:03:32 -0700 Subject: [dba-SQLServer] Very strange behavior In-Reply-To: <29f585dd0809121500r1b5db6d5lb7de7841d3b96aaa@mail.gmail.com> References: <29f585dd0809101259w710b3cfehd2d80cce6c7c22a2@mail.gmail.com> <010c01c91385$cca4cba0$680101c0@fci.local> <29f585dd0809102114u25ff1991xd9ec9723c4f6482f@mail.gmail.com> <29f585dd0809121500r1b5db6d5lb7de7841d3b96aaa@mail.gmail.com> Message-ID: yes, user tables... -Francisco http://sqlthis.blogspot.com | Tsql and More... On Fri, Sep 12, 2008 at 3:00 PM, Arthur Fuller wrote: > Thanks Francisco. I assume the tables mentioned are user tables? > > On Fri, Sep 12, 2008 at 11:39 AM, Francisco Tapia > wrote: > > > Arthur... I have built my defrag indexes scripts for Sql 2005 following > > this > > model... that I wrote up on my blog > > > http://sqlthis.blogspot.com/2005/04/defrag-those-indexes-maintenance.html > > > > the initial simply finds the fragmented indexes... I have a much more > > complete script that I can post later today, but here is the basic > portion > > on the defrag section... in where I simply defrag... > > > > > > > > SET NOCOUNT ON > > > > DECLARE @TableName AS VARCHAR(500), > > @TableOwner AS VARCHAR(500), > > @Rows AS BIGINT, > > @aAvg AS DECIMAL(10,3), > > @SQL AS VARCHAR (1000) > > > > WHILE EXISTS(SELECT * FROM db_defrag) > > BEGIN > > SELECT TOP 1 > > @TableOwner = TableOwner, > > @TableName = TableName --TableName, > > AVG(avg_fragmentation_in_percent)aAvg, AVG(ROWS) aRows, > > , at Rows = AVG(ROWS), @aAvg = AVG([avg_fragmentation_in_percent]) > > FROM db_defrag > > GROUP BY TableOwner, TableName > > ORDER BY AVG(ROWS) DESC > > > > SET @SQL = 'BEGIN TRY ' + > > 'ALTER INDEX ALL ON ' + @TableOwner + '.[' + @TableName + '] REBUILD > > WITH(MAXDOP=2, ONLINE=ON)' > > + ' END TRY ' + > > + ' BEGIN CATCH ' > > + 'ALTER INDEX ALL ON ' + @TableOwner + '.[' + @TableName + '] REBUILD > > WITH(MAXDOP=2, ONLINE=OFF)' > > + ' END CATCH ' > > > > IF GETDATE() < '5/4/08 23:59'--CONVERT(VARCHAR(12), GETDATE(), 110) + > > ' 22:00' > > BEGIN > > PRINT 'Defragging TABLE ' + @TableName > > EXECUTE(@SQL) > > PRINT 'Clearing from db_defrag table' > > DELETE FROM db_defrag WHERE TableName = @TableName > > INSERT INTO db_defrag_complete(TableOwner, TableName, ROWS) > > VALUES(@TableOwner, @TableName, @Rows) > > SET @SQL = 'UPDATE STATISTICS ' + @TableOwner + '.' + @TableName > > EXEC(@SQL) > > END > > ELSE > > BEGIN > > PRINT 'Skipping TABLE ' + @TableName > > DELETE FROM db_defrag WHERE TableName = @TableName > > INSERT INTO db_defrag_skipped(TableOwner, TableName, ROWS, > > [avg_fragmentation_in_percent]) VALUES(@TableOwner, @TableName, @Rows, > > @aAvg) > > END > > > > END > > > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Wed, Sep 10, 2008 at 9:14 PM, Arthur Fuller > >wrote: > > > > > In the simple case of Northwind you are correct, but try it against > > > Adventureworks and you will see the problem. Try running these > > statements: > > > > > > > > > EXEC > > > sp_MSForeachtable ('ALTER INDEX ALL ON ' + schema_name() + '.' ? + > > 'REBUILD > > > WITH ( PAD_INDEX = OFF, SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = > ON > > > )') > > > > > > EXEC > > > sp_MSForeachtable ('ALTER INDEX ALL ON ? REBUILD WITH ( PAD_INDEX = > OFF, > > > SORT_IN_TEMPDB = ON, STATISTICS_NORECOMPUTE = ON )') > > > _______________________________________________ > > > 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 fuller.artful at gmail.com Fri Sep 12 17:29:52 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Fri, 12 Sep 2008 19:29:52 -0300 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer In-Reply-To: <000001c91522$d43d2c60$2401a8c0@AB> References: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> <000001c91522$d43d2c60$2401a8c0@AB> Message-ID: <29f585dd0809121529g30572cddk2fd313e07217b331@mail.gmail.com> That's certainly a solution for this specific problem, but I still think there's a business case for a transaction log reader. A. On Fri, Sep 12, 2008 at 6:59 PM, Asger Blond wrote: > For this I would create an audittable and a FOR DELETE TRIGGER. From ab-mi at post3.tele.dk Fri Sep 12 17:56:16 2008 From: ab-mi at post3.tele.dk (Asger Blond) Date: Sat, 13 Sep 2008 00:56:16 +0200 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer In-Reply-To: <29f585dd0809121529g30572cddk2fd313e07217b331@mail.gmail.com> Message-ID: <000101c9152a$c3361140$2401a8c0@AB> Agree. Always wondered why MS hasn't supplied that. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arthur Fuller Sendt: 13. september 2008 00:30 Til: Discussion concerning MS SQL Server Emne: Re: [dba-SQLServer] SQL Server 2005 LDF Viewer That's certainly a solution for this specific problem, but I still think there's a business case for a transaction log reader. A. On Fri, Sep 12, 2008 at 6:59 PM, Asger Blond wrote: > For this I would create an audittable and a FOR DELETE TRIGGER. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fuller.artful at gmail.com Fri Sep 12 18:36:45 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Fri, 12 Sep 2008 20:36:45 -0300 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer In-Reply-To: <000101c9152a$c3361140$2401a8c0@AB> References: <29f585dd0809121529g30572cddk2fd313e07217b331@mail.gmail.com> <000101c9152a$c3361140$2401a8c0@AB> Message-ID: <29f585dd0809121636l633daeb0h75fa61de14f08f31@mail.gmail.com> IMO: it's more fun and less expensive for MS to let the 3rd party community develop solutions and then reverse engineer them and roll them into a future version and thus bankrupt the 3rd party (unless the 3rd party expects this and is working on future solutions). Case in point, Lumigent. A. On Fri, Sep 12, 2008 at 7:56 PM, Asger Blond wrote: > Agree. Always wondered why MS hasn't supplied that. > > Asger > From fhtapia at gmail.com Fri Sep 12 23:37:39 2008 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 12 Sep 2008 21:37:39 -0700 Subject: [dba-SQLServer] full transaction logs In-Reply-To: <000401c9139a$3a813f50$2401a8c0@AB> References: <000301c91393$14ca91f0$2401a8c0@AB> <000401c9139a$3a813f50$2401a8c0@AB> Message-ID: I completely agree, In my environment we now also have VLDB's and in those systems the transaction log is typically between 15-30gb large depending on which system we're talking about... I have an automatic alert that fire's off when the transaction log hits 60% of it's total size and performs a backup. This effectively prevents the log from over-growing. At night I perform a Differential backup and this allows me to drop the transaction logs within 1week so that I don't eat up too much disk space. I am using Red-Gate's Sql Backup so I compress all my backups, for my largest database, a compressed backup generally looks like 250gbs and takes between 2-3hrs depending on network traffic. I also do have a script for shrinking the log files that fires off once a week, but generally this does not occur to often (it's also set on an alert) the purpose is that this should not fire often if all the other backups are occuring at regular intrevals, over-shrinking your file then re-growing it on NTFS causes huge disk fragmentation if you are using SAN disk, then the amout of fragmentation depends on the vendor of SAN you are using... -Francisco http://sqlthis.blogspot.com | Tsql and More... On Wed, Sep 10, 2008 at 4:09 PM, Asger Blond wrote: > Just a second comment for Arthur: > > You wrote: "Now we back up the log (only the log) four times a day and > nightly do a dbcc shrinkfile" > > To my mind a DBCC SHRINKFILE is an emergency command which should NOT be > included in an automated administrative task. > > DBCC SHRINKFILE will free truncated file-space to the operating system. > This > may be a reasonable action if the log-file has been bloating. Otherwise it > certainly is not: freeing truncated file-space to the operation system will > force SQL Server to allocate new file-space for the log as needed, and this > will be a great invitation for file fragmentation at the disk level. > > Asger > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger > Blond > Sendt: 11. september 2008 00:18 > Til: 'Discussion concerning MS SQL Server' > Emne: Re: [dba-SQLServer] full transaction logs > > Hi Susan and Arthur, > > The transaction is only truncated if you: > > 1. Set the database to SIMPLE RECOVERY MODEL. This recovery model equals > the > obsolete command SET TRUNCATE ON CHECKPOINT ON, meaning that the log is > automatically truncated when a checkpoint is performed (normally every 1 > minute). However, setting the database to SIMPLE RECOVERY MODEL will not > allow you to make backups of the transaction log - so this is not a > reasonable choice for an OLTP-database. > OR: > 2. Perform a manual truncation of the log issuing the command BACKUP LOG > WITH TRUNCATE_ONLY. This command should only be used as an > emergency if the database log for some reason is bloating. > OR: > 3. Perform a log-backup at regular intervals. Notice that only a log-backup > will truncate the log, a full or differential backup won't. > > Of these options I normally would prefer the last for an OLTP-database. > > If I'm not wrong this may be an answer to Arthur's statement: "I don't know > what I'm doing right." > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arthur > Fuller > Sendt: 10. september 2008 22:32 > Til: Discussion concerning MS SQL Server > Emne: Re: [dba-SQLServer] full transaction logs > > I know that some people have received a message that their transaction log > is full, but I personally never have. I don't know what I'm doing right. > Recently we changed our strategy on transaction logs. Now we back up the > log > (only the log) four times a day and nightly do a dbcc shrinkfile, so the > living log is peanuts compared to what it used to be. Before I got here > there was a nightly process that dropped a table and then recreated it and > did thousands of inserts. As a result, the log file was huge -- way larger > than the 18 gig db itself. We changed that process dramatically and the log > file shrank dramatically too. > Arthur > On Wed, Sep 10, 2008 at 4:33 PM, Susan Harkins > wrote: > > > Are full transaction logs still a problem in 2005 and 2008? I'm just > > wondering if they've done anything automatic to warn the administrator or > > to > > avoid the problem altogether. > > > > Susan H. > > > _______________________________________________ > 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 ssharkins at gmail.com Sat Sep 13 14:43:52 2008 From: ssharkins at gmail.com (Susan Harkins) Date: Sat, 13 Sep 2008 15:43:52 -0400 Subject: [dba-SQLServer] transactions not logged Message-ID: <0ced01c915d9$0e30de60$2f8601c7@SusanOne> I'm looking for a comprehensive list of transactions not tracked and logged in the transaction log, but so far, no luck. If you have something bookmarked, please share. Susan H. From ab-mi at post3.tele.dk Sat Sep 13 16:54:57 2008 From: ab-mi at post3.tele.dk (Asger Blond) Date: Sat, 13 Sep 2008 23:54:57 +0200 Subject: [dba-SQLServer] transactions not logged In-Reply-To: <0ced01c915d9$0e30de60$2f8601c7@SusanOne> Message-ID: <000001c915eb$5d055c20$2401a8c0@AB> >From http://support.microsoft.com/kb/272093 "In the full recovery model, every change to the database is logged." "In the Bulk-logged model, minimal logging may be performed for the following operations to save transaction log space: ? Bulk load operations, including bcp and BULK INSERT. ? CREATE INDEX, including indexed views. ? SELECT INTO ? WRITETEXT ? UPDATETEXT ? DTS with Use Fast Load and Table Lock enabled." Don't know if this is a comprehensive list. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Susan Harkins Sendt: 13. september 2008 21:44 Til: SQLList Emne: [dba-SQLServer] transactions not logged I'm looking for a comprehensive list of transactions not tracked and logged in the transaction log, but so far, no luck. If you have something bookmarked, please share. Susan H. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From paul.hartland at googlemail.com Mon Sep 15 06:24:34 2008 From: paul.hartland at googlemail.com (Paul Hartland) Date: Mon, 15 Sep 2008 12:24:34 +0100 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer In-Reply-To: <000001c91522$d43d2c60$2401a8c0@AB> References: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> <000001c91522$d43d2c60$2401a8c0@AB> Message-ID: <38c884770809150424l3b9b3e42ta9a0aa771a00ca0@mail.gmail.com> Asger, I have created a FOR DELETE trigger, and fingers crossed no more records have disappeared since, however how do I view the trigger that I have created in SQL Server 2005 ? Thanks for your help. Paul 2008/9/12 Asger Blond > For this I would create an audittable and a FOR DELETE TRIGGER. > Suppose your tblPersonnel has columns like PersonnelID, FirstName, and > LastName. You want to audit the record deleted plus the time of the event, > and the user performing the deletion: > > CREATE TABLE AuditDelete > (PersonnelID int, FirstName varchar(30), LastName varchar (30), Deletion > varchar(100) DEFAULT CONVERT(varchar(50), GETDATE()) + '. By: ' + > SUSER_SNAME()) > GO > > CREATE TRIGGER tr_tblPersonnel_Delete ON tblPersonnel FOR DELETE AS > INSERT INTO AuditTable (PersonnelID, FirstName, LastName) SELECT > PersonnelID, FirstName, LastName FROM deleted > GO > > Using a delete-trigger your can also cancel the event issuing a rollback. > Suppose you want to prevent deletion of multiple rows in the personnel > table, you could create the trigger like this: > > CREATE TRIGGER tr_tblPersonnel_Delete ON tblPersonnel FOR DELETE AS > IF (SELECT COUNT(*) FROM deleted) > 1 > BEGIN > RAISERROR ('Deletion of multiple records not permitted!',16,1) > ROLLBACK TRANSACTION > END > ELSE > INSERT INTO AuditTable (PersonnelID, FirstName, LastName) SELECT > PersonnelID, FirstName, LastName FROM deleted > GO > > Asger > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Paul > Hartland > Sendt: 12. september 2008 09:26 > Til: Access List; SQLServerList > Emne: [dba-SQLServer] SQL Server 2005 LDF Viewer > > To all, > > Over the last two days we have been losing personnel off our main database, > and have had to retrieve them from one of my many backups. However I can't > seem to see why or where this is happening in my application (VB6)...Does > anybody know how to view the LDF files, so that I can see each transaction > as it takes place, or if there is something I can do when a record is > deleted from tblPersonnel, or if I can turn on some sort of monitoring > system ? > > Thanks in advance for any help on this. > > -- > Paul Hartland > paul.hartland at googlemail.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 > > -- Paul Hartland paul.hartland at googlemail.com From paul.hartland at googlemail.com Mon Sep 15 07:11:48 2008 From: paul.hartland at googlemail.com (Paul Hartland) Date: Mon, 15 Sep 2008 13:11:48 +0100 Subject: [dba-SQLServer] SQL Server 2005 LDF Viewer In-Reply-To: <38c884770809150424l3b9b3e42ta9a0aa771a00ca0@mail.gmail.com> References: <38c884770809120025n54f37781y764c9a1767779b38@mail.gmail.com> <000001c91522$d43d2c60$2401a8c0@AB> <38c884770809150424l3b9b3e42ta9a0aa771a00ca0@mail.gmail.com> Message-ID: <38c884770809150511g7c238d4ey71b41fbaee7e91d7@mail.gmail.com> Please ignore last email from me asking where Triggers are stored, was having blonde moment... Thanks again for everyone's help. Paul 2008/9/15 Paul Hartland > Asger, > > I have created a FOR DELETE trigger, and fingers crossed no more records > have disappeared since, however how do I view the trigger that I have > created in SQL Server 2005 ? > > Thanks for your help. > > Paul > > 2008/9/12 Asger Blond > > For this I would create an audittable and a FOR DELETE TRIGGER. >> Suppose your tblPersonnel has columns like PersonnelID, FirstName, and >> LastName. You want to audit the record deleted plus the time of the event, >> and the user performing the deletion: >> >> CREATE TABLE AuditDelete >> (PersonnelID int, FirstName varchar(30), LastName varchar (30), Deletion >> varchar(100) DEFAULT CONVERT(varchar(50), GETDATE()) + '. By: ' + >> SUSER_SNAME()) >> GO >> >> CREATE TRIGGER tr_tblPersonnel_Delete ON tblPersonnel FOR DELETE AS >> INSERT INTO AuditTable (PersonnelID, FirstName, LastName) SELECT >> PersonnelID, FirstName, LastName FROM deleted >> GO >> >> Using a delete-trigger your can also cancel the event issuing a rollback. >> Suppose you want to prevent deletion of multiple rows in the personnel >> table, you could create the trigger like this: >> >> CREATE TRIGGER tr_tblPersonnel_Delete ON tblPersonnel FOR DELETE AS >> IF (SELECT COUNT(*) FROM deleted) > 1 >> BEGIN >> RAISERROR ('Deletion of multiple records not permitted!',16,1) >> ROLLBACK TRANSACTION >> END >> ELSE >> INSERT INTO AuditTable (PersonnelID, FirstName, LastName) SELECT >> PersonnelID, FirstName, LastName FROM deleted >> GO >> >> Asger >> -----Oprindelig meddelelse----- >> Fra: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Paul >> Hartland >> Sendt: 12. september 2008 09:26 >> Til: Access List; SQLServerList >> Emne: [dba-SQLServer] SQL Server 2005 LDF Viewer >> >> To all, >> >> Over the last two days we have been losing personnel off our main >> database, >> and have had to retrieve them from one of my many backups. However I >> can't >> seem to see why or where this is happening in my application (VB6)...Does >> anybody know how to view the LDF files, so that I can see each transaction >> as it takes place, or if there is something I can do when a record is >> deleted from tblPersonnel, or if I can turn on some sort of monitoring >> system ? >> >> Thanks in advance for any help on this. >> >> -- >> Paul Hartland >> paul.hartland at googlemail.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 >> >> > > > -- > Paul Hartland > paul.hartland at googlemail.com > -- Paul Hartland paul.hartland at googlemail.com From fuller.artful at gmail.com Mon Sep 15 13:09:34 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 15 Sep 2008 15:09:34 -0300 Subject: [dba-SQLServer] Bulk insert puzzle Message-ID: <29f585dd0809151109r70dc42a8td44baab5ff543d96@mail.gmail.com> I have a peculiar puzzle here. I will soon embark on a new project in which I'll be using SSIS to grab millions of rows coming in daily. A c++ component will be reading a stream and writing the data. Our original concept was that the c++ component would do inserts into a staging table and occasionally flush that table, moving the data into the real database. Now that we see the speed and quantity of the incoming data, we are not so sure we will be able to keep up. So I have been investigating the possibility of using Bulk Insert from many text files, so the process would be something along the lines of: 1. c++ writes a new file every 10k rows. 2. bulk insert kicks in and inserts that entire file into a staging table. 3. destroy the file just inserted. 4. move the data from the staging table to the real database. 5. Repeat until the last text file has been deleted. So the algorithm is fairly clear (although as always subject to adjustment as we move into development and production). I have some sample data of the type we will be receiving. This morning I created an SSIS package using the Import/Export wizard to dump that data to a csv file. Fine, so far. Then I created a bulk insert script. First here is the table structure: CREATE TABLE [dbo].[BPODMessage_Staging]( [SecurityIDBSID] [bigint] NOT NULL, [MessageName] [varchar](200) NOT NULL, [FieldName] [varchar](200) NOT NULL, [DataValue] [varchar](50) NULL, [TimeOfUpdate] [datetime] NOT NULL, [Ts] [timestamp] NOT NULL ) ON [PRIMARY] GO Here is the next part of the puzzle: PRINT GETDATE() BULK INSERT BPOD.dbo.BPODMessage_Staging FROM 'C:\Documents and Settings\afuller\My Documents\BPOD\BPOD_Message.txt' WITH (FIRSTROW=1, BATCHSIZE = 1000, FIELDTERMINATOR=',', ROWTERMINATOR='\n') PRINT GETDATE() This results in these error messages: Msg 4866, Level 16, State 1, Line 2 The bulk load failed. The column is too long in the data file for row 1, column 1. Verify that the field terminator and row terminator are specified correctly. Msg 7399, Level 16, State 1, Line 2 The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error. Msg 7330, Level 16, State 2, Line 2 Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)". A line of the data I'm attempting to import looks like this: 678605358674,Summary.Message,Summary.Last.Bid.Time,20080703 11:56:21.000,2008-07-03 08:54:31.820000000,000000001ABA0AC1 Given that the staging table was created by scripting the final table to a Create To | New Query window and then created, how could data that came from an identical structure now suddenly not fit? Any ideas? TIA, Arthur From newsgrps at dalyn.co.nz Mon Sep 15 13:58:17 2008 From: newsgrps at dalyn.co.nz (David Emerson) Date: Tue, 16 Sep 2008 06:58:17 +1200 Subject: [dba-SQLServer] Formatting Numbers IN SQL Message-ID: <20080915185710.BTPW29348.mta06.xtra.co.nz@Dalyn.dalyn.co.nz> I am wanting to convert the following access line into SQL: Format(12345,"#,##0") Is there an equivalent SQL command to use in a stored procedure? The result is then to be cast into a varchar to be appended to another varchar. Regards David Emerson Dalyn Software Ltd Wellington, New Zealand From fuller.artful at gmail.com Mon Sep 15 14:13:55 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 15 Sep 2008 16:13:55 -0300 Subject: [dba-SQLServer] AdventureWorks.csv Message-ID: <29f585dd0809151213k9418462obb1d009e21adf7e0@mail.gmail.com> Does anyone have a copy of this file that is allegedly part of the build script for the AdventureWorks sample database? It is alleged to be on my hard disk already and if not, then downloadable from MS, but I can't find it in either location. If you have a copy, would you kindly zip it and send it to me off-list? TIA, Arthur From accessd at shaw.ca Mon Sep 15 16:30:03 2008 From: accessd at shaw.ca (Jim Lawrence) Date: Mon, 15 Sep 2008 14:30:03 -0700 Subject: [dba-SQLServer] AdventureWorks.csv In-Reply-To: <29f585dd0809151213k9418462obb1d009e21adf7e0@mail.gmail.com> References: <29f585dd0809151213k9418462obb1d009e21adf7e0@mail.gmail.com> Message-ID: Hi Arthur: I am not sure what you are needing but the entire adventureworks download is available at: http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?Relea seId=16040 Everything must be in this package group. HTH Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Monday, September 15, 2008 12:14 PM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] AdventureWorks.csv Does anyone have a copy of this file that is allegedly part of the build script for the AdventureWorks sample database? It is alleged to be on my hard disk already and if not, then downloadable from MS, but I can't find it in either location. If you have a copy, would you kindly zip it and send it to me off-list? TIA, Arthur _______________________________________________ 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 Mon Sep 15 17:46:00 2008 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Tue, 16 Sep 2008 08:46:00 +1000 Subject: [dba-SQLServer] Bulk insert puzzle In-Reply-To: <29f585dd0809151109r70dc42a8td44baab5ff543d96@mail.gmail.com> References: <29f585dd0809151109r70dc42a8td44baab5ff543d96@mail.gmail.com> Message-ID: <48CF7248.17449.C79D90E@stuart.lexacorp.com.pg> Just a WAG, but do you have a header line in the file containing the field names. That would cause a problem reading Row 1, Column 1 with FirstLine = 1 and the first column being a BIGINT. On 15 Sep 2008 at 15:09, Arthur Fuller wrote: > I have a peculiar puzzle here. I will soon embark on a new project in which > I'll be using SSIS to grab millions of rows coming in daily. A c++ component > will be reading a stream and writing the data. Our original concept was that > the c++ component would do inserts into a staging table and occasionally > flush that table, moving the data into the real database. Now that we see > the speed and quantity of the incoming data, we are not so sure we will be > able to keep up. So I have been investigating the possibility of using Bulk > Insert from many text files, so the process would be something along the > lines of: > > 1. c++ writes a new file every 10k rows. > 2. bulk insert kicks in and inserts that entire file into a staging table. > 3. destroy the file just inserted. > 4. move the data from the staging table to the real database. > 5. Repeat until the last text file has been deleted. > > So the algorithm is fairly clear (although as always subject to adjustment > as we move into development and production). > > I have some sample data of the type we will be receiving. This morning I > created an SSIS package using the Import/Export wizard to dump that data to > a csv file. Fine, so far. Then I created a bulk insert script. First here is > the table structure: > > > CREATE TABLE [dbo].[BPODMessage_Staging]( > [SecurityIDBSID] [bigint] NOT NULL, > [MessageName] [varchar](200) NOT NULL, > [FieldName] [varchar](200) NOT NULL, > [DataValue] [varchar](50) NULL, > [TimeOfUpdate] [datetime] NOT NULL, > [Ts] [timestamp] NOT NULL > ) ON [PRIMARY] > GO > > > > Here is the next part of the puzzle: > > > > PRINT GETDATE() > BULK INSERT BPOD.dbo.BPODMessage_Staging > FROM 'C:\Documents and Settings\afuller\My Documents\BPOD\BPOD_Message.txt' > WITH (FIRSTROW=1, BATCHSIZE = 1000, FIELDTERMINATOR=',', ROWTERMINATOR='\n') > PRINT GETDATE() > > > > This results in these error messages: > > > > Msg 4866, Level 16, State 1, Line 2 > The bulk load failed. The column is too long in the data file for row 1, > column 1. Verify that the field terminator and row terminator are specified > correctly. > Msg 7399, Level 16, State 1, Line 2 > The OLE DB provider "BULK" for linked server "(null)" reported an error. The > provider did not give any information about the error. > Msg 7330, Level 16, State 2, Line 2 > Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)". > > > > A line of the data I'm attempting to import looks like this: > > > > 678605358674,Summary.Message,Summary.Last.Bid.Time,20080703 > 11:56:21.000,2008-07-03 08:54:31.820000000,000000001ABA0AC1 > > > > Given that the staging table was created by scripting the final table to a > Create To | New Query window and then created, how could data that came from > an identical structure now suddenly not fit? > > Any ideas? > > TIA, > > Arthur > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From fuller.artful at gmail.com Mon Sep 15 18:09:06 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 15 Sep 2008 20:09:06 -0300 Subject: [dba-SQLServer] Bulk insert puzzle In-Reply-To: <48CF7248.17449.C79D90E@stuart.lexacorp.com.pg> References: <29f585dd0809151109r70dc42a8td44baab5ff543d96@mail.gmail.com> <48CF7248.17449.C79D90E@stuart.lexacorp.com.pg> Message-ID: <29f585dd0809151609rf7b1532v5e14661de4ccd950@mail.gmail.com> No header line. Tried straight comma-delimited, tried quoted csv (double and single), so far no joy. I don't get it. A. On Mon, Sep 15, 2008 at 7:46 PM, Stuart McLachlan wrote: > Just a WAG, but do you have a header line in the file containing the field > names. > > That would cause a problem reading Row 1, Column 1 with FirstLine = 1 > and the first column being a BIGINT. > > > From mike.tope at dsl.pipex.com Mon Sep 15 19:27:55 2008 From: mike.tope at dsl.pipex.com (Mike Tope) Date: Tue, 16 Sep 2008 01:27:55 +0100 Subject: [dba-SQLServer] ASP to 64-bit Message-ID: <009901c91793$13544150$0207a8c0@charybdis> Dear List Wonder if anyone else has come up against this and can give me a pointer. I'm normally a lurker, and usually well behind the times - I only get to this email late at night (in London) so don't expect instant conversation. Anyway, there exist several SQL 2000 databases using ASP front ends (I didn't write them). They run on the same server as the Internet Information Server serving them. Our office in Aberdeen has kindly chosen to install a 64-bit operating system, and install SQL 2005. Obviously, the test database doesn't work. First advice I saw was to change the connection string to use SQLOLEDB. This enabled the front screen to open, which uses a Set rs=OpenRecordset construction. However, the later screens where rs=cmd.Execute was used, failed, and I saw pointers suggesting that the parameters object needed to be overtly declared. Not that the particular page had parameters, but anyway that was going to involve recoding some hundreds of ASP files. I learnt that it was possible to enable 32-bit apps within 64-bit IBIS by running a single vbs command in the Admin web site utility - this is now done. I can connect to the first page using a DSN equivalent to the original but set up in odbcad32.exe in the SysWoW64 folder rather than control panel, Admin Tasks, ODBC. But it falls down at the same point - setting a recordset to cmd.Execute gives me a server error 500. I could recode around the Selects, but what about the Inserts, Modifies and Deletes ? VBscript is of course not 32-bit enabled so my testing options are limited. Am I missing something obvious ? I can't entertain the idea of rewriting the entire set. Regards Mike Tope From michael at ddisolutions.com.au Tue Sep 16 05:09:37 2008 From: michael at ddisolutions.com.au (Michael Maddison) Date: Tue, 16 Sep 2008 20:09:37 +1000 Subject: [dba-SQLServer] ASP to 64-bit References: <009901c91793$13544150$0207a8c0@charybdis> Message-ID: <59A61174B1F5B54B97FD4ADDE71E7D013C003B@ddi-01.DDI.local> Hi Mike, Taking a wild stab here... I suspect you need to make sure that the user has select permissions on the tables. Not the most secure thing to do but it seems you are executing strings in the ASP and returning recordsets so table level permissions will be required. Havn't done any ASP classic in years and never with 64-bit SQL... Cheers Michael M -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Mike Tope Sent: Tuesday, 16 September 2008 10:28 AM To: Dba-SqlServer Subject: [dba-SQLServer] ASP to 64-bit Dear List Wonder if anyone else has come up against this and can give me a pointer. I'm normally a lurker, and usually well behind the times - I only get to this email late at night (in London) so don't expect instant conversation. Anyway, there exist several SQL 2000 databases using ASP front ends (I didn't write them). They run on the same server as the Internet Information Server serving them. Our office in Aberdeen has kindly chosen to install a 64-bit operating system, and install SQL 2005. Obviously, the test database doesn't work. First advice I saw was to change the connection string to use SQLOLEDB. This enabled the front screen to open, which uses a Set rs=OpenRecordset construction. However, the later screens where rs=cmd.Execute was used, failed, and I saw pointers suggesting that the parameters object needed to be overtly declared. Not that the particular page had parameters, but anyway that was going to involve recoding some hundreds of ASP files. I learnt that it was possible to enable 32-bit apps within 64-bit IBIS by running a single vbs command in the Admin web site utility - this is now done. I can connect to the first page using a DSN equivalent to the original but set up in odbcad32.exe in the SysWoW64 folder rather than control panel, Admin Tasks, ODBC. But it falls down at the same point - setting a recordset to cmd.Execute gives me a server error 500. I could recode around the Selects, but what about the Inserts, Modifies and Deletes ? VBscript is of course not 32-bit enabled so my testing options are limited. Am I missing something obvious ? I can't entertain the idea of rewriting the entire set. Regards Mike Tope _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fuller.artful at gmail.com Tue Sep 16 09:43:38 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 16 Sep 2008 11:43:38 -0300 Subject: [dba-SQLServer] Return the result set of a sproc additively Message-ID: <29f585dd0809160743v5d74bb86l5c788d05e33ea32e@mail.gmail.com> I'm having a senior moment, but I know I have done this, and I think I have written about how to do it, but I can't find the article and can't remember how to do it, but I do know it can be done. Here's the gist. I want to call a sproc (which is just a select) N times and have the result sets "unioned", as it were. Say for example we have 5 salespersons in a company, and I want the sales of 4 of them. It's easy to grab the 4 selected IDs, but then I want to go in and grab all the sales for those 4. This is the important part: I don't want to rewrite the logic that's already there to grab one salesperson's data. I want to call that sproc several times and union the results. I'm sure that I have done this but at the moment I can't remember how I did it. TIA, Arthur From robert at webedb.com Tue Sep 16 10:03:10 2008 From: robert at webedb.com (Robert L. Stewart) Date: Tue, 16 Sep 2008 10:03:10 -0500 Subject: [dba-SQLServer] Return the result set of a sproc additively In-Reply-To: References: Message-ID: <200809161506.m8GF6E7g030862@databaseadvisors.com> Use temp tables to hold the data until you can union it. At 09:43 AM 9/16/2008, you wrote: >Date: Tue, 16 Sep 2008 11:43:38 -0300 >From: "Arthur Fuller" >Subject: [dba-SQLServer] Return the result set of a sproc additively >To: "Discussion concerning MS SQL Server" > >Message-ID: > <29f585dd0809160743v5d74bb86l5c788d05e33ea32e at mail.gmail.com> >Content-Type: text/plain; charset=ISO-8859-1 > >I'm having a senior moment, but I know I have done this, and I think I have >written about how to do it, but I can't find the article and can't remember >how to do it, but I do know it can be done. > >Here's the gist. > >I want to call a sproc (which is just a select) N times and have the result >sets "unioned", as it were. Say for example we have 5 salespersons in a >company, and I want the sales of 4 of them. It's easy to grab the 4 selected >IDs, but then I want to go in and grab all the sales for those 4. This is >the important part: I don't want to rewrite the logic that's already there >to grab one salesperson's data. I want to call that sproc several times and >union the results. > >I'm sure that I have done this but at the moment I can't remember how I did >it. > >TIA, >Arthur From newsgrps at dalyn.co.nz Tue Sep 16 12:19:50 2008 From: newsgrps at dalyn.co.nz (David Emerson) Date: Wed, 17 Sep 2008 05:19:50 +1200 Subject: [dba-SQLServer] Formatting Numbers IN SQL Message-ID: <20080916171845.FPPQ13966.mta02.xtra.co.nz@Dalyn.dalyn.co.nz> Since I didn't get a reply I will try another tact. There doesn't seem to be an SQL equivalent to the Access Format(12345,"#,##0"). What is the simplest way of taking a number like 12345.00 and converting it to a varchar "12,345"? Regards David Emerson Dalyn Software Ltd Wellington, New Zealand From ssharkins at gmail.com Tue Sep 16 12:23:35 2008 From: ssharkins at gmail.com (Susan Harkins) Date: Tue, 16 Sep 2008 13:23:35 -0400 Subject: [dba-SQLServer] Formatting Numbers IN SQL References: <20080916171845.FPPQ13966.mta02.xtra.co.nz@Dalyn.dalyn.co.nz> Message-ID: <18bb01c91820$f405ca10$2f8601c7@SusanOne> > There doesn't seem to be an SQL equivalent to the Access > Format(12345,"#,##0"). What is the simplest way of taking a number > like 12345.00 and converting it to a varchar "12,345"? ====First, is it 12345 or 12345.00? Or, could it be either? Susan H. From Elizabeth.J.Doering at wellsfargo.com Tue Sep 16 12:31:09 2008 From: Elizabeth.J.Doering at wellsfargo.com (Elizabeth.J.Doering at wellsfargo.com) Date: Tue, 16 Sep 2008 12:31:09 -0500 Subject: [dba-SQLServer] Formatting Numbers IN SQL References: <20080916171845.FPPQ13966.mta02.xtra.co.nz@Dalyn.dalyn.co.nz> Message-ID: Are you trying to stick the commas in? 'cause if you cast it as a varchar print '$' + cast(12345 as varchar) you can append it to other varchars, but you don't get commas. If you find out how to do those, I would like to know too. Thanks, Liz This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Tuesday, September 16, 2008 12:20 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Formatting Numbers IN SQL Since I didn't get a reply I will try another tact. There doesn't seem to be an SQL equivalent to the Access Format(12345,"#,##0"). What is the simplest way of taking a number like 12345.00 and converting it to a varchar "12,345"? Regards David Emerson Dalyn Software Ltd Wellington, New Zealand _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From delam at zyterra.com Tue Sep 16 12:37:15 2008 From: delam at zyterra.com (Debbie Elam) Date: Tue, 16 Sep 2008 12:37:15 -0500 Subject: [dba-SQLServer] Formatting Numbers IN SQL Message-ID: <20080916173712.MONB5778.atlmtaow01.cingularme.com@Inbox> Since SQL is a backend only, this sort of formatting is not generally handled there. Access does formatting at the table level because it is also a front end and can pass that seamlessly. Just set the data type to integer if you do not want any decimals to be stored. Otherwise, set the format at the front end. Debbie -----Original Message----- From: David Emerson Sent: Tuesday, September 16, 2008 12:19 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Formatting Numbers IN SQL Since I didn't get a reply I will try another tact. There doesn't seem to be an SQL equivalent to the Access Format(12345,"#,##0"). What is the simplest way of taking a number like 12345.00 and converting it to a varchar "12,345"? Regards David Emerson Dalyn Software Ltd Wellington, New Zealand _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From newsgrps at dalyn.co.nz Tue Sep 16 13:03:59 2008 From: newsgrps at dalyn.co.nz (David Emerson) Date: Wed, 17 Sep 2008 06:03:59 +1200 Subject: [dba-SQLServer] Formatting Numbers IN SQL In-Reply-To: <18bb01c91820$f405ca10$2f8601c7@SusanOne> References: <20080916171845.FPPQ13966.mta02.xtra.co.nz@Dalyn.dalyn.co.nz> <18bb01c91820$f405ca10$2f8601c7@SusanOne> Message-ID: <20080916180728.NQYR22271.mta04.xtra.co.nz@Dalyn.dalyn.co.nz> Sorry about the confusion - it is money type (12345.00) At 17/09/2008, you wrote: > > There doesn't seem to be an SQL equivalent to the Access > > Format(12345,"#,##0"). What is the simplest way of taking a number > > like 12345.00 and converting it to a varchar "12,345"? > >====First, is it 12345 or 12345.00? Or, could it be either? > >Susan H. >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com From newsgrps at dalyn.co.nz Tue Sep 16 13:08:27 2008 From: newsgrps at dalyn.co.nz (David Emerson) Date: Wed, 17 Sep 2008 06:08:27 +1200 Subject: [dba-SQLServer] Formatting Numbers IN SQL In-Reply-To: <20080916173712.MONB5778.atlmtaow01.cingularme.com@Inbox> References: <20080916173712.MONB5778.atlmtaow01.cingularme.com@Inbox> Message-ID: <20080916180734.NRES22271.mta04.xtra.co.nz@Dalyn.dalyn.co.nz> Thanks. I was hoping to be able to do it in SQL as there are other manipulations to do before getting to the front end, but it looks like your suggestion is the only easy option. At 17/09/2008, you wrote: >Since SQL is a backend only, this sort of formatting is not >generally handled there. Access does formatting at the table level >because it is also a front end and can pass that seamlessly. > >Just set the data type to integer if you do not want any decimals to >be stored. Otherwise, set the format at the front end. > >Debbie > >-----Original Message----- >From: David Emerson >Sent: Tuesday, September 16, 2008 12:19 PM >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer] Formatting Numbers IN SQL > >Since I didn't get a reply I will try another tact. > >There doesn't seem to be an SQL equivalent to the Access >Format(12345,"#,##0"). What is the simplest way of taking a number >like 12345.00 and converting it to a varchar "12,345"? > > >Regards > >David Emerson >Dalyn Software Ltd >Wellington, New Zealand > >_______________________________________________ >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 fahooper at trapo.com Tue Sep 16 13:08:04 2008 From: fahooper at trapo.com (Fred Hooper) Date: Tue, 16 Sep 2008 14:08:04 -0400 Subject: [dba-SQLServer] Formatting Numbers IN SQL In-Reply-To: <20080916171845.FPPQ13966.mta02.xtra.co.nz@Dalyn.dalyn.co.nz> Message-ID: <7E98EF3B553149BBA8A92DC97DC754C1@FRED6998B25045> If you only want two decimal places you can use money, like this: select convert(varchar, convert(money, 12345) ,1) returns "12,345.00" -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Tuesday, September 16, 2008 1:20 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer] Formatting Numbers IN SQL Since I didn't get a reply I will try another tact. There doesn't seem to be an SQL equivalent to the Access Format(12345,"#,##0"). What is the simplest way of taking a number like 12345.00 and converting it to a varchar "12,345"? Regards David Emerson Dalyn Software Ltd Wellington, New Zealand _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From newsgrps at dalyn.co.nz Tue Sep 16 16:41:49 2008 From: newsgrps at dalyn.co.nz (David Emerson) Date: Wed, 17 Sep 2008 09:41:49 +1200 Subject: [dba-SQLServer] Formatting Numbers IN SQL In-Reply-To: <7E98EF3B553149BBA8A92DC97DC754C1@FRED6998B25045> References: <20080916171845.FPPQ13966.mta02.xtra.co.nz@Dalyn.dalyn.co.nz> <7E98EF3B553149BBA8A92DC97DC754C1@FRED6998B25045> Message-ID: <20080916214026.HUXJ22271.mta04.xtra.co.nz@Dalyn.dalyn.co.nz> I tried that but still got "12345.00" I am using SQL2000. Regards David At 17/09/2008, you wrote: >If you only want two decimal places you can use money, like this: > >select convert(varchar, convert(money, 12345) ,1) > >returns "12,345.00" > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >Emerson >Sent: Tuesday, September 16, 2008 1:20 PM >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer] Formatting Numbers IN SQL > >Since I didn't get a reply I will try another tact. > >There doesn't seem to be an SQL equivalent to the Access >Format(12345,"#,##0"). What is the simplest way of taking a number >like 12345.00 and converting it to a varchar "12,345"? > > >Regards > >David Emerson >Dalyn Software Ltd >Wellington, New Zealand > >_______________________________________________ >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 fahooper at trapo.com Tue Sep 16 16:58:05 2008 From: fahooper at trapo.com (Fred Hooper) Date: Tue, 16 Sep 2008 17:58:05 -0400 Subject: [dba-SQLServer] Formatting Numbers IN SQL In-Reply-To: <20080916214026.HUXJ22271.mta04.xtra.co.nz@Dalyn.dalyn.co.nz> Message-ID: Hi David, I don't have 2000 to test on, but the documentation (http://msdn.microsoft.com/en-us/library/aa226054(SQL.80).aspx) says it ought to work. Maybe you have a regional setting that's affecting it, (I found a link where an integer was formatted with commas that was due to a regional setting -- perhaps you have the opposite effect). You could also try the DLL at http://www.databasepronews.com/articles/0220df.html if it's important enough. (I haven't tried it, just found it.) Fred -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Tuesday, September 16, 2008 5:42 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Formatting Numbers IN SQL I tried that but still got "12345.00" I am using SQL2000. Regards David At 17/09/2008, you wrote: >If you only want two decimal places you can use money, like this: > >select convert(varchar, convert(money, 12345) ,1) > >returns "12,345.00" > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >Emerson >Sent: Tuesday, September 16, 2008 1:20 PM >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer] Formatting Numbers IN SQL > >Since I didn't get a reply I will try another tact. > >There doesn't seem to be an SQL equivalent to the Access >Format(12345,"#,##0"). What is the simplest way of taking a number >like 12345.00 and converting it to a varchar "12,345"? > > >Regards > >David Emerson >Dalyn Software Ltd >Wellington, New Zealand > >_______________________________________________ >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 davidmcafee at gmail.com Tue Sep 16 17:43:10 2008 From: davidmcafee at gmail.com (David McAfee) Date: Tue, 16 Sep 2008 15:43:10 -0700 Subject: [dba-SQLServer] Formatting Numbers IN SQL In-Reply-To: <20080916214026.HUXJ22271.mta04.xtra.co.nz@Dalyn.dalyn.co.nz> References: <20080916171845.FPPQ13966.mta02.xtra.co.nz@Dalyn.dalyn.co.nz> <7E98EF3B553149BBA8A92DC97DC754C1@FRED6998B25045> <20080916214026.HUXJ22271.mta04.xtra.co.nz@Dalyn.dalyn.co.nz> Message-ID: <8786a4c00809161543s20824ec9rc7dde0af01d92823@mail.gmail.com> IN QA, I got the same result as Fred. 12,345.00 select '$ ' + CAST(convert(varchar, convert(money, 12345) ,1) AS VARCHAR(12)) as Cash will handle up to 9,999,999.99 David On Tue, Sep 16, 2008 at 2:41 PM, David Emerson wrote: > I tried that but still got "12345.00" > > I am using SQL2000. > > Regards > > David > > At 17/09/2008, you wrote: > >If you only want two decimal places you can use money, like this: > > > >select convert(varchar, convert(money, 12345) ,1) > > > >returns "12,345.00" > > > >-----Original Message----- > >From: dba-sqlserver-bounces at databaseadvisors.com > >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David > >Emerson > >Sent: Tuesday, September 16, 2008 1:20 PM > >To: dba-SQLServer at databaseadvisors.com > >Subject: [dba-SQLServer] Formatting Numbers IN SQL > > > >Since I didn't get a reply I will try another tact. > > > >There doesn't seem to be an SQL equivalent to the Access > >Format(12345,"#,##0"). What is the simplest way of taking a number > >like 12345.00 and converting it to a varchar "12,345"? > > > > > >Regards > > > >David Emerson > >Dalyn Software Ltd > >Wellington, New Zealand > > > >_______________________________________________ > >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 newsgrps at dalyn.co.nz Tue Sep 16 17:47:49 2008 From: newsgrps at dalyn.co.nz (David Emerson) Date: Wed, 17 Sep 2008 10:47:49 +1200 Subject: [dba-SQLServer] Formatting Numbers IN SQL In-Reply-To: <8786a4c00809161543s20824ec9rc7dde0af01d92823@mail.gmail.co m> References: <20080916171845.FPPQ13966.mta02.xtra.co.nz@Dalyn.dalyn.co.nz> <7E98EF3B553149BBA8A92DC97DC754C1@FRED6998B25045> <20080916214026.HUXJ22271.mta04.xtra.co.nz@Dalyn.dalyn.co.nz> <8786a4c00809161543s20824ec9rc7dde0af01d92823@mail.gmail.com> Message-ID: <20080916224644.XGIX9034.mta07.xtra.co.nz@Dalyn.dalyn.co.nz> I have spotted the problem - I omitted the ,1 at the end. Thanks everyone for your help. David At 17/09/2008, you wrote: >IN QA, I got the same result as Fred. > >12,345.00 > >select '$ ' + CAST(convert(varchar, convert(money, 12345) ,1) AS >VARCHAR(12)) as Cash > >will handle up to 9,999,999.99 > >David > >On Tue, Sep 16, 2008 at 2:41 PM, David Emerson wrote: > > > I tried that but still got "12345.00" > > > > I am using SQL2000. > > > > Regards > > > > David > > > > At 17/09/2008, you wrote: > > >If you only want two decimal places you can use money, like this: > > > > > >select convert(varchar, convert(money, 12345) ,1) > > > > > >returns "12,345.00" > > > > > >-----Original Message----- > > >From: dba-sqlserver-bounces at databaseadvisors.com > > >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David > > >Emerson > > >Sent: Tuesday, September 16, 2008 1:20 PM > > >To: dba-SQLServer at databaseadvisors.com > > >Subject: [dba-SQLServer] Formatting Numbers IN SQL > > > > > >Since I didn't get a reply I will try another tact. > > > > > >There doesn't seem to be an SQL equivalent to the Access > > >Format(12345,"#,##0"). What is the simplest way of taking a number > > >like 12345.00 and converting it to a varchar "12,345"? > > > > > > > > >Regards > > > > > >David Emerson > > >Dalyn Software Ltd > > >Wellington, New Zealand From mike.tope at dsl.pipex.com Tue Sep 16 18:36:06 2008 From: mike.tope at dsl.pipex.com (Mike Tope) Date: Wed, 17 Sep 2008 00:36:06 +0100 Subject: [dba-SQLServer] ASP to 64-bit References: <009901c91793$13544150$0207a8c0@charybdis> <59A61174B1F5B54B97FD4ADDE71E7D013C003B@ddi-01.DDI.local> Message-ID: <004b01c91854$fe258100$0207a8c0@charybdis> Thanks Michael, but been there. I created a whole new user in SQL Server, granted rights, set default database, and ensured SQL login rather than Windows Authentication. To get the front page required select rights; I eventually granted db owner rights. I'm thinking now it might not be a 64-bit issue at all but just a difference between SQLServer 2000 and 2005. That I should be able to test as we have 2005 Express running in 32-bit in our office, separate from the main SQL 2000 server. Even so, if it ends up involving recoding every cmd.Execute it's going to take forever. Regards Mike Tope ----- Original Message ----- From: "Michael Maddison" To: "Discussion concerning MS SQL Server" Sent: Tuesday, September 16, 2008 11:09 AM Subject: Re: [dba-SQLServer] ASP to 64-bit > Hi Mike, > > Taking a wild stab here... > I suspect you need to make sure that the user has select permissions on > the tables. > Not the most secure thing to do but it seems you are executing strings > in the ASP and > returning recordsets so table level permissions will be required. > Havn't done any ASP classic in years and never with 64-bit SQL... > > Cheers > > Michael M > > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Mike > Tope > Sent: Tuesday, 16 September 2008 10:28 AM > To: Dba-SqlServer > Subject: [dba-SQLServer] ASP to 64-bit > > Dear List > Wonder if anyone else has come up against this and can give me a > pointer. > I'm normally a lurker, and usually well behind the times - I only get to > > this email late at night (in London) so don't expect instant > conversation. > > Anyway, there exist several SQL 2000 databases using ASP front ends (I > didn't write them). They run on the same server as the Internet > Information > Server serving them. Our office in Aberdeen has kindly chosen to install > a > 64-bit operating system, and install SQL 2005. Obviously, the test > database > doesn't work. > > First advice I saw was to change the connection string to use SQLOLEDB. > This > enabled the front screen to open, which uses a Set rs=OpenRecordset > construction. > However, the later screens where rs=cmd.Execute was used, failed, and I > saw > pointers suggesting that the parameters object needed to be overtly > declared. Not that the particular page had parameters, but anyway that > was > going to involve recoding some hundreds of ASP files. > > I learnt that it was possible to enable 32-bit apps within 64-bit IBIS > by > running a single vbs command in the Admin web site utility - this is now > > done. I can connect to the first page using a DSN equivalent to the > original > but set up in odbcad32.exe in the SysWoW64 folder rather than control > panel, > Admin Tasks, ODBC. > > But it falls down at the same point - setting a recordset to cmd.Execute > > gives me a server error 500. I could recode around the Selects, but what > > about the Inserts, Modifies and Deletes ? VBscript is of course not > 32-bit > enabled so my testing options are limited. > > Am I missing something obvious ? I can't entertain the idea of rewriting > the > entire set. > > Regards > Mike Tope From fuller.artful at gmail.com Wed Sep 17 13:42:22 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Wed, 17 Sep 2008 15:42:22 -0300 Subject: [dba-SQLServer] Line Numbers Message-ID: <29f585dd0809171142t26418585me57e720f953629a9@mail.gmail.com> Does the editor in Management Studio recognize logical or physical line numbers? Given this code... CREATE TABLE #TempCash_Consideration ( PPersonContactType_ID int , Currency_ID int , CashValue decimal(18,2) , CashValue_FXH decimal(18,2) , Withdrawals decimal(18,2) , Contributions decimal(18,2)) ... does the editor regard this as one logical line? The reason I'm asking is that I have an error trapping routine that reports the procedure name and line number, but the line reported doesn't make sense. It's an occasional problem with a deadlock, but the line reported to be the problem is the above, which doesn't make sense. The lines after this one do an INSERT | SELECT. Could that be the problem? Arthur From nancy.lytle at gmail.com Wed Sep 17 14:14:02 2008 From: nancy.lytle at gmail.com (Nancy Lytle) Date: Wed, 17 Sep 2008 14:14:02 -0500 Subject: [dba-SQLServer] Line Numbers In-Reply-To: <29f585dd0809171142t26418585me57e720f953629a9@mail.gmail.com> References: <29f585dd0809171142t26418585me57e720f953629a9@mail.gmail.com> Message-ID: For what it is worth, I know that in Management Studio I can never really rely on the error message to 'point' to the correct line of code, it is usually the one below the 'line' I'm given in the message. Nancy Lytle N_Lytle at terpalum.umd.edu EMAILING FOR THE GREATER GOODJoin me > Date: Wed, 17 Sep 2008 15:42:22 -0300> From: fuller.artful at gmail.com> To: dba-sqlserver at databaseadvisors.com> Subject: [dba-SQLServer] Line Numbers> > Does the editor in Management Studio recognize logical or physical line> numbers? Given this code...> > > CREATE TABLE> #TempCash_Consideration (> PPersonContactType_ID int> , Currency_ID int> , CashValue decimal(18,2)> , CashValue_FXH decimal(18,2)> , Withdrawals decimal(18,2)> , Contributions decimal(18,2))> > > > ... does the editor regard this as one logical line? The reason I'm asking> is that I have an error trapping routine that reports the procedure name and> line number, but the line reported doesn't make sense. It's an> occasional problem with a deadlock, but the line reported to be the problem> is the above, which doesn't make sense. The lines after this one do an> INSERT | SELECT. Could that be the problem?> > Arthur> _______________________________________________> dba-SQLServer mailing list> dba-SQLServer at databaseadvisors.com> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver> http://www.databaseadvisors.com> From Darryl.Collins at coles.com.au Thu Sep 18 01:53:54 2008 From: Darryl.Collins at coles.com.au (Darryl Collins) Date: Thu, 18 Sep 2008 16:53:54 +1000 Subject: [dba-SQLServer] Controlling Trigger In-Reply-To: Message-ID: <57E6E6CA42105A48B977303A2CDC2720076DA26F80@WPEXCH22.retail.ad.cmltd.net.au> Hi Everyone, I am trying to create an transaction audit table using a trigger - I have one for Udate, Delete, Insert. However, whenever I make a change the trigger will record every record in the table as being update, rather than just the txn in question. I can see why this happens (as it is pretty much what i have coded), But how do I pass the active record KeyID (BaselineID in this case) to the SQL Trigger from Access? All I want to record is the record in the table that has changed, but am getting the entire table instead. Any Pointers? Cheers Darryl. Code below: ' -------------------------------------------------------------- SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO /* #############################################################*/ /* Changes to ITFCT_tblBaselineData UPDATE Trigger */ /* #############################################################*/ ALTER TRIGGER trgUpd_tblBaseline ON ITFCT_tblBaselineData FOR UPDATE AS INSERT INTO [dbo].ITFCT_audBaselineData ([BaselineID], [IsCurrent], [ProductCode], [ProjectCode], [SkillGroup], [Component], [ResourceOrItem], [StandardTaskID], [StandardTaskAdd], [MECID], [SpendTypeID], [AccTreatmentID], [AccountingSplit], [ValueAUD], [ValueOpex], [ValueCapex], [SourceID], [ForumRef], [ReleaseNote], [FYID], [Comments], [APLID], [EventTrigger] ) SELECT [BaselineID], [IsCurrent], [ProductCode], [ProjectCode], [SkillGroup], [Component], [ResourceOrItem], [StandardTaskID], [StandardTaskAdd], [MECID], [SpendTypeID], [AccTreatmentID], [AccountingSplit], [ValueAUD], [ValueOpex], [ValueCapex], [SourceID], [ForumRef], [ReleaseNote], [FYID], [Comments], [APLID], 'UPDATE' FROM ITFCT_tblBaselineData WHERE [BaselineID] = [BaselineID] ''' THIS BIT HERE NEEDS A TWEAK GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO ' -------------------------------------------------------------- This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses. No warranty is made that this material is free from computer virus or any other defect or error. Any loss/damage incurred by using this material is not the sender's responsibility. The sender's entire liability will be limited to resupplying the material. From Darryl.Collins at coles.com.au Thu Sep 18 02:08:03 2008 From: Darryl.Collins at coles.com.au (Darryl Collins) Date: Thu, 18 Sep 2008 17:08:03 +1000 Subject: [dba-SQLServer] Controlling Trigger In-Reply-To: <57E6E6CA42105A48B977303A2CDC2720076DA26F80@WPEXCH22.retail.ad.cmltd.net.au> Message-ID: <57E6E6CA42105A48B977303A2CDC2720076DA26F83@WPEXCH22.retail.ad.cmltd.net.au> Furrr-ghed-about-it!! hehehe. I am a prize goose. I forgot to add in "Inserted" at the bottom... duh! Should read "FROM Inserted ITFCT_tblBaselineData" rather than "FROM ITFCT_tblBaselineData" all good now. :) cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Darryl Collins Sent: Thursday, 18 September 2008 4:54 PM To: 'Discussion concerning MS SQL Server' Subject: [dba-SQLServer] Controlling Trigger Hi Everyone, I am trying to create an transaction audit table using a trigger - I have one for Udate, Delete, Insert. However, whenever I make a change the trigger will record every record in the table as being update, rather than just the txn in question. I can see why this happens (as it is pretty much what i have coded), But how do I pass the active record KeyID (BaselineID in this case) to the SQL Trigger from Access? All I want to record is the record in the table that has changed, but am getting the entire table instead. Any Pointers? Cheers Darryl. Code below: ' -------------------------------------------------------------- SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO /* #############################################################*/ /* Changes to ITFCT_tblBaselineData UPDATE Trigger */ /* #############################################################*/ ALTER TRIGGER trgUpd_tblBaseline ON ITFCT_tblBaselineData FOR UPDATE AS INSERT INTO [dbo].ITFCT_audBaselineData ([BaselineID], [IsCurrent], [ProductCode], [ProjectCode], [SkillGroup], [Component], [ResourceOrItem], [StandardTaskID], [StandardTaskAdd], [MECID], [SpendTypeID], [AccTreatmentID], [AccountingSplit], [ValueAUD], [ValueOpex], [ValueCapex], [SourceID], [ForumRef], [ReleaseNote], [FYID], [Comments], [APLID], [EventTrigger] ) SELECT [BaselineID], [IsCurrent], [ProductCode], [ProjectCode], [SkillGroup], [Component], [ResourceOrItem], [StandardTaskID], [StandardTaskAdd], [MECID], [SpendTypeID], [AccTreatmentID], [AccountingSplit], [ValueAUD], [ValueOpex], [ValueCapex], [SourceID], [ForumRef], [ReleaseNote], [FYID], [Comments], [APLID], 'UPDATE' FROM ITFCT_tblBaselineData WHERE [BaselineID] = [BaselineID] ''' THIS BIT HERE NEEDS A TWEAK GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO ' -------------------------------------------------------------- This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses. No warranty is made that this material is free from computer virus or any other defect or error. Any loss/damage incurred by using this material is not the sender's responsibility. The sender's entire liability will be limited to resupplying the material. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses. No warranty is made that this material is free from computer virus or any other defect or error. Any loss/damage incurred by using this material is not the sender's responsibility. The sender's entire liability will be limited to resupplying the material. From erbachs at gmail.com Mon Sep 22 09:33:37 2008 From: erbachs at gmail.com (Steve Erbach) Date: Mon, 22 Sep 2008 09:33:37 -0500 Subject: [dba-SQLServer] Sum of elapsed time blocks Message-ID: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> Dear Group, I wrote an upgrade to the classic ASP In/Out board my company uses in ASP.NET. The security cards we all have allow us access to the building and the In/Out times are recorded in a SQL table. I wonder if you could help me visualize a query that would total up the elapsed time IN for an employee over a defined period of time, say, from Monday at 12:01 AM to now. The table, AccessEvents, contains these main fields: EmployeeID TimeStamp AreaCode The AreaCode contains either the area of the building that the employee entered upon coming in, or the "outside", meaning that the employee is out of the building. Say that it's Thursday and the employee's AccessEvents records look like the following (I've changed the AreaCode to In or Out for simplicity): 337 2008-09-15 07:54:50.000 In 337 2008-09-15 11:59:56.000 Out 337 2008-09-15 12:38:24.000 In 337 2008-09-15 17:01:24.000 Out 337 2008-09-16 07:53:16.000 In 337 2008-09-16 11:58:00.000 Out 337 2008-09-16 12:33:35.000 In 337 2008-09-16 17:03:29.000 Out 337 2008-09-17 07:56:29.000 In 337 2008-09-17 11:59:14.000 Out 337 2008-09-17 12:49:41.000 In 337 2008-09-17 17:02:41.000 Out 337 2008-09-18 08:04:17.000 In ...and the employee wants to know how much time he's spent in the building up to now, which is, say, 10:00AM on Thursday the 18th of Sept. It's easy enough to select these records, but I'm having trouble visualizing how to sum the elapsed time spent IN the building, including the time from his last In event to 10:00. Any ideas? Regards, Steve Erbach Neenah, WI From erbachs at gmail.com Mon Sep 22 10:08:44 2008 From: erbachs at gmail.com (Steve Erbach) Date: Mon, 22 Sep 2008 10:08:44 -0500 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> Message-ID: <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com> Are we talking about using a SQL Cursor here? Steve Erbach Neenah, WI On Mon, Sep 22, 2008 at 9:33 AM, Steve Erbach wrote: > Dear Group, > > I wrote an upgrade to the classic ASP In/Out board my company uses in > ASP.NET. The security cards we all have allow us access to the > building and the In/Out times are recorded in a SQL table. > > I wonder if you could help me visualize a query that would total up > the elapsed time IN for an employee over a defined period of time, > say, from Monday at 12:01 AM to now. > > The table, AccessEvents, contains these main fields: > > EmployeeID > TimeStamp > AreaCode > > The AreaCode contains either the area of the building that the > employee entered upon coming in, or the "outside", meaning that the > employee is out of the building. > > Say that it's Thursday and the employee's AccessEvents records look > like the following (I've changed the AreaCode to In or Out for > simplicity): > > 337 2008-09-15 07:54:50.000 In > 337 2008-09-15 11:59:56.000 Out > 337 2008-09-15 12:38:24.000 In > 337 2008-09-15 17:01:24.000 Out > 337 2008-09-16 07:53:16.000 In > 337 2008-09-16 11:58:00.000 Out > 337 2008-09-16 12:33:35.000 In > 337 2008-09-16 17:03:29.000 Out > 337 2008-09-17 07:56:29.000 In > 337 2008-09-17 11:59:14.000 Out > 337 2008-09-17 12:49:41.000 In > 337 2008-09-17 17:02:41.000 Out > 337 2008-09-18 08:04:17.000 In > > ...and the employee wants to know how much time he's spent in the > building up to now, which is, say, 10:00AM on Thursday the 18th of > Sept. It's easy enough to select these records, but I'm having > trouble visualizing how to sum the elapsed time spent IN the building, > including the time from his last In event to 10:00. > > Any ideas? > > Regards, > > Steve Erbach > Neenah, WI From fuller.artful at gmail.com Mon Sep 22 11:29:24 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 22 Sep 2008 13:29:24 -0300 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com> References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com> Message-ID: <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> As Steve suggests, a cursor appears to be the way out of this, but I believe that this is because the model is wrong. In-to-out ought to be on one row not two. Then the problem erases itself. This approach might require some additional logic but in general, IMO, it is sound: Location1: In = 9:00am Location2: In = not permitted before Location1.Out is not null Location2: In >= Location1.Out My gut instinct tells me that it is a bad idea to store In and Out on separate rows. The concept ought to be rethought as a "Visit" which has an In time and an Out time.Then everything you need to know is on one single row and it's easy to grab and the duration is a cinch to calculate. Just my $0.02 Arthur On Mon, Sep 22, 2008 at 12:08 PM, Steve Erbach wrote: > Are we talking about using a SQL Cursor here? > > Steve Erbach > Neenah, WI > > On Mon, Sep 22, 2008 at 9:33 AM, Steve Erbach wrote: > > Dear Group, > > > > I wrote an upgrade to the classic ASP In/Out board my company uses in > > ASP.NET . The security cards we all have allow us > access to the > > building and the In/Out times are recorded in a SQL table. > > > > I wonder if you could help me visualize a query that would total up > > the elapsed time IN for an employee over a defined period of time, > > say, from Monday at 12:01 AM to now. > > > > The table, AccessEvents, contains these main fields: > > > > EmployeeID > > TimeStamp > > AreaCode > > > > The AreaCode contains either the area of the building that the > > employee entered upon coming in, or the "outside", meaning that the > > employee is out of the building. > > > > Say that it's Thursday and the employee's AccessEvents records look > > like the following (I've changed the AreaCode to In or Out for > > simplicity): > > > > 337 2008-09-15 07:54:50.000 In > > 337 2008-09-15 11:59:56.000 Out > > 337 2008-09-15 12:38:24.000 In > > 337 2008-09-15 17:01:24.000 Out > > 337 2008-09-16 07:53:16.000 In > > 337 2008-09-16 11:58:00.000 Out > > 337 2008-09-16 12:33:35.000 In > > 337 2008-09-16 17:03:29.000 Out > > 337 2008-09-17 07:56:29.000 In > > 337 2008-09-17 11:59:14.000 Out > > 337 2008-09-17 12:49:41.000 In > > 337 2008-09-17 17:02:41.000 Out > > 337 2008-09-18 08:04:17.000 In > > > > ...and the employee wants to know how much time he's spent in the > > building up to now, which is, say, 10:00AM on Thursday the 18th of > > Sept. It's easy enough to select these records, but I'm having > > trouble visualizing how to sum the elapsed time spent IN the building, > > including the time from his last In event to 10:00. > > > > Any ideas? > > > > Regards, > > > > Steve Erbach > > Neenah, WI > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From Gustav at cactus.dk Mon Sep 22 11:54:36 2008 From: Gustav at cactus.dk (Gustav Brock) Date: Mon, 22 Sep 2008 18:54:36 +0200 Subject: [dba-SQLServer] Sum of elapsed time blocks Message-ID: Hi Steve and Arthur I would keep the single rows but add a VisitId to the row: 11 337 2008-09-15 07:54:50.000 In 11 337 2008-09-15 11:59:56.000 Out 12 337 2008-09-15 12:38:24.000 In 12 337 2008-09-15 17:01:24.000 Out 13 337 2008-09-16 07:53:16.000 In 13 337 2008-09-16 11:58:00.000 Out 24 337 2008-09-16 12:33:35.000 In 24 337 2008-09-16 17:03:29.000 Out 25 337 2008-09-17 07:56:29.000 In 25 337 2008-09-17 11:59:14.000 Out 31 337 2008-09-17 12:49:41.000 In 31 337 2008-09-17 17:02:41.000 Out 77 337 2008-09-18 08:04:17.000 In If VisitStatus In/Out is a True/False, then all you need is a simple view to look up the row where VisitId match and VisitStatus1 = Not VisitStatus2 where you calculate the date/time diff. /gustav >>> fuller.artful at gmail.com 22-09-2008 18:29 >>> As Steve suggests, a cursor appears to be the way out of this, but I believe that this is because the model is wrong. In-to-out ought to be on one row not two. Then the problem erases itself. This approach might require some additional logic but in general, IMO, it is sound: Location1: In = 9:00am Location2: In = not permitted before Location1.Out is not null Location2: In >= Location1.Out My gut instinct tells me that it is a bad idea to store In and Out on separate rows. The concept ought to be rethought as a "Visit" which has an In time and an Out time.Then everything you need to know is on one single row and it's easy to grab and the duration is a cinch to calculate. Just my $0.02 Arthur On Mon, Sep 22, 2008 at 12:08 PM, Steve Erbach wrote: > Are we talking about using a SQL Cursor here? > > Steve Erbach > Neenah, WI > > On Mon, Sep 22, 2008 at 9:33 AM, Steve Erbach wrote: > > Dear Group, > > > > I wrote an upgrade to the classic ASP In/Out board my company uses in > > ASP.NET . The security cards we all have allow us access to the > > building and the In/Out times are recorded in a SQL table. > > > > I wonder if you could help me visualize a query that would total up > > the elapsed time IN for an employee over a defined period of time, > > say, from Monday at 12:01 AM to now. > > > > The table, AccessEvents, contains these main fields: > > > > EmployeeID > > TimeStamp > > AreaCode > > > > The AreaCode contains either the area of the building that the > > employee entered upon coming in, or the "outside", meaning that the > > employee is out of the building. > > > > Say that it's Thursday and the employee's AccessEvents records look > > like the following (I've changed the AreaCode to In or Out for > > simplicity): > > > > 337 2008-09-15 07:54:50.000 In > > 337 2008-09-15 11:59:56.000 Out > > 337 2008-09-15 12:38:24.000 In > > 337 2008-09-15 17:01:24.000 Out > > 337 2008-09-16 07:53:16.000 In > > 337 2008-09-16 11:58:00.000 Out > > 337 2008-09-16 12:33:35.000 In > > 337 2008-09-16 17:03:29.000 Out > > 337 2008-09-17 07:56:29.000 In > > 337 2008-09-17 11:59:14.000 Out > > 337 2008-09-17 12:49:41.000 In > > 337 2008-09-17 17:02:41.000 Out > > 337 2008-09-18 08:04:17.000 In > > > > ...and the employee wants to know how much time he's spent in the > > building up to now, which is, say, 10:00AM on Thursday the 18th of > > Sept. It's easy enough to select these records, but I'm having > > trouble visualizing how to sum the elapsed time spent IN the building, > > including the time from his last In event to 10:00. > > > > Any ideas? > > > > Regards, > > > > Steve Erbach > > Neenah, WI From stuart at lexacorp.com.pg Mon Sep 22 12:00:13 2008 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Tue, 23 Sep 2008 03:00:13 +1000 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com>, <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com>, <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> Message-ID: <48D85BBD.29522.CD688BB@stuart.lexacorp.com.pg> Trouble is nost commercial time recording devices and systems log and store single "events" not visits. I think I've still got something like this stored away somewhere in Access ( it imported a text file which was dumped by just such a commercial system. I'll try to locate it. On 22 Sep 2008 at 13:29, Arthur Fuller wrote: > As Steve suggests, a cursor appears to be the way out of this, but I believe > that this is because the model is wrong. In-to-out ought to be on one row > not two. Then the problem erases itself. This approach might require some > additional logic but in general, IMO, it is sound: > > Location1: In = 9:00am > Location2: In = not permitted before Location1.Out is not null > Location2: In >= Location1.Out > > My gut instinct tells me that it is a bad idea to store In and Out on > separate rows. The concept ought to be rethought as a > "Visit" which has an In time and an Out time.Then everything you need to > know is on one single row and it's easy to grab and the duration is a cinch > to calculate. > > Just my $0.02 > > Arthur > > On Mon, Sep 22, 2008 at 12:08 PM, Steve Erbach wrote: > > > Are we talking about using a SQL Cursor here? > > > > Steve Erbach > > Neenah, WI > > > > On Mon, Sep 22, 2008 at 9:33 AM, Steve Erbach wrote: > > > Dear Group, > > > > > > I wrote an upgrade to the classic ASP In/Out board my company uses in > > > ASP.NET . The security cards we all have allow us > > access to the > > > building and the In/Out times are recorded in a SQL table. > > > > > > I wonder if you could help me visualize a query that would total up > > > the elapsed time IN for an employee over a defined period of time, > > > say, from Monday at 12:01 AM to now. > > > > > > The table, AccessEvents, contains these main fields: > > > > > > EmployeeID > > > TimeStamp > > > AreaCode > > > > > > The AreaCode contains either the area of the building that the > > > employee entered upon coming in, or the "outside", meaning that the > > > employee is out of the building. > > > > > > Say that it's Thursday and the employee's AccessEvents records look > > > like the following (I've changed the AreaCode to In or Out for > > > simplicity): > > > > > > 337 2008-09-15 07:54:50.000 In > > > 337 2008-09-15 11:59:56.000 Out > > > 337 2008-09-15 12:38:24.000 In > > > 337 2008-09-15 17:01:24.000 Out > > > 337 2008-09-16 07:53:16.000 In > > > 337 2008-09-16 11:58:00.000 Out > > > 337 2008-09-16 12:33:35.000 In > > > 337 2008-09-16 17:03:29.000 Out > > > 337 2008-09-17 07:56:29.000 In > > > 337 2008-09-17 11:59:14.000 Out > > > 337 2008-09-17 12:49:41.000 In > > > 337 2008-09-17 17:02:41.000 Out > > > 337 2008-09-18 08:04:17.000 In > > > > > > ...and the employee wants to know how much time he's spent in the > > > building up to now, which is, say, 10:00AM on Thursday the 18th of > > > Sept. It's easy enough to select these records, but I'm having > > > trouble visualizing how to sum the elapsed time spent IN the building, > > > including the time from his last In event to 10:00. > > > > > > Any ideas? > > > > > > Regards, > > > > > > Steve Erbach > > > Neenah, WI > > _______________________________________________ > > 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 jnatola at hotmail.com Mon Sep 22 12:54:59 2008 From: jnatola at hotmail.com (jean-paul) Date: Mon, 22 Sep 2008 13:54:59 -0400 Subject: [dba-SQLServer] Create error Message-ID: Hi all, Please bear with me as Im new to SQL , ;m having an issue with creating a DB i just installed windows 2003 r2 and sql05 the install went well no errors etc.. I have changed the default locations for the DB's to E: for Tlogs and F: for the DB I'm using windows authentication , my user account is both domain admin and local admin on the server - its not a DC- and I'm not on compressed drives The issue when I try to create a database I get the following; Create failed for database 'test1' (Microsoft.SqlServer.Smo) An exception occurred while executing a Transact-SQL statement or batch Directory lookup for the file e:\SQL_DBs\test1.mdf" failed with the operating system error 2 (the system cannot find the file specified CREATE DATABSASE failed. Some file names listed could not be created. Check realted errors (Microsoft SQL Server, Error: 5133) TIA J _________________________________________________________________ See how Windows connects the people, information, and fun that are part of your life. http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/ From markamatte at hotmail.com Mon Sep 22 12:58:57 2008 From: markamatte at hotmail.com (Mark A Matte) Date: Mon, 22 Sep 2008 17:58:57 +0000 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: <48D85BBD.29522.CD688BB@stuart.lexacorp.com.pg> References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com>, <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com>, <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> <48D85BBD.29522.CD688BB@stuart.lexacorp.com.pg> Message-ID: Steve, I think this will get you to having your times in a single record...I'm sure you can do the math from here. This does NOT test for missed punches/times...or whatever you are calling them. Hope it helps...Mark A. Matte SELECT MT.AgentID, MT.DTTM, MT.Direction, (SELECT Min(SM.DTTM) AS MinOfDTTM FROM tblTimes AS SM WHERE (((SM.AgentID)=MT.AgentID) AND ((SM.Direction)="out")) and (((SM.DTTM)>MT.DTTM));) AS Expr1 FROM tblTimes AS MT WHERE (((MT.Direction)="in")); > From: stuart at lexacorp.com.pg > To: dba-sqlserver at databaseadvisors.com > Date: Tue, 23 Sep 2008 03:00:13 +1000 > Subject: Re: [dba-SQLServer] Sum of elapsed time blocks > > Trouble is nost commercial time recording devices and systems log and store single > "events" not visits. > > > I think I've still got something like this stored away somewhere in Access ( it imported a text > file > which was dumped by just such a commercial system. I'll try to locate it. > > On 22 Sep 2008 at 13:29, Arthur Fuller wrote: > >> As Steve suggests, a cursor appears to be the way out of this, but I believe >> that this is because the model is wrong. In-to-out ought to be on one row >> not two. Then the problem erases itself. This approach might require some >> additional logic but in general, IMO, it is sound: >> >> Location1: In = 9:00am >> Location2: In = not permitted before Location1.Out is not null >> Location2: In>= Location1.Out >> >> My gut instinct tells me that it is a bad idea to store In and Out on >> separate rows. The concept ought to be rethought as a >> "Visit" which has an In time and an Out time.Then everything you need to >> know is on one single row and it's easy to grab and the duration is a cinch >> to calculate. >> >> Just my $0.02 >> >> Arthur >> >> On Mon, Sep 22, 2008 at 12:08 PM, Steve Erbach wrote: >> >>> Are we talking about using a SQL Cursor here? >>> >>> Steve Erbach >>> Neenah, WI >>> >>> On Mon, Sep 22, 2008 at 9:33 AM, Steve Erbach wrote: >>>> Dear Group, >>>> >>>> I wrote an upgrade to the classic ASP In/Out board my company uses in >>>> ASP.NET . The security cards we all have allow us >>> access to the >>>> building and the In/Out times are recorded in a SQL table. >>>> >>>> I wonder if you could help me visualize a query that would total up >>>> the elapsed time IN for an employee over a defined period of time, >>>> say, from Monday at 12:01 AM to now. >>>> >>>> The table, AccessEvents, contains these main fields: >>>> >>>> EmployeeID >>>> TimeStamp >>>> AreaCode >>>> >>>> The AreaCode contains either the area of the building that the >>>> employee entered upon coming in, or the "outside", meaning that the >>>> employee is out of the building. >>>> >>>> Say that it's Thursday and the employee's AccessEvents records look >>>> like the following (I've changed the AreaCode to In or Out for >>>> simplicity): >>>> >>>> 337 2008-09-15 07:54:50.000 In >>>> 337 2008-09-15 11:59:56.000 Out >>>> 337 2008-09-15 12:38:24.000 In >>>> 337 2008-09-15 17:01:24.000 Out >>>> 337 2008-09-16 07:53:16.000 In >>>> 337 2008-09-16 11:58:00.000 Out >>>> 337 2008-09-16 12:33:35.000 In >>>> 337 2008-09-16 17:03:29.000 Out >>>> 337 2008-09-17 07:56:29.000 In >>>> 337 2008-09-17 11:59:14.000 Out >>>> 337 2008-09-17 12:49:41.000 In >>>> 337 2008-09-17 17:02:41.000 Out >>>> 337 2008-09-18 08:04:17.000 In >>>> >>>> ...and the employee wants to know how much time he's spent in the >>>> building up to now, which is, say, 10:00AM on Thursday the 18th of >>>> Sept. It's easy enough to select these records, but I'm having >>>> trouble visualizing how to sum the elapsed time spent IN the building, >>>> including the time from his last In event to 10:00. >>>> >>>> Any ideas? >>>> >>>> Regards, >>>> >>>> Steve Erbach >>>> Neenah, WI >>> _______________________________________________ >>> 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 > _________________________________________________________________ Get more out of the Web. Learn 10 hidden secrets of Windows Live. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 From jnatola at hotmail.com Mon Sep 22 13:10:26 2008 From: jnatola at hotmail.com (jean-paul) Date: Mon, 22 Sep 2008 14:10:26 -0400 Subject: [dba-SQLServer] Create error In-Reply-To: References: Message-ID: well i dont know what happened , but now it is working- thanks > From: jnatola at hotmail.com > To: dba-sqlserver at databaseadvisors.com > Date: Mon, 22 Sep 2008 13:54:59 -0400 > Subject: [dba-SQLServer] Create error > > > Hi all, > > Please bear with me as Im new to SQL , > ;m having an issue with creating a DB i just installed windows 2003 r2 and sql05 the install went well no errors etc.. > > > I have changed the default locations for the DB's to E: for Tlogs and F: for the DB > > I'm using windows authentication , my user account is both domain admin and local admin on the server - its not a DC- > and I'm not on compressed drives > > > The issue when I try to create a database I get the following; > > Create failed for database 'test1' (Microsoft.SqlServer.Smo) > > An exception occurred while executing a Transact-SQL statement or batch > > Directory lookup for the file e:\SQL_DBs\test1.mdf" failed with the operating system error 2 (the system cannot find the file specified > > CREATE DATABSASE failed. Some file names listed could not be created. Check realted errors > (Microsoft SQL Server, Error: 5133) > > > > > > > TIA > > J > > > > > > > > > _________________________________________________________________ > See how Windows connects the people, information, and fun that are part of your life. > http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/ > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _________________________________________________________________ See how Windows Mobile brings your life together?at home, work, or on the go. http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/ From Darryl.Collins at coles.com.au Mon Sep 22 18:40:56 2008 From: Darryl.Collins at coles.com.au (Darryl Collins) Date: Tue, 23 Sep 2008 09:40:56 +1000 Subject: [dba-SQLServer] Create error In-Reply-To: Message-ID: <57E6E6CA42105A48B977303A2CDC2720076DA26FA6@WPEXCH22.retail.ad.cmltd.net.au> heh.. I told you these folks were good ;) -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of jean-paul Sent: Tuesday, 23 September 2008 4:10 AM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Create error well i dont know what happened , but now it is working- thanks > From: jnatola at hotmail.com > To: dba-sqlserver at databaseadvisors.com > Date: Mon, 22 Sep 2008 13:54:59 -0400 > Subject: [dba-SQLServer] Create error > > > Hi all, > > Please bear with me as Im new to SQL , > ;m having an issue with creating a DB i just installed windows 2003 r2 and sql05 the install went well no errors etc.. > > > I have changed the default locations for the DB's to E: for Tlogs and F: for the DB > > I'm using windows authentication , my user account is both domain admin and local admin on the server - its not a DC- > and I'm not on compressed drives > > > The issue when I try to create a database I get the following; > > Create failed for database 'test1' (Microsoft.SqlServer.Smo) > > An exception occurred while executing a Transact-SQL statement or batch > > Directory lookup for the file e:\SQL_DBs\test1.mdf" failed with the operating system error 2 (the system cannot find the file specified > > CREATE DATABSASE failed. Some file names listed could not be created. Check realted errors > (Microsoft SQL Server, Error: 5133) > > > > > > > TIA > > J > > > > > > > > > _________________________________________________________________ > See how Windows connects the people, information, and fun that are part of your life. > http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/ > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _________________________________________________________________ See how Windows Mobile brings your life together?at home, work, or on the go. http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/ _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses. No warranty is made that this material is free from computer virus or any other defect or error. Any loss/damage incurred by using this material is not the sender's responsibility. The sender's entire liability will be limited to resupplying the material. From erbachs at gmail.com Tue Sep 23 06:18:06 2008 From: erbachs at gmail.com (Steve Erbach) Date: Tue, 23 Sep 2008 06:18:06 -0500 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com> <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> Message-ID: <39cb22f30809230418l5db913acwcba9e793b2279874@mail.gmail.com> Arthur, ? My gut instinct tells me that it is a bad idea to store In and Out on separate rows. The concept ought to be rethought as a "Visit" which has an In time and an Out time. ? This makes sense. Unfortunately, the SQL database is part of the security card access system. I suppose that I could suggest to the manufacturer that its design could be tweaked; but, even if they have an epiphany, the design isn't likely to change soon. So I'm left with my original question. The more I look at it the more I think I'll just bypass the all-in-one query idea and just feed the result set to a .NET routine to step through the records. Thanks, Arthur. Steve Erbach Neenah, WI On Mon, Sep 22, 2008 at 11:29 AM, Arthur Fuller wrote: > As Steve suggests, a cursor appears to be the way out of this, but I believe > that this is because the model is wrong. In-to-out ought to be on one row > not two. Then the problem erases itself. This approach might require some > additional logic but in general, IMO, it is sound: > > Location1: In = 9:00am > Location2: In = not permitted before Location1.Out is not null > Location2: In >= Location1.Out > > My gut instinct tells me that it is a bad idea to store In and Out on > separate rows. The concept ought to be rethought as a > "Visit" which has an In time and an Out time.Then everything you need to > know is on one single row and it's easy to grab and the duration is a cinch > to calculate. > > Just my $0.02 > > Arthur > From erbachs at gmail.com Tue Sep 23 06:19:03 2008 From: erbachs at gmail.com (Steve Erbach) Date: Tue, 23 Sep 2008 06:19:03 -0500 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: <48D85BBD.29522.CD688BB@stuart.lexacorp.com.pg> References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com> <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> <48D85BBD.29522.CD688BB@stuart.lexacorp.com.pg> Message-ID: <39cb22f30809230419j4dcfba76n85147edf61316b0c@mail.gmail.com> Stuart, Right you are. Thanks for looking through your archives. Steve Erbach Neenah, WI On Mon, Sep 22, 2008 at 12:00 PM, Stuart McLachlan wrote: > Trouble is nost commercial time recording devices and systems log and store single > "events" not visits. > > > I think I've still got something like this stored away somewhere in Access ( it imported a text > file > which was dumped by just such a commercial system. I'll try to locate it. From fuller.artful at gmail.com Tue Sep 23 10:51:06 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 23 Sep 2008 12:51:06 -0300 Subject: [dba-SQLServer] Logical reads/writes Message-ID: <29f585dd0809230851x506d1db6q145b2970d8bbad01@mail.gmail.com> I suppose that I should know what these terms mean, but the fact is that I don't. I'm looking at this report of object execution times from SQL 2005 and there are columns about logical reads and writes and I have no idea what that means. Logical as opposed to physical, or as opposed to illogical? Oh and then there is Total Logical IO. That would be a really funny graph if they had Illogical Reads and Writes LOL. It's time to Google, I guess. Arthur From erbachs at gmail.com Tue Sep 23 11:46:14 2008 From: erbachs at gmail.com (Steve Erbach) Date: Tue, 23 Sep 2008 11:46:14 -0500 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com> <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> <48D85BBD.29522.CD688BB@stuart.lexacorp.com.pg> Message-ID: <39cb22f30809230946k6d5cabb7k646faa222e6bc3e9@mail.gmail.com> Mark, Your query does, indeed, work. I think, however, that I'm going to go with the .NET loop-through-the-records idea because of query performance. I restricted the query results to the In/Out records for one guy starting with Monday, Sep. 15th. The query produced the correct result but it takes 11 to 17 seconds (!!??) to fetch the records from the SQL Server. It's cool that SQL Server can do this much with one query, but man! There are already 1.4 million records in the In/Out table and building indexes is a bit of a chore. I've suggested that some additional clustered indexes be built for that table, but not action so far. Thank you for posting that query. Steve Erbach Neenah, WI On Mon, Sep 22, 2008 at 12:58 PM, Mark A Matte wrote: > > Steve, > > I think this will get you to having your times in a single record...I'm sure you can do the math from here. This does NOT test for missed punches/times...or whatever you are calling them. > > Hope it helps...Mark A. Matte > > SELECT MT.AgentID, MT.DTTM, MT.Direction, (SELECT Min(SM.DTTM) AS MinOfDTTM > FROM tblTimes AS SM > WHERE (((SM.AgentID)=MT.AgentID) AND ((SM.Direction)="out")) > and (((SM.DTTM)>MT.DTTM));) AS Expr1 > FROM tblTimes AS MT > WHERE (((MT.Direction)="in")); > > >> From: stuart at lexacorp.com.pg >> To: dba-sqlserver at databaseadvisors.com >> Date: Tue, 23 Sep 2008 03:00:13 +1000 >> Subject: Re: [dba-SQLServer] Sum of elapsed time blocks >> >> Trouble is nost commercial time recording devices and systems log and store single >> "events" not visits. From fuller.artful at gmail.com Tue Sep 23 11:54:46 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 23 Sep 2008 13:54:46 -0300 Subject: [dba-SQLServer] Script a Database to Message-ID: <29f585dd0809230954t5eb0274esc205555b01fee06e@mail.gmail.com> Several questions in one message here.... Is there a way to script all objects in a database all at once, or must it be one at a time? For a db with a few hundred tables and let's say 4 sprocs per table and a bunch of UDFs etc., this could get tedious very quickly. (I am using SQL 2005 on this project.) I want to version everything and stick it all into Subversion, but one by one, this is going to take Days of uninterruped excitement! Sheesh. How does one script the logins and permissions and jobs? I know how to do them individually but it appears it cannot be done en masse. Or maybe I'm missing something. The final question is, does one have to go to a third party to generate a script that will do all the inserts necessary to populate some or all the tables? I have used dbScripter in the past for this, but I left my copy on my computer in Canada. TIA, Arthur From robert at webedb.com Tue Sep 23 12:49:14 2008 From: robert at webedb.com (Robert L. Stewart) Date: Tue, 23 Sep 2008 12:49:14 -0500 Subject: [dba-SQLServer] Script a Database to In-Reply-To: References: Message-ID: <200809231752.m8NHqgon016799@databaseadvisors.com> Why would it do it into subversion any way other than one file? You can add all of them at one time to the repository from your local copy. I believe there is an option to script the logins or users. Jobs would be one at a time. I write a view for each table that gives me the insert script for the data for each table. Permissions can be scripted at the same time as the object from Mgt Studio. Robert At 12:00 PM 9/23/2008, you wrote: >Date: Tue, 23 Sep 2008 13:54:46 -0300 >From: "Arthur Fuller" >Subject: [dba-SQLServer] Script a Database to >To: "Discussion concerning MS SQL Server" > >Message-ID: > <29f585dd0809230954t5eb0274esc205555b01fee06e at mail.gmail.com> >Content-Type: text/plain; charset=ISO-8859-1 > >Several questions in one message here.... > >Is there a way to script all objects in a database all at once, or must it >be one at a time? For a db with a few hundred tables and let's say 4 sprocs >per table and a bunch of UDFs etc., this could get tedious very quickly. (I >am using SQL 2005 on this project.) I want to version everything and stick >it all into Subversion, but one by one, this is going to take Days of >uninterruped excitement! Sheesh. > >How does one script the logins and permissions and jobs? I know how to do >them individually but it appears it cannot be done en masse. Or maybe I'm >missing something. > >The final question is, does one have to go to a third party to generate a >script that will do all the inserts necessary to populate some or all the >tables? I have used dbScripter in the past for this, but I left my copy on >my computer in Canada. > >TIA, >Arthur From erbachs at gmail.com Tue Sep 23 16:30:29 2008 From: erbachs at gmail.com (Steve Erbach) Date: Tue, 23 Sep 2008 16:30:29 -0500 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com> <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> <48D85BBD.29522.CD688BB@stuart.lexacorp.com.pg> Message-ID: <39cb22f30809231430p32f8aa7ajcfdffc552497af7f@mail.gmail.com> Mark, I kept working at the query you sent me and I looked up ideas in Joe Celko's book, "SQL for Smarties". As I said earlier today, the "raw" query took 11-17 seconds to run because the table it queries contains 1.4 million rows and the self-join has to run quite a few times and indexes have to be built, etc. So I built a couple temp tables first. The following routine assumes that there is a one-to-one match between "In" and "Out" records (except for the most recent "In" record). It executes lickety-split: SELECT EmployeeID, [TimeStamp], AreaCode INTO [_TempIn] FROM AccessEvents WHERE EmployeeID = 337 AND [TimeStamp] > CONVERT(datetime, '9/15/2008') AND AreaCode = 'In'; SELECT EmployeeID, [TimeStamp], AreaCode INTO [_TempOut] FROM AccessEvents WHERE EmployeeID = 337 AND [TimeStamp] > CONVERT(datetime, '9/15/2008') AND AreaCode = 'Out'; SELECT I.EmployeeID, I.[TimeStamp] AS TimeIn, ( SELECT Min(O.[TimeStamp]) AS TimeOut FROM [_TempOut] AS O WHERE ( (O.EmployeeID = I.EmployeeID) AND (O.[TimeStamp] > I.[TimeStamp]) ) ) AS TimeOut FROM [_TempIn] AS I ORDER BY I.[TimeStamp]; DROP TABLE [SteveErbach].[_TempIn]; DROP TABLE [SteveErbach].[_TempOut]; Thanks for the original query and the idea. Steve Erbach Neenah, WI On Mon, Sep 22, 2008 at 12:58 PM, Mark A Matte wrote: > > Steve, > > I think this will get you to having your times in a single record...I'm sure you can do the math from here. This does NOT test for missed punches/times...or whatever you are calling them. > > Hope it helps...Mark A. Matte > > SELECT MT.AgentID, MT.DTTM, MT.Direction, (SELECT Min(SM.DTTM) AS MinOfDTTM > FROM tblTimes AS SM > WHERE (((SM.AgentID)=MT.AgentID) AND ((SM.Direction)="out")) > and (((SM.DTTM)>MT.DTTM));) AS Expr1 > FROM tblTimes AS MT > WHERE (((MT.Direction)="in")); > From markamatte at hotmail.com Wed Sep 24 09:49:41 2008 From: markamatte at hotmail.com (Mark A Matte) Date: Wed, 24 Sep 2008 14:49:41 +0000 Subject: [dba-SQLServer] Sum of elapsed time blocks In-Reply-To: <39cb22f30809231430p32f8aa7ajcfdffc552497af7f@mail.gmail.com> References: <39cb22f30809220733m11e60c43p5fa1236a2c9407a2@mail.gmail.com> <39cb22f30809220808y46ef7258pa72407a63603517b@mail.gmail.com> <29f585dd0809220929p623df7f6h696ee603a04e2470@mail.gmail.com> <48D85BBD.29522.CD688BB@stuart.lexacorp.com.pg> <39cb22f30809231430p32f8aa7ajcfdffc552497af7f@mail.gmail.com> Message-ID: Glad I could help. Mark > Date: Tue, 23 Sep 2008 16:30:29 -0500 > From: erbachs at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] Sum of elapsed time blocks > > Mark, > > I kept working at the query you sent me and I looked up ideas in Joe > Celko's book, "SQL for Smarties". As I said earlier today, the "raw" > query took 11-17 seconds to run because the table it queries contains > 1.4 million rows and the self-join has to run quite a few times and > indexes have to be built, etc. > > So I built a couple temp tables first. The following routine assumes > that there is a one-to-one match between "In" and "Out" records > (except for the most recent "In" record). It executes lickety-split: > > SELECT > EmployeeID, > [TimeStamp], > AreaCode > INTO [_TempIn] > FROM AccessEvents > WHERE EmployeeID = 337 AND > [TimeStamp]> CONVERT(datetime, '9/15/2008') AND > AreaCode = 'In'; > > SELECT > EmployeeID, > [TimeStamp], > AreaCode > INTO [_TempOut] > FROM AccessEvents > WHERE EmployeeID = 337 AND > [TimeStamp]> CONVERT(datetime, '9/15/2008') AND > AreaCode = 'Out'; > > SELECT > I.EmployeeID, > I.[TimeStamp] AS TimeIn, > ( > SELECT > Min(O.[TimeStamp]) AS TimeOut > FROM [_TempOut] AS O > WHERE > ( > (O.EmployeeID = I.EmployeeID) AND > (O.[TimeStamp]> I.[TimeStamp]) > ) > ) AS TimeOut > FROM [_TempIn] AS I > ORDER BY I.[TimeStamp]; > > DROP TABLE [SteveErbach].[_TempIn]; > DROP TABLE [SteveErbach].[_TempOut]; > > Thanks for the original query and the idea. > > Steve Erbach > Neenah, WI > > On Mon, Sep 22, 2008 at 12:58 PM, Mark A Matte wrote: >> >> Steve, >> >> I think this will get you to having your times in a single record...I'm sure you can do the math from here. This does NOT test for missed punches/times...or whatever you are calling them. >> >> Hope it helps...Mark A. Matte >> >> SELECT MT.AgentID, MT.DTTM, MT.Direction, (SELECT Min(SM.DTTM) AS MinOfDTTM >> FROM tblTimes AS SM >> WHERE (((SM.AgentID)=MT.AgentID) AND ((SM.Direction)="out")) >> and (((SM.DTTM)>MT.DTTM));) AS Expr1 >> FROM tblTimes AS MT >> WHERE (((MT.Direction)="in")); >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _________________________________________________________________ Want to do more with Windows Live? Learn ?10 hidden secrets? from Jamie. http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 From robert at webedb.com Wed Sep 24 12:43:45 2008 From: robert at webedb.com (Robert L. Stewart) Date: Wed, 24 Sep 2008 12:43:45 -0500 Subject: [dba-SQLServer] Script a Database to In-Reply-To: References: Message-ID: <200809241744.m8OHift5019889@databaseadvisors.com> Why would it do it into subversion any way other than one file? Should have read Why would it do it into subversion any way other than multiple files? At 12:00 PM 9/24/2008, you wrote: >Date: Tue, 23 Sep 2008 12:49:14 -0500 >From: "Robert L. Stewart" >Subject: Re: [dba-SQLServer] Script a Database to >To: dba-sqlserver at databaseadvisors.com >Message-ID: <200809231752.m8NHqgon016799 at databaseadvisors.com> >Content-Type: text/plain; charset="us-ascii"; format=flowed > >Why would it do it into subversion any way other than one file? >You can add all of them at one time to the repository from your local copy. > >I believe there is an option to script the logins or users. > >Jobs would be one at a time. > >I write a view for each table that gives me the insert script for the >data for each table. > >Permissions can be scripted at the same time as the object from Mgt Studio. > >Robert From fuller.artful at gmail.com Fri Sep 26 12:09:25 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Fri, 26 Sep 2008 14:09:25 -0300 Subject: [dba-SQLServer] Automatic drop of everything related to a table Message-ID: <29f585dd0809261009g310bd257u940e5ecfe8998bfe@mail.gmail.com> When you drop a table, do all related objects automatically get dropped as well? By "related objects" I don't mean related tables, but rather constraints, triggers, indexes and so on. Does dropping a table automatically kill all this stuff, or do remnants persist, and if the latter, is there some systematic way of killing all the remnants when I kill the table? You might wonder why I want to do this. I'd tell you but then I'd have to kill you. (It's Friday. so I may let you live until Monday.) A. From Darryl.Collins at coles.com.au Sat Sep 27 19:28:50 2008 From: Darryl.Collins at coles.com.au (Darryl Collins) Date: Sun, 28 Sep 2008 10:28:50 +1000 Subject: [dba-SQLServer] SPROC Help SELECT and INSERT. In-Reply-To: <29f585dd0809261009g310bd257u940e5ecfe8998bfe@mail.gmail.com> Message-ID: <57E6E6CA42105A48B977303A2CDC2720076DA26FE5@WPEXCH22.retail.ad.cmltd.net.au> Hi guys and gals, A bit of advice if you don't mind. Trying to write a SPROC and know this should be easy and I think I am making it way too complicated. I have data in one table and want to copy and insert into another table (identical fields pretty much). So for each example tblSource '------------------- SourceKeyID (PK) Alpha Beta Gamma FYP Prog so: SQL would be SELECT * FROM tblSource WHERE FYP = @FYP AND Prog = @Prog or maybe SELECT SourceKeyID, Alpha, Beta, Gamma, FYP, Prog FROM tblSource WHERE FYP = @FYP AND Prog = @Prog Then I want to insert it in to the tblTarget table. tblTarget '------------------- TargetKeyID ' Auto generated FYP_Imported ' Needs to be written as a variable (eg 75) SourceKeyID (FK) ' The following all come from the source table Alpha Beta Gamma FYP Prog Something like INSERT INTO tblTarget FYP_Imported = @FYP_imported SourceKeyID, Alpha, Beta, Gamma, FYP, Prog . Anyway, I can't seem to get it to work so I am clearly fouling something up *sigh* any advice? cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller Sent: Saturday, 27 September 2008 3:09 AM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] Automatic drop of everything related to a table When you drop a table, do all related objects automatically get dropped as well? By "related objects" I don't mean related tables, but rather constraints, triggers, indexes and so on. Does dropping a table automatically kill all this stuff, or do remnants persist, and if the latter, is there some systematic way of killing all the remnants when I kill the table? You might wonder why I want to do this. I'd tell you but then I'd have to kill you. (It's Friday. so I may let you live until Monday.) A. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses. No warranty is made that this material is free from computer virus or any other defect or error. Any loss/damage incurred by using this material is not the sender's responsibility. The sender's entire liability will be limited to resupplying the material. From ab-mi at post3.tele.dk Sun Sep 28 14:59:48 2008 From: ab-mi at post3.tele.dk (Asger Blond) Date: Sun, 28 Sep 2008 21:59:48 +0200 Subject: [dba-SQLServer] SPROC Help SELECT and INSERT. In-Reply-To: <57E6E6CA42105A48B977303A2CDC2720076DA26FE5@WPEXCH22.retail.ad.cmltd.net.au> Message-ID: <000001c921a4$d90beb80$2101a8c0@AB> Darryl, This may be what you need: INSERT INTO tblTarget (FYP_Imported, SourceKeyID, Alpha, Beta, Gamma, FYP, Prog) SELECT @FYP_imported, SourceKeyID, Alpha, Beta, Gamma, FYP, Prog FROM tblSOURCE WHERE FYP = @FYP AND Prog = @Prog Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Darryl Collins Sendt: 28. september 2008 02:29 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] SPROC Help SELECT and INSERT. Hi guys and gals, A bit of advice if you don't mind. Trying to write a SPROC and know this should be easy and I think I am making it way too complicated. I have data in one table and want to copy and insert into another table (identical fields pretty much). So for each example tblSource '------------------- SourceKeyID (PK) Alpha Beta Gamma FYP Prog so: SQL would be SELECT * FROM tblSource WHERE FYP = @FYP AND Prog = @Prog or maybe SELECT SourceKeyID, Alpha, Beta, Gamma, FYP, Prog FROM tblSource WHERE FYP = @FYP AND Prog = @Prog Then I want to insert it in to the tblTarget table. tblTarget '------------------- TargetKeyID ' Auto generated FYP_Imported ' Needs to be written as a variable (eg 75) SourceKeyID (FK) ' The following all come from the source table Alpha Beta Gamma FYP Prog Something like INSERT INTO tblTarget FYP_Imported = @FYP_imported SourceKeyID, Alpha, Beta, Gamma, FYP, Prog . Anyway, I can't seem to get it to work so I am clearly fouling something up *sigh* any advice? cheers Darryl. From Darryl.Collins at coles.com.au Sun Sep 28 21:30:17 2008 From: Darryl.Collins at coles.com.au (Darryl Collins) Date: Mon, 29 Sep 2008 12:30:17 +1000 Subject: [dba-SQLServer] SPROC Help SELECT and INSERT. In-Reply-To: <000001c921a4$d90beb80$2101a8c0@AB> Message-ID: <57E6E6CA42105A48B977303A2CDC2720076DA26FE7@WPEXCH22.retail.ad.cmltd.net.au> Thanks Asger, I have this working great now. For the archives here is the whole thing. Lesson learnt was that the INSERT statement needs () and the SELECT statement does not. '================================================== if exists (select * from dbo.sysobjects where id = object_id(N'dbo.stprSubmitForecast') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure dbo.stprSubmitForecast GO SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO /* Name : stprSubmitForecast Description : Update/Submit the forecast data from the Live table to the Archive Table Revision History : 2008-10-17 Darryl Collins - Created */ CREATE PROCEDURE dbo.stprSubmitForecast @UCFYPID Int, @APLID Int AS SET NOCOUNT ON DELETE FROM dbo.ITFCT_tblForecastSubmitted WHERE FYPID_Submitted = @UCFYPID AND APLID = @APLID INSERT INTO dbo.ITFCT_tblForecastSubmitted (FYPID_Submitted, ForecastID, ForecastLinkID, IsCurrent, ProductCode, ProjectCode, SkillGroup, Component, ResourceOrItem, Organisation, OrgAlias, StandardTaskID, StandardTaskAdd, MECID, SpendTypeID, AccTreatmentID, AccountingSplit, EffortDays, EffortRate, [ValueAUD], ValueOpex, ValueCapex, FYPID, [Comments], ForecastStatusID, APLID) SELECT @UCFYPID, ForecastID, ForecastLinkID, IsCurrent, ProductCode, ProjectCode, SkillGroup, Component, ResourceOrItem, Organisation, OrgAlias, StandardTaskID, StandardTaskAdd, MECID, SpendTypeID, AccTreatmentID, AccountingSplit, EffortDays, EffortRate, [ValueAUD], ValueOpex, ValueCapex, FYPID, [Comments], ForecastStatusID, APLID FROM dbo.ITFCT_tblForecastLive WHERE FYPID = (@UCFYPID+1) AND APLID = @APLID AND IsCurrent <> 0 SELECT 0 AS Result GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO '============================================================ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Asger Blond Sent: Monday, 29 September 2008 6:00 AM To: 'Discussion concerning MS SQL Server' Subject: Re: [dba-SQLServer] SPROC Help SELECT and INSERT. Darryl, This may be what you need: INSERT INTO tblTarget (FYP_Imported, SourceKeyID, Alpha, Beta, Gamma, FYP, Prog) SELECT @FYP_imported, SourceKeyID, Alpha, Beta, Gamma, FYP, Prog FROM tblSOURCE WHERE FYP = @FYP AND Prog = @Prog Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Darryl Collins Sendt: 28. september 2008 02:29 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] SPROC Help SELECT and INSERT. Hi guys and gals, A bit of advice if you don't mind. Trying to write a SPROC and know this should be easy and I think I am making it way too complicated. I have data in one table and want to copy and insert into another table (identical fields pretty much). So for each example tblSource '------------------- SourceKeyID (PK) Alpha Beta Gamma FYP Prog so: SQL would be SELECT * FROM tblSource WHERE FYP = @FYP AND Prog = @Prog or maybe SELECT SourceKeyID, Alpha, Beta, Gamma, FYP, Prog FROM tblSource WHERE FYP = @FYP AND Prog = @Prog Then I want to insert it in to the tblTarget table. tblTarget '------------------- TargetKeyID ' Auto generated FYP_Imported ' Needs to be written as a variable (eg 75) SourceKeyID (FK) ' The following all come from the source table Alpha Beta Gamma FYP Prog Something like INSERT INTO tblTarget FYP_Imported = @FYP_imported SourceKeyID, Alpha, Beta, Gamma, FYP, Prog . Anyway, I can't seem to get it to work so I am clearly fouling something up *sigh* any advice? cheers Darryl. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses. No warranty is made that this material is free from computer virus or any other defect or error. Any loss/damage incurred by using this material is not the sender's responsibility. The sender's entire liability will be limited to resupplying the material. From fuller.artful at gmail.com Tue Sep 30 09:15:07 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 30 Sep 2008 11:15:07 -0300 Subject: [dba-SQLServer] Insufficient information about deadlocks Message-ID: <29f585dd0809300715t2347d9beifd3272593393a072@mail.gmail.com> We occasionally get deadlocks reported from our error handler in a particular sproc. What mystifies me is that this sproc is simply doing a select from a few tables, based on two IDs. I can't pin it down. I know that this procedure was the victim but I don't know who the victor was. How can I track this down? Thanks, Arthur From davidmcafee at gmail.com Tue Sep 30 11:58:12 2008 From: davidmcafee at gmail.com (David McAfee) Date: Tue, 30 Sep 2008 09:58:12 -0700 Subject: [dba-SQLServer] Insufficient information about deadlocks In-Reply-To: <29f585dd0809300715t2347d9beifd3272593393a072@mail.gmail.com> References: <29f585dd0809300715t2347d9beifd3272593393a072@mail.gmail.com> Message-ID: <8786a4c00809300958r3a20a11p165f36daaa12b3ea@mail.gmail.com> Arthur do you select using nolock? I try to make it a habit when selecting Snapshot type recordsets. SELECT SomeFields FROM sometable WITH (NOLOCK) WHERE pkid = @SomeID On Tue, Sep 30, 2008 at 7:15 AM, Arthur Fuller wrote: > We occasionally get deadlocks reported from our error handler in a > particular sproc. What mystifies me is that this sproc is simply doing a > select from a few tables, based on two IDs. I can't pin it down. I know > that > this procedure was the victim but I don't know who the victor was. How can > I > track this down? > > Thanks, > Arthur > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fuller.artful at gmail.com Tue Sep 30 14:00:28 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 30 Sep 2008 16:00:28 -0300 Subject: [dba-SQLServer] Insufficient information about deadlocks In-Reply-To: <8786a4c00809300958r3a20a11p165f36daaa12b3ea@mail.gmail.com> References: <29f585dd0809300715t2347d9beifd3272593393a072@mail.gmail.com> <8786a4c00809300958r3a20a11p165f36daaa12b3ea@mail.gmail.com> Message-ID: <29f585dd0809301200g748a84f5gcf7915729c8dab9d@mail.gmail.com> Not so far but I will follow your advice and put in the new statements and see what blows up tomorrow LOL. Then I can quickly un-rem the existing statements if need be. This is the big problem with testing stuff, is that on the Prod stuff hundreds of users are whacking the db and in the testing stuff it's basically only me. Maybe this is what outsourcing is about -- find a few hundred users in third-world countries to bang on your app for a month and see what explodes. Thanks, A. On Tue, Sep 30, 2008 at 1:58 PM, David McAfee wrote: > Arthur do you select using nolock? I try to make it a habit when selecting > Snapshot type recordsets. > > SELECT SomeFields FROM sometable WITH (NOLOCK) WHERE pkid = @SomeID > > From nancy.lytle at gmail.com Tue Sep 30 14:18:42 2008 From: nancy.lytle at gmail.com (Nancy Lytle) Date: Tue, 30 Sep 2008 14:18:42 -0500 Subject: [dba-SQLServer] Insufficient information about deadlocks In-Reply-To: <29f585dd0809300715t2347d9beifd3272593393a072@mail.gmail.com> References: <29f585dd0809300715t2347d9beifd3272593393a072@mail.gmail.com> Message-ID: Check out sp_blocker_pss80.sql, I found it on the web. It gives good info on blocking and who is blocking what. There are some other ones out there but this is the one I use throughout the day to get an eye on things, or I use it when there is a complaint about slowness, etc. Nancy Lytle N_Lytle at terpalum.umd.edu EMAILING FOR THE GREATER GOODJoin me > Date: Tue, 30 Sep 2008 11:15:07 -0300> From: fuller.artful at gmail.com> To: dba-sqlserver at databaseadvisors.com> Subject: [dba-SQLServer] Insufficient information about deadlocks> > We occasionally get deadlocks reported from our error handler in a> particular sproc. What mystifies me is that this sproc is simply doing a> select from a few tables, based on two IDs. I can't pin it down. I know that> this procedure was the victim but I don't know who the victor was. How can I> track this down?> > Thanks,> Arthur> _______________________________________________> dba-SQLServer mailing list> dba-SQLServer at databaseadvisors.com> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver> http://www.databaseadvisors.com> From fuller.artful at gmail.com Tue Sep 30 15:08:13 2008 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 30 Sep 2008 17:08:13 -0300 Subject: [dba-SQLServer] Insufficient information about deadlocks In-Reply-To: References: <29f585dd0809300715t2347d9beifd3272593393a072@mail.gmail.com> Message-ID: <29f585dd0809301308q493546b5med1a3ea8e3ac43f9@mail.gmail.com> Thanks. I Googled it and got a hit but the link led nowhere. Do you have a copy that you could send me? It would be appreciated. Arthur On Tue, Sep 30, 2008 at 4:18 PM, Nancy Lytle wrote: > Check out sp_blocker_pss80.sql, I found it on the web. It gives good info > on blocking and who is blocking what. There are some other ones out there > but this is the one I use throughout the day to get an eye on things, or I > use it when there is a complaint about slowness, etc. > Nancy Lytle N_Lytle at terpalum.umd.edu > >