From jnatola at hotmail.com Thu Aug 4 15:53:56 2011 From: jnatola at hotmail.com (Jean-Paul natola) Date: Thu, 4 Aug 2011 16:53:56 -0400 Subject: [dba-SQLServer] syslock help Message-ID: Hi all, We have a user that got "locked" in some process or transaction or table, excuse the language here, the former version of the program had a syslocks utility to release anything in that type of situation, it turns out that utlity was removed and the only thing i could find to point me in the right direction was a querey i found online, SELECT * FROM master.dbo.syslockinfo here is what it output but i can really make heads or tails I know its not a lot to go on, but any pointers thoughts would be appreciated column headers are rsc_bin,rsc_valblk,rsc_dbid,rsc_indid,rsc_objid,rsc_type,_rsc_flag,req_mode,req_statu,req_refcnt,req_cryrefecnt,req_lifetime,req_spid,req_ecid,req_ownertype,req_transactionid,req_transactionUOW 0x00000000000000000000000005000200 0x00000000000000000000000000000000 5 0 0 2 0 3 1 1 0 0 53 0 4 0 00000000-0000-0000-0000-000000000000 0x00000000000000000000000005000200 0x00000000000000000000000000000000 5 0 0 2 0 3 1 1 0 0 51 0 4 0 00000000-0000-0000-0000-000000000000 0x00000000000000000000000007000200 0x00000000000000000000000000000000 7 0 0 2 0 3 1 1 0 0 56 0 4 0 00000000-0000-0000-0000-000000000000 0x00000000000000000000000007000200 0x00000000000000000000000000000000 7 0 0 2 0 3 1 1 0 0 54 0 4 0 00000000-0000-0000-0000-000000000000 0x00000000000000000000000007000200 0x00000000000000000000000000000000 7 0 0 2 0 3 1 1 0 0 52 0 4 0 00000000-0000-0000-0000-000000000000 From jwcolby at colbyconsulting.com Fri Aug 5 16:36:34 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Fri, 05 Aug 2011 17:36:34 -0400 Subject: [dba-SQLServer] Stored procedure parameters Message-ID: <4E3C6262.5090002@colbyconsulting.com> I have a form which I want to open and display a single record in. I am building a SP to pull just that one record but I have two different parameters that I can use to find the record, the PKID (an Integer) and a string "opus number". IOW I will pass one or the other but not both. Should I build a single SP with two params and just do a test internal to the SP to determine which param has a value in it? Should I build two different SPs? Should I use some third strategy? -- John W. Colby www.ColbyConsulting.com From davidmcafee at gmail.com Fri Aug 5 17:12:20 2011 From: davidmcafee at gmail.com (David McAfee) Date: Fri, 5 Aug 2011 15:12:20 -0700 Subject: [dba-SQLServer] Stored procedure parameters In-Reply-To: <4E3C6262.5090002@colbyconsulting.com> References: <4E3C6262.5090002@colbyconsulting.com> Message-ID: You can do it your way with two parameters: CREATE PROCEDURE stpJCsSproc (@PKID INT NULL, @Opus NVARCHAR(10)) AS IF ISNULL(PKID,0) <> 0 SELECT * FROM BLAH WHERE PKID = @PKID ELSE SELECT * FROM BLEH WHERE Opus = @Opus or you can do something like this CREATE PROCEDURE stpJCsSproc (@IntMode INT, @Opus NVARCHAR(20)) AS IF @IntMode = 1 --By PKID SELECT * FROM BLAH WHERE PKID = CAST(@Opus AS INT) ELSE IF @intMode = 2 --By Opus SELECT * FROM BLEH WHERE Opus = @Opus --any future more can be added here without changing input parameters --ELSE IF @intMode = 3 --By Composer -- SELECT * FROM tblMusic WHERE Composer = @Opus On Fri, Aug 5, 2011 at 2:36 PM, jwcolby wrote: > I have a form which I want to open and display a single record in. I am > building a SP to pull just that one record but I have two different > parameters that I can use to find the record, the PKID (an Integer) and a > string "opus number". IOW I will pass one or the other but not both. > > Should I build a single SP with two params and just do a test internal to > the SP to determine which param has a value in it? Should I build two > different SPs? Should I use some third strategy? > > -- > John W. Colby > www.ColbyConsulting.com > ______________________________**_________________ > dba-SQLServer mailing list > dba-SQLServer@**databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.**com > > From wilw31 at gmail.com Sun Aug 7 22:06:23 2011 From: wilw31 at gmail.com (Wil Wakely) Date: Sun, 7 Aug 2011 20:06:23 -0700 Subject: [dba-SQLServer] Delete Message-ID: Is this a correct sql statement to delete the first 5 rows (oldest dates) of a recordset for Access 2002? I'm new to SQL. strSQL1 = "DELETE FROM rs WHERE TOP 5, player=1 ORDER BY playdate ASC;" DoCmd.RunSQL strSQL1 ==wilw -- ===wil wakely sunny san diego ca From michael at ddisolutions.com.au Mon Aug 8 02:51:48 2011 From: michael at ddisolutions.com.au (Michael Maddison) Date: Mon, 8 Aug 2011 17:51:48 +1000 Subject: [dba-SQLServer] Delete References: Message-ID: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> Hi Wil, Others will probably jump in but I think you could end up deleting more than 5 rows. If there are multiple 5th top rows ie with the same date. In SQL Server you would do something like... DELETE FROM [tableName] WHERE ID IN ( SELECT TOP 5 ID FROM [tableName] WHERE [tableName]. player = 1 ORDER BY playdate ASC ) I see you are using a Access recordset. This won't work. I don't think you can run a query against a recordset. Why not just open the recordset sorted and loop 5 times deleting as you go? I'm not sure but I seem to recall you don't need to movenext if you are deleteing. Cheers Michael M -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Wil Wakely Sent: Monday, 8 August 2011 1:06 PM To: sql-dba Subject: [dba-SQLServer] Delete Is this a correct sql statement to delete the first 5 rows (oldest dates) of a recordset for Access 2002? I'm new to SQL. strSQL1 = "DELETE FROM rs WHERE TOP 5, player=1 ORDER BY playdate ASC;" DoCmd.RunSQL strSQL1 ==wilw -- ===wil wakely sunny san diego ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com ----- No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1391 / Virus Database: 1520/3820 - Release Date: 08/07/11 From marklbreen at gmail.com Mon Aug 8 03:45:40 2011 From: marklbreen at gmail.com (Mark Breen) Date: Mon, 8 Aug 2011 09:45:40 +0100 Subject: [dba-SQLServer] Delete In-Reply-To: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> References: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> Message-ID: Hello Michael and Wil, Wil, thanks for that, I did not know that you could use TOP n in the where clause, I only use it when I select. Michael, thanks for highlighting the potential additional records, I am looking forward to playing with TOP in where clauses, Mark On 8 August 2011 08:51, Michael Maddison wrote: > Hi Wil, > > Others will probably jump in but I think you could end up deleting more > than 5 rows. If there are multiple 5th top rows ie with the same date. > In SQL Server you would do something like... > DELETE FROM [tableName] > WHERE ID IN ( SELECT TOP 5 ID FROM [tableName] WHERE [tableName]. > player = 1 ORDER BY playdate ASC ) > > I see you are using a Access recordset. This won't work. I don't think > you can run a query against a recordset. > > Why not just open the recordset sorted and loop 5 times deleting as you > go? I'm not sure but I seem to recall you don't need to movenext if you > are deleteing. > > Cheers > > Michael M > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Wil > Wakely > Sent: Monday, 8 August 2011 1:06 PM > To: sql-dba > Subject: [dba-SQLServer] Delete > > Is this a correct sql statement to delete the first 5 rows (oldest > dates) of a recordset for Access 2002? I'm new to SQL. > > strSQL1 = "DELETE FROM rs WHERE TOP 5, player=1 ORDER BY playdate ASC;" > DoCmd.RunSQL strSQL1 > > ==wilw > > -- > ===wil wakely > sunny san diego ca > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 10.0.1391 / Virus Database: 1520/3820 - Release Date: 08/07/11 > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From dw-murphy at cox.net Mon Aug 8 11:02:41 2011 From: dw-murphy at cox.net (Doug Murphy) Date: Mon, 8 Aug 2011 09:02:41 -0700 Subject: [dba-SQLServer] Delete In-Reply-To: References: Message-ID: <002d01cc55e4$9a48aba0$ceda02e0$@cox.net> Don't know. I am more of an empirical developer. I'd try it. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Wil Wakely Sent: Sunday, August 07, 2011 8:06 PM To: sql-dba Subject: [dba-SQLServer] Delete Is this a correct sql statement to delete the first 5 rows (oldest dates) of a recordset for Access 2002? I'm new to SQL. strSQL1 = "DELETE FROM rs WHERE TOP 5, player=1 ORDER BY playdate ASC;" DoCmd.RunSQL strSQL1 ==wilw -- ===wil wakely sunny san diego ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From wilw31 at gmail.com Mon Aug 8 12:47:44 2011 From: wilw31 at gmail.com (Wil Wakely) Date: Mon, 8 Aug 2011 10:47:44 -0700 Subject: [dba-SQLServer] Delete In-Reply-To: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> References: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> Message-ID: Thanks for reply, MIchael. >Why not just open the recordset sorted and loop 5 times deleting as you go? I'm not sure but I seem to recall you don't need to movenext if you are deleteing. Like this? 'select rs and order by date strsql1 = "SELECT * FROM rs WHERE player=1 ORDER BY playdate ASC DoCmd.runsql strsql1 rs.movefirst for n = 1 to 5 rs.delete next n rs.update Woops! I just read that a snapshot RS cannot be edited. I don't want to modify the underlying table so I used snapshot rs. Is there another way to play with the data in the table without modifying the underlying table? -- ===wil wakely sunny san diego ca From michael at ddisolutions.com.au Tue Aug 9 02:20:09 2011 From: michael at ddisolutions.com.au (Michael Maddison) Date: Tue, 9 Aug 2011 17:20:09 +1000 Subject: [dba-SQLServer] Delete References: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> Message-ID: <99266C61B516644D9727F983FAFAB465086727@remote.ddisolutions.com.au> Ok, the plot thickens :-) So you only want to remove the rows from the recordset not the underlying data? To disconnect the ADO recordset from the database you set the connection to nothing, after loading the recordset. You will have to trial and error to see what type of recordset you need, snapshot won't work as you have discovered. I havn't used access as a FE for years so others might want to chip in??? Cheers Michael M -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Wil Wakely Sent: Tuesday, 9 August 2011 3:48 AM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Delete Thanks for reply, MIchael. >Why not just open the recordset sorted and loop 5 times deleting as you go? I'm not sure but I seem to recall you don't need to movenext if you are deleteing. Like this? 'select rs and order by date strsql1 = "SELECT * FROM rs WHERE player=1 ORDER BY playdate ASC DoCmd.runsql strsql1 rs.movefirst for n = 1 to 5 rs.delete next n rs.update Woops! I just read that a snapshot RS cannot be edited. I don't want to modify the underlying table so I used snapshot rs. Is there another way to play with the data in the table without modifying the underlying table? -- ===wil wakely sunny san diego ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com ----- No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1391 / Virus Database: 1520/3820 - Release Date: 08/07/11 From lawhonac at hiwaay.net Tue Aug 16 04:47:49 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Tue, 16 Aug 2011 04:47:49 -0500 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites Message-ID: <000501cc5bf9$8f8b30f0$aea192d0$@net> This is my first post to the dba-sqlserver list, (and I am a total "noobie" to SQL Server), so I hope no one will consider this a dumb question. I have decided to study for and pursue certification in Microsoft's SQL Server 2008 R2 database platform. My previous work experience was primarily in Access development with some Visual Basic coding. I have virtually no SQL Server experience. Thanks to a recommendation from Susan Harkins, I plan to download and install SQL Server 2008 R2 (the free "Express" edition) and learn all I can using that tool along with books and study guides. My initial plan is to study for (and pass) exam 70-432, "TS: Microsoft SQL Server 2008, Implementation and Maintenance," followed by exams 70-433 and 70-448. (After obtaining those three certifications, hopefully I can find a job because poverty sucks!) One of the first resources I have discovered is Microsoft's online eBook "Introducing Microsoft SQL Server 2008 R2" by Ross Mistry and Stacia Misner. In chapter 1 of Ross and Stacia's book, (i.e. "SQL Server 2008 R2 Editions and Enhancements"), under subsection "SQL Server 2008 R2 Enhancements for DBAs," the following quotation appears in the final sentence of the second paragraph on page 3: Enhancements to scalability and performance, high availability, enterprise security, enterprise manageability, data warehousing, reporting, self-service BI, collaboration, and tight integration with Microsoft Visual Studio 2010, Microsoft SharePoint 2010, and SQL Server PowerPivot for SharePoint make it the best database platform available. My question concerns the three Microsoft products mentioned in that sentence, specifically "Microsoft Visual Studio 2010, Microsoft SharePoint 2010, and SQL Server PowerPivot for SharePoint." Is knowledge and experience with these three products taken for granted - an assumed prerequisite - prior to pursuing a SQL Server certification? (I have no knowledge or experience with any of these three products - I don't even know what SharePoint is - or what SharePoint does.) As far as PowerPivot is concerned, I think that has something to do with Excel spreadsheets. My prior experience with Excel was limited to converting (and copying over) spreadsheet data to Access tables. Is a detailed knowledge of these three Microsoft technologies required (or assumed) as a prerequisite to pursuing a SQL Server certification? TIA. (I suspect this is going to be the first of many questions.) Alan C. Lawhon From stuart at lexacorp.com.pg Tue Aug 16 06:56:36 2011 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Tue, 16 Aug 2011 21:56:36 +1000 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: <000501cc5bf9$8f8b30f0$aea192d0$@net> References: <000501cc5bf9$8f8b30f0$aea192d0$@net> Message-ID: <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> Hi Alan, Nice to see you over on this list. SQL Server is a Database Management System. It is generally used as the back-end to some sort of front end application. You can use anything you like for the front end. A number here and on the VB List use Visual Studio but it is not the only thing to use ( I stopped using VS years ago). Sharepoint is used by a small minority of SQL users. Forget about Excel, PowerPivot has nothing to do with that application. At this stage, you would probably be best off sticking to Access as the front end with ODBC linked tables and PassThrough Queries to stored procedures in SQL Server. You get your head around the fundamentals of tables, triggers, SQL and stored procedures, how user permissions work, how backups work, how import and export works. They are the key components of managing SQL Server. Then you can look at other front ends if required. Many DBAs (Database Administrators) don't get involved in front end application development at all - they just manage the back end and leave it up to others to use the data in real-world applications. -- Stuart On 16 Aug 2011 at 4:47, Alan Lawhon wrote: > > My question concerns the three Microsoft products mentioned in that > sentence, specifically "Microsoft Visual Studio 2010, Microsoft > SharePoint 2010, and SQL Server PowerPivot for SharePoint." Is > knowledge and experience with these three products taken for granted - > an assumed prerequisite - prior to pursuing a SQL Server > certification? (I have no knowledge or experience with any of these > three products - I don't even know what SharePoint is - or what > SharePoint does.) As far as PowerPivot is concerned, I think that has > something to do with Excel spreadsheets. My prior experience with > Excel was limited to converting (and copying over) spreadsheet data to > Access tables. Is a detailed knowledge of these three Microsoft > technologies required (or assumed) as a prerequisite to pursuing a SQL > Server certification? > > TIA. (I suspect this is going to be the first of many questions.) > > Alan C. Lawhon > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From lawhonac at hiwaay.net Tue Aug 16 09:08:52 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Tue, 16 Aug 2011 09:08:52 -0500 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> References: <000501cc5bf9$8f8b30f0$aea192d0$@net> <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> Message-ID: <000101cc5c1e$076dc370$16494a50$@net> Stuart: Thanks. This is encouraging. I vaguely remember SQL pass-through queries, ODBC, and linked tables from my Access days. I even recall playing around a bit with ADO. In my last software job, we had an Access application that was being converted to a SQL Server back end, but I left before the conversion was completed. That was over five years ago. I did get a small amount of experience with SQL Server. (I recall a GUI interface labeled "Enterprise Manager" that resembled a tree-like structure with a lot of lower-level branches - or something similar to that.) This may not be as difficult as I originally thought. From what you're describing, combined with my past experience, I should be able to pick up most of the major implementation and maintenance topics in fairly short order. According to this: http://tinyurl.com/27f4fzt blog posting by Buck Woody, there are over 40 major study areas covered in the 70-432 exam. At first glance, most of the topics - and the links to their corresponding MSDN articles - don't look familiar, but surely I've been exposed to some of this before. With determined effort, (and a little help from my friends), I believe I can master this material and ace the exam. (Thank goodness I don't have to become a SharePoint and Visual Studio expert in order to pass the exam. That's a relief!) Five years ago I turned downed an offer of a Database Administrator job in Iraq. I was worried that I might not be qualified, but I was even more worried about being surrounded by terrorists! With perfect 20/20 hindsight, I probably should have taken that job - whether I was qualified or not - and "grown" into it once I was over there. Once I've passed 70-432 and obtained my (first) certification, I feel fairly confident that I'll find a DBA job somewhere - even if it's on a remote island in the middle of the South Pacific. (It will be nice to work someplace where you can walk to work and you don't need a car.) Thanks again for the good news. I'm now even more motivated to study my butt off. Alan C. Lawhon -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Tuesday, August 16, 2011 6:57 AM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites Hi Alan, Nice to see you over on this list. SQL Server is a Database Management System. It is generally used as the back-end to some sort of front end application. You can use anything you like for the front end. A number here and on the VB List use Visual Studio but it is not the only thing to use ( I stopped using VS years ago). Sharepoint is used by a small minority of SQL users. Forget about Excel, PowerPivot has nothing to do with that application. At this stage, you would probably be best off sticking to Access as the front end with ODBC linked tables and PassThrough Queries to stored procedures in SQL Server. You get your head around the fundamentals of tables, triggers, SQL and stored procedures, how user permissions work, how backups work, how import and export works. They are the key components of managing SQL Server. Then you can look at other front ends if required. Many DBAs (Database Administrators) don't get involved in front end application development at all - they just manage the back end and leave it up to others to use the data in real-world applications. -- Stuart On 16 Aug 2011 at 4:47, Alan Lawhon wrote: > > My question concerns the three Microsoft products mentioned in that > sentence, specifically "Microsoft Visual Studio 2010, Microsoft > SharePoint 2010, and SQL Server PowerPivot for SharePoint." Is > knowledge and experience with these three products taken for granted - > an assumed prerequisite - prior to pursuing a SQL Server > certification? (I have no knowledge or experience with any of these > three products - I don't even know what SharePoint is - or what > SharePoint does.) As far as PowerPivot is concerned, I think that has > something to do with Excel spreadsheets. My prior experience with > Excel was limited to converting (and copying over) spreadsheet data to > Access tables. Is a detailed knowledge of these three Microsoft > technologies required (or assumed) as a prerequisite to pursuing a SQL > Server certification? > > TIA. (I suspect this is going to be the first of many questions.) > > Alan C. Lawhon > > > > _______________________________________________ > 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 stuart at lexacorp.com.pg Tue Aug 16 09:56:43 2011 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 17 Aug 2011 00:56:43 +1000 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: <000101cc5c1e$076dc370$16494a50$@net> References: <000501cc5bf9$8f8b30f0$aea192d0$@net>, <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg>, <000101cc5c1e$076dc370$16494a50$@net> Message-ID: <4E4A852B.24866.20250749@stuart.lexacorp.com.pg> Based on the link, that exam is purely DB Administration stuff.. After a bit of research, I'd suggest you need to work on 70-433 concurrently. See: http://www.microsoft.com/learning/en/us/Exam.aspx?ID=70-433&locale=en-us#tab2 On 16 Aug 2011 at 9:08, Alan Lawhon wrote: > Stuart: > > Thanks. This is encouraging. I vaguely remember SQL pass-through > queries, ODBC, and linked tables from my Access days. I even recall > playing around a bit with ADO. In my last software job, we had an > Access application that was being converted to a SQL Server back end, > but I left before the conversion was completed. That was over five > years ago. I did get a small amount of experience with SQL Server. > (I recall a GUI interface labeled "Enterprise Manager" that resembled > a tree-like structure with a lot of lower-level branches - or > something similar to that.) > > This may not be as difficult as I originally thought. From what > you're describing, combined with my past experience, I should be able > to pick up most of the major implementation and maintenance topics in > fairly short order. According to this: > > http://tinyurl.com/27f4fzt > > blog posting by Buck Woody, there are over 40 major study areas > covered in the 70-432 exam. At first glance, most of the topics - and > the links to their corresponding MSDN articles - don't look familiar, > but surely I've been exposed to some of this before. With determined > effort, (and a little help from my friends), I believe I can master > this material and ace the exam. (Thank goodness I don't have to > become a SharePoint and Visual Studio expert in order to pass the > exam. That's a relief!) > > Five years ago I turned downed an offer of a Database Administrator > job in Iraq. I was worried that I might not be qualified, but I was > even more worried about being surrounded by terrorists! With perfect > 20/20 hindsight, I probably should have taken that job - whether I was > qualified or not - and "grown" into it once I was over there. Once > I've passed 70-432 and obtained my (first) certification, I feel > fairly confident that I'll find a DBA job somewhere - even if it's on > a remote island in the middle of the South Pacific. (It will be nice > to work someplace where you can walk to work and you don't need a > car.) > > Thanks again for the good news. I'm now even more motivated to study > my butt off. > > Alan C. Lawhon > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > Stuart McLachlan Sent: Tuesday, August 16, 2011 6:57 AM To: Discussion > concerning MS SQL Server Subject: Re: [dba-SQLServer] Question > Concerning Microsoft SQL Server 2008 R2 Prerequisites > > Hi Alan, > > Nice to see you over on this list. > > SQL Server is a Database Management System. It is generally used as > the back-end to some sort of front end application. You can use > anything you like for the front end. A number here and on the VB List > use Visual Studio but it is not the only thing to use ( I stopped > using VS years ago). > > Sharepoint is used by a small minority of SQL users. > Forget about Excel, PowerPivot has nothing to do with that > application. > > At this stage, you would probably be best off sticking to Access as > the front end with ODBC linked tables and PassThrough Queries to > stored procedures in SQL Server. You get your head around the > fundamentals of tables, triggers, SQL and stored procedures, how user > permissions work, how backups work, how import and export works. > They are the key components of managing SQL Server. Then you can > look at other front ends if required. > > Many DBAs (Database Administrators) don't get involved in front end > application development at all - they just manage the back end and > leave it up to others to use the data in real-world applications. > > -- > Stuart > > On 16 Aug 2011 at 4:47, Alan Lawhon wrote: > > > > My question concerns the three Microsoft products mentioned in that > > sentence, specifically "Microsoft Visual Studio 2010, Microsoft > > SharePoint 2010, and SQL Server PowerPivot for SharePoint." Is > > knowledge and experience with these three products taken for granted > > - an assumed prerequisite - prior to pursuing a SQL Server > > certification? (I have no knowledge or experience with any of these > > three products - I don't even know what SharePoint is - or what > > SharePoint does.) As far as PowerPivot is concerned, I think that > > has something to do with Excel spreadsheets. My prior experience > > with Excel was limited to converting (and copying over) spreadsheet > > data to Access tables. Is a detailed knowledge of these three > > Microsoft technologies required (or assumed) as a prerequisite to > > pursuing a SQL Server certification? > > > > TIA. (I suspect this is going to be the first of many questions.) > > > > Alan C. Lawhon > > > > > > > > _______________________________________________ > > 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 garykjos at gmail.com Tue Aug 16 12:51:58 2011 From: garykjos at gmail.com (Gary Kjos) Date: Tue, 16 Aug 2011 12:51:58 -0500 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> References: <000501cc5bf9$8f8b30f0$aea192d0$@net> <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> Message-ID: Hmmmm, it is my understanding that Powerpivot is an add in for Excel 2010..... http://www.powerpivot.com/ I've seen demos of it and it is really a powerful tool for analyzing Data Warehouse type data - almost gives end users the ability to create their own data marts. But it would be outside of a SQL Server DBA kind of tool. GK On Tue, Aug 16, 2011 at 6:56 AM, Stuart McLachlan wrote: > Hi Alan, > > Nice to see you over on this list. > > SQL Server is a Database Management System. ?It is generally used as the back-end to > some sort of front end application. ?You can use anything you like for the front end. ?A > number here and on the VB List use Visual Studio but it is not the only thing to use ( I > stopped using VS years ago). > > Sharepoint is used by a small minority of SQL users. > Forget about Excel, PowerPivot has nothing to do with ?that application. > > At this stage, you would probably be best off sticking to Access as the front end with ODBC > linked tables and PassThrough Queries to stored procedures in SQL Server. ? You get your > head around the fundamentals of tables, triggers, SQL and stored procedures, how user > permissions ?work, how backups work, how import and export works. ?They are the key > components of managing SQL Server. ? Then you can look at other front ends if required. > > Many DBAs (Database Administrators) don't get involved in front end application > development at all - they just manage the back end and leave it up to others to use the data > in real-world applications. > > -- > Stuart > > On 16 Aug 2011 at 4:47, Alan Lawhon wrote: >> >> My question concerns the three Microsoft products mentioned in that >> sentence, specifically "Microsoft Visual Studio 2010, Microsoft >> SharePoint 2010, and SQL Server PowerPivot for SharePoint." ?Is >> knowledge and experience with these three products taken for granted - >> an assumed prerequisite - prior to pursuing a SQL Server >> certification? ?(I have no knowledge or experience with any of these >> three products - I don't even know what SharePoint is - or what >> SharePoint does.) ?As far as PowerPivot is concerned, I think that has >> something to do with Excel spreadsheets. ?My prior experience with >> Excel was limited to converting (and copying over) spreadsheet data to >> Access tables. ?Is a detailed knowledge of these three Microsoft >> technologies required (or assumed) as a prerequisite to pursuing a SQL >> Server certification? >> >> TIA. ?(I suspect this is going to be the first of many questions.) >> >> Alan C. Lawhon >> >> >> >> _______________________________________________ >> 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 > > -- Gary Kjos garykjos at gmail.com From stuart at lexacorp.com.pg Tue Aug 16 16:21:22 2011 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 17 Aug 2011 07:21:22 +1000 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: References: <000501cc5bf9$8f8b30f0$aea192d0$@net>, <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg>, Message-ID: <4E4ADF52.5536.21852DD3@stuart.lexacorp.com.pg> I should have been more specific. There are two PowerPivots components: PowerPivot for Excel and PowerPivot for Sharepoint. I was referring to the latter which Alan's asked about. -- Stuart On 16 Aug 2011 at 12:51, Gary Kjos wrote: > Hmmmm, it is my understanding that Powerpivot is an add in for Excel > 2010..... > > http://www.powerpivot.com/ > > I've seen demos of it and it is really a powerful tool for analyzing > Data Warehouse type data - almost gives end users the ability to > create their own data marts. > > But it would be outside of a SQL Server DBA kind of tool. > > GK > > On Tue, Aug 16, 2011 at 6:56 AM, Stuart McLachlan > wrote: > > Hi Alan, > > > > Nice to see you over on this list. > > > > SQL Server is a Database Management System. ?It is generally used as > > the back-end to some sort of front end application. ?You can use > > anything you like for the front end. ?A number here and on the VB > > List use Visual Studio but it is not the only thing to use ( I > > stopped using VS years ago). > > > > Sharepoint is used by a small minority of SQL users. > > Forget about Excel, PowerPivot has nothing to do with ?that > > application. > > > > At this stage, you would probably be best off sticking to Access as > > the front end with ODBC linked tables and PassThrough Queries to > > stored procedures in SQL Server. ? You get your head around the > > fundamentals of tables, triggers, SQL and stored procedures, how > > user permissions ?work, how backups work, how import and export > > works. ?They are the key components of managing SQL Server. ? Then > > you can look at other front ends if required. > > > > Many DBAs (Database Administrators) don't get involved in front end > > application development at all - they just manage the back end and > > leave it up to others to use the data in real-world applications. > > > > -- > > Stuart > > > > On 16 Aug 2011 at 4:47, Alan Lawhon wrote: > >> > >> My question concerns the three Microsoft products mentioned in that > >> sentence, specifically "Microsoft Visual Studio 2010, Microsoft > >> SharePoint 2010, and SQL Server PowerPivot for SharePoint." ?Is > >> knowledge and experience with these three products taken for > >> granted - an assumed prerequisite - prior to pursuing a SQL Server > >> certification? ?(I have no knowledge or experience with any of > >> these three products - I don't even know what SharePoint is - or > >> what SharePoint does.) ?As far as PowerPivot is concerned, I think > >> that has something to do with Excel spreadsheets. ?My prior > >> experience with Excel was limited to converting (and copying over) > >> spreadsheet data to Access tables. ?Is a detailed knowledge of > >> these three Microsoft technologies required (or assumed) as a > >> prerequisite to pursuing a SQL Server certification? > >> > >> TIA. ?(I suspect this is going to be the first of many questions.) > >> > >> Alan C. Lawhon > >> > >> > >> > >> _______________________________________________ > >> 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 > > > > > > > > -- > Gary Kjos > garykjos at gmail.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From lawhonac at hiwaay.net Fri Aug 19 22:03:19 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Fri, 19 Aug 2011 22:03:19 -0500 Subject: [dba-SQLServer] SQL Server Book Message-ID: <000f01cc5ee5$b7215b00$25641100$@net> I plunked down a little over $50 today and bought a copy of "murach's SQL Server 2008 for developers" book. This is a 750 page tome (including a couple of Appendixes) that include instructions for downloading SQL Server Express (with Tools), the Management Studio, Books Online and two sample databases. There are 22 chapters in this book with heavy emphasis on T-SQL, so I think this will be a very good study resource and prep guide for passing the SQL Server Developer's exam - (i.e. 70-433). In scanning this book prior to purchase, I noticed that each chapter ends with a section of "Terms" that were covered in the chapter. For instance, I have seen frequent references to the term "instance" in Books Online, but I've never been sure exactly what "instance" (or an "instance") means. Based on what I'm reading in this book, an entity is a class of objects (for instance "cars") and a particular car would be a member of that class, so if a table represents a class of objects, then a row within the table would be an instance. (An instance is not a copy - it's a member of a class.) That's where I was getting confused - I thought "instance" was a copy, but apparently it's not. What has me confused now is another section of the book where I read that you can have "two instances" of SQL Server running simultaneously on the same machine. If I recalled correctly, that would seem to imply that an "instance" is a copy! (Maybe what that sentence was implying is that you can have SQL Server running two different [application] databases off the same SQL Server database engine simultaneously - so the two separate databases are the "instances" - while the [installed] SQL Server database engine is the entity.) Hopefully this book will help me unravel all the terminology and clear out the cobwebs. Alan C. Lawhon From stuart at lexacorp.com.pg Fri Aug 19 22:53:38 2011 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Sat, 20 Aug 2011 13:53:38 +1000 Subject: [dba-SQLServer] SQL Server Book In-Reply-To: <000f01cc5ee5$b7215b00$25641100$@net> References: <000f01cc5ee5$b7215b00$25641100$@net> Message-ID: <4E4F2FC2.28180.7F736D@stuart.lexacorp.com.pg> Two instances of SQL Server, means that you have two separate installations od the database engine running concurrently on the same machine The first time you instal SQL Server on a machine, it is automatically installed as the "Default Instance". You can then do a complete instal of SQL Server again, this time as a "Named Instance" where you specify a different name and different port(s) for it to operate on. The concept was introduces with SQL Server 2000. See http://msdn.microsoft.com/en-us/library/aa174516%28v=sql.80%29.aspx -- Stuart On 19 Aug 2011 at 22:03, Alan Lawhon wrote: > > What has me confused now is another section of the book where I read > that you can have "two instances" of SQL Server running simultaneously > on the same machine. If I recalled correctly, that would seem to > imply that an "instance" is a copy! (Maybe what that sentence was > implying is that you can have SQL Server running two different > [application] databases off the same SQL Server database engine > simultaneously - so the two separate databases are the "instances" - > while the [installed] SQL Server database engine is the entity.) > > From jwcolby at colbyconsulting.com Fri Aug 19 23:14:26 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 20 Aug 2011 00:14:26 -0400 Subject: [dba-SQLServer] SQL Server Book In-Reply-To: <000f01cc5ee5$b7215b00$25641100$@net> References: <000f01cc5ee5$b7215b00$25641100$@net> Message-ID: <4E4F34A2.1090902@colbyconsulting.com> My understanding is that the instances are actual services, the SQL Server service is running twice. Any instance can be running many different databases simultaneously. But what do I know? ;) John W. Colby www.ColbyConsulting.com On 8/19/2011 11:03 PM, Alan Lawhon wrote: > I plunked down a little over $50 today and bought a copy of "murach's SQL > Server 2008 for developers" book. This is a 750 page tome (including a > couple of Appendixes) that include instructions for downloading SQL Server > Express (with Tools), the Management Studio, Books Online and two sample > databases. There are 22 chapters in this book with heavy emphasis on T-SQL, > so I think this will be a very good study resource and prep guide for > passing the SQL Server Developer's exam - (i.e. 70-433). > > > > In scanning this book prior to purchase, I noticed that each chapter ends > with a section of "Terms" that were covered in the chapter. For instance, I > have seen frequent references to the term "instance" in Books Online, but > I've never been sure exactly what "instance" (or an "instance") means. > Based on what I'm reading in this book, an entity is a class of objects (for > instance "cars") and a particular car would be a member of that class, so if > a table represents a class of objects, then a row within the table would be > an instance. (An instance is not a copy - it's a member of a class.) > That's where I was getting confused - I thought "instance" was a copy, but > apparently it's not. > > > > What has me confused now is another section of the book where I read that > you can have "two instances" of SQL Server running simultaneously on the > same machine. If I recalled correctly, that would seem to imply that an > "instance" is a copy! (Maybe what that sentence was implying is that you > can have SQL Server running two different [application] databases off the > same SQL Server database engine simultaneously - so the two separate > databases are the "instances" - while the [installed] SQL Server database > engine is the entity.) > > > > Hopefully this book will help me unravel all the terminology and clear out > the cobwebs. > > > > Alan C. Lawhon > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From lawhonac at hiwaay.net Sat Aug 20 00:24:27 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Sat, 20 Aug 2011 00:24:27 -0500 Subject: [dba-SQLServer] SQL Server Book In-Reply-To: <4E4F2FC2.28180.7F736D@stuart.lexacorp.com.pg> References: <000f01cc5ee5$b7215b00$25641100$@net> <4E4F2FC2.28180.7F736D@stuart.lexacorp.com.pg> Message-ID: <000101cc5ef9$6e0d1300$4a273900$@net> Stuart: Thanks for the link. I think I understand why you would have named instances on the same machine. You might have one named instance for the engineering department of a very large company and a second named instance for the accounting department - with each department having their own databases and applications - and their own copy of SQL Server dedicated solely to their instance with both instances running on the same computer. (That computer better have a lot of horsepower - especially if you have multiple named instances running concurrently with lots of users on each instance.) Alan C. Lawhon -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Friday, August 19, 2011 10:54 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] SQL Server Book Two instances of SQL Server, means that you have two separate installations od the database engine running concurrently on the same machine The first time you instal SQL Server on a machine, it is automatically installed as the "Default Instance". You can then do a complete instal of SQL Server again, this time as a "Named Instance" where you specify a different name and different port(s) for it to operate on. The concept was introduces with SQL Server 2000. See http://msdn.microsoft.com/en-us/library/aa174516%28v=sql.80%29.aspx -- Stuart On 19 Aug 2011 at 22:03, Alan Lawhon wrote: > > What has me confused now is another section of the book where I read > that you can have "two instances" of SQL Server running simultaneously > on the same machine. If I recalled correctly, that would seem to > imply that an "instance" is a copy! (Maybe what that sentence was > implying is that you can have SQL Server running two different > [application] databases off the same SQL Server database engine > simultaneously - so the two separate databases are the "instances" - > while the [installed] SQL Server database engine is the entity.) > > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From jwcolby at colbyconsulting.com Sat Aug 20 07:47:45 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 20 Aug 2011 08:47:45 -0400 Subject: [dba-SQLServer] SQL Server Book In-Reply-To: <000101cc5ef9$6e0d1300$4a273900$@net> References: <000f01cc5ee5$b7215b00$25641100$@net> <4E4F2FC2.28180.7F736D@stuart.lexacorp.com.pg> <000101cc5ef9$6e0d1300$4a273900$@net> Message-ID: <4E4FACF1.2050200@colbyconsulting.com> SQL Server has properties for assigning physical cores to it as well as amounts of memory. I have a 16 core server with 32 gigs of memory. If I run two instances I can assign one SQL Server instance 4 cores and 8 gigs of memory, another instance 8 cores and 20 gigs of memory. All cores and memory not assigned are left for the OS. John W. Colby www.ColbyConsulting.com On 8/20/2011 1:24 AM, Alan Lawhon wrote: > Stuart: > > Thanks for the link. I think I understand why you would have named > instances on the same machine. You might have one named instance for the > engineering department of a very large company and a second named instance > for the accounting department - with each department having their own > databases and applications - and their own copy of SQL Server dedicated > solely to their instance with both instances running on the same computer. > (That computer better have a lot of horsepower - especially if you have > multiple named instances running concurrently with lots of users on each > instance.) > > Alan C. Lawhon > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart > McLachlan > Sent: Friday, August 19, 2011 10:54 PM > To: Discussion concerning MS SQL Server > Subject: Re: [dba-SQLServer] SQL Server Book > > Two instances of SQL Server, means that you have two separate installations > od the > database engine running concurrently on the same machine > > The first time you instal SQL Server on a machine, it is automatically > installed as the "Default > Instance". You can then do a complete instal of SQL Server again, this > time as a "Named > Instance" where you specify a different name and different port(s) for it > to operate on. > > The concept was introduces with SQL Server 2000. > > See http://msdn.microsoft.com/en-us/library/aa174516%28v=sql.80%29.aspx > From jwcolby at colbyconsulting.com Sun Aug 28 17:40:51 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sun, 28 Aug 2011 18:40:51 -0400 Subject: [dba-SQLServer] Enforcing a rule Message-ID: <4E5AC3F3.2010000@colbyconsulting.com> I have a table where the client is either a parent type (from a list of parent types) or a professional type (from a list of professional types). I need to enforce that at least one of the fields is filled. IOW both cannot be null, but either one can be null or both can be filled. How do I do something like that? I have never used database level constraints other than pk/fk so I do not know how to set something like this up. Any detailed instructions or a pointer to a web page would be appreciated. Thanks, -- John W. Colby www.ColbyConsulting.com From rockysmolin at bchacc.com Sun Aug 28 18:52:11 2011 From: rockysmolin at bchacc.com (Rocky Smolin) Date: Sun, 28 Aug 2011 16:52:11 -0700 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <4E5AC3F3.2010000@colbyconsulting.com> References: <4E5AC3F3.2010000@colbyconsulting.com> Message-ID: <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> I would use the Before Update event of the form to verify that at last choice was made. Rocky -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: August 28, 2011 3:41 PM To: Sqlserver-Dba Subject: [dba-SQLServer] Enforcing a rule I have a table where the client is either a parent type (from a list of parent types) or a professional type (from a list of professional types). I need to enforce that at least one of the fields is filled. IOW both cannot be null, but either one can be null or both can be filled. How do I do something like that? I have never used database level constraints other than pk/fk so I do not know how to set something like this up. Any detailed instructions or a pointer to a web page would be appreciated. Thanks, -- John W. Colby www.ColbyConsulting.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From jwcolby at colbyconsulting.com Sun Aug 28 20:47:06 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sun, 28 Aug 2011 21:47:06 -0400 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> References: <4E5AC3F3.2010000@colbyconsulting.com> <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> Message-ID: <4E5AEF9A.40105@colbyconsulting.com> I can certainly do that but I am hoping to learn how to use the SQL Server engine to do these things. John W. Colby www.ColbyConsulting.com On 8/28/2011 7:52 PM, Rocky Smolin wrote: > I would use the Before Update event of the form to verify that at last > choice was made. > > Rocky > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby > Sent: August 28, 2011 3:41 PM > To: Sqlserver-Dba > Subject: [dba-SQLServer] Enforcing a rule > > I have a table where the client is either a parent type (from a list of > parent types) or a professional type (from a list of professional types). I > need to enforce that at least one of the fields is filled. IOW both cannot > be null, but either one can be null or both can be filled. > > How do I do something like that? I have never used database level > constraints other than pk/fk so I do not know how to set something like this > up. Any detailed instructions or a pointer to a web page would be > appreciated. > > Thanks, > > -- > John W. Colby > www.ColbyConsulting.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 fhtapia at gmail.com Sun Aug 28 20:49:13 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Sun, 28 Aug 2011 18:49:13 -0700 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <4E5AEF9A.40105@colbyconsulting.com> References: <4E5AC3F3.2010000@colbyconsulting.com> <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> <4E5AEF9A.40105@colbyconsulting.com> Message-ID: <-4307288342993314064@unknownmsgid> Have you looked into update triggers on tables? Sent from my mobile On Aug 28, 2011, at 6:47 PM, jwcolby wrote: > I can certainly do that but I am hoping to learn how to use the SQL Server engine to do these things. > > John W. Colby > www.ColbyConsulting.com > > On 8/28/2011 7:52 PM, Rocky Smolin wrote: >> I would use the Before Update event of the form to verify that at last >> choice was made. >> >> Rocky >> >> >> -----Original Message----- >> From: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby >> Sent: August 28, 2011 3:41 PM >> To: Sqlserver-Dba >> Subject: [dba-SQLServer] Enforcing a rule >> >> I have a table where the client is either a parent type (from a list of >> parent types) or a professional type (from a list of professional types). I >> need to enforce that at least one of the fields is filled. IOW both cannot >> be null, but either one can be null or both can be filled. >> >> How do I do something like that? I have never used database level >> constraints other than pk/fk so I do not know how to set something like this >> up. Any detailed instructions or a pointer to a web page would be >> appreciated. >> >> Thanks, >> >> -- >> John W. Colby >> www.ColbyConsulting.com >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From lawhonac at hiwaay.net Mon Aug 29 02:22:21 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Mon, 29 Aug 2011 02:22:21 -0500 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <-4307288342993314064@unknownmsgid> References: <4E5AC3F3.2010000@colbyconsulting.com> <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> <4E5AEF9A.40105@colbyconsulting.com> <-4307288342993314064@unknownmsgid> Message-ID: <000101cc661c$64a871e0$2df955a0$@net> John: I'm not sure exactly how triggers would apply to your specific situation, (i.e. exactly how you would go about coding a solution to your problem), but Francisco may be on to something. In "Section 4 - Advanced SQL skills" on pages 470 and 471 of "murach's SQL Server 2008 for developers" book, the author has a section entitled "How to use triggers to enforce data consistency". The problem (and solution) he presents may not be precisely applicable to the problem you're describing, but you may be able to get a good idea of how to go about solving your problem from reading those pages. I'm in the early stages of trying to figure out and "learn" SQL Server. >From what I've read so far, triggers seem to be designed to ensure data validation (data consistency) and maintain relationships between tables. What you're trying to do seems related to this, so maybe a stored procedure that includes a trigger will solve your problem. This is great - I'm now a SQL Server consultant! :-))) Alan C. Lawhon -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia Sent: Sunday, August 28, 2011 8:49 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Enforcing a rule Have you looked into update triggers on tables? Sent from my mobile On Aug 28, 2011, at 6:47 PM, jwcolby wrote: > I can certainly do that but I am hoping to learn how to use the SQL Server engine to do these things. > > John W. Colby > www.ColbyConsulting.com > > On 8/28/2011 7:52 PM, Rocky Smolin wrote: >> I would use the Before Update event of the form to verify that at last >> choice was made. >> >> Rocky >> >> >> -----Original Message----- >> From: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby >> Sent: August 28, 2011 3:41 PM >> To: Sqlserver-Dba >> Subject: [dba-SQLServer] Enforcing a rule >> >> I have a table where the client is either a parent type (from a list of >> parent types) or a professional type (from a list of professional types). I >> need to enforce that at least one of the fields is filled. IOW both cannot >> be null, but either one can be null or both can be filled. >> >> How do I do something like that? I have never used database level >> constraints other than pk/fk so I do not know how to set something like this >> up. Any detailed instructions or a pointer to a web page would be >> appreciated. >> >> Thanks, >> >> -- >> John W. Colby >> www.ColbyConsulting.com >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From Gustav at cactus.dk Mon Aug 29 02:25:56 2011 From: Gustav at cactus.dk (Gustav Brock) Date: Mon, 29 Aug 2011 09:25:56 +0200 Subject: [dba-SQLServer] Enforcing a rule Message-ID: Hi John Just add a new constraint, name it properly, and add an expression that states the rule you explain, like: Not ([ParentType] Is Null And [ProfessionalType] Is Null) And mark: Enforce for INSERTs and UPDATEs /gustav >>> jwcolby at colbyconsulting.com 29-08-2011 00:40 >>> I have a table where the client is either a parent type (from a list of parent types) or a professional type (from a list of professional types). I need to enforce that at least one of the fields is filled. IOW both cannot be null, but either one can be null or both can be filled. How do I do something like that? I have never used database level constraints other than pk/fk so I do not know how to set something like this up. Any detailed instructions or a pointer to a web page would be appreciated. Thanks, -- John W. Colby www.ColbyConsulting.com From fuller.artful at gmail.com Mon Aug 29 04:56:32 2011 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 29 Aug 2011 05:56:32 -0400 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <000101cc661c$64a871e0$2df955a0$@net> References: <4E5AC3F3.2010000@colbyconsulting.com> <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> <4E5AEF9A.40105@colbyconsulting.com> <-4307288342993314064@unknownmsgid> <000101cc661c$64a871e0$2df955a0$@net> Message-ID: Besdies ensuring data consistency, triggers are often used for maintaining an audit trail. On an insert it doesn't make much sense, but on update and delete it does (you can write the old row to a table before doing the actual update, or write the old row to a table before doing the delete). IIRC, Susan and I wrote about that some time ago in TechRepublic. Arthur From jwcolby at colbyconsulting.com Mon Aug 29 11:32:39 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Mon, 29 Aug 2011 12:32:39 -0400 Subject: [dba-SQLServer] Are indexes unique Message-ID: <4E5BBF27.90305@colbyconsulting.com> If I have a clustered index on my PK (autoincrement int) and that is used in all indexes without specififying that it be used (my understanding) does that mean that every index is by definition unique? Do I need to check the unique box when creating the index? Or does "unique" only count on the actual fields specified in the index? -- John W. Colby www.ColbyConsulting.com From fuller.artful at gmail.com Mon Aug 29 12:12:41 2011 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 29 Aug 2011 13:12:41 -0400 Subject: [dba-SQLServer] Are indexes unique In-Reply-To: <4E5BBF27.90305@colbyconsulting.com> References: <4E5BBF27.90305@colbyconsulting.com> Message-ID: Unique only counts on the specified fields. A. On Mon, Aug 29, 2011 at 12:32 PM, jwcolby wrote: > If I have a clustered index on my PK (autoincrement int) and that is used > in all indexes without specififying that it be used (my understanding) does > that mean that every index is by definition unique? Do I need to check the > unique box when creating the index? > > Or does "unique" only count on the actual fields specified in the index? > From lawhonac at hiwaay.net Mon Aug 29 17:56:20 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Mon, 29 Aug 2011 17:56:20 -0500 Subject: [dba-SQLServer] Success!! (I Think ...) Message-ID: <000701cc669e$de755880$9b600980$@net> It took me the better part of 4-5 hours, (including installation of all the "prerequisite" software along with several service pack upgrades after the installation), but I managed to successfully download and install the SQL Server 2008 R2 "Express" edition (with Books Online) to my Windows XP SP3 notebook computer. It took a bit of head scratching figuring it all out, (there's a bunch of "stuff" about Windows authentication that I need to learn), but I finally got it all to work. I'll download and attach the Accounts Payable sample database that goes with my Murach SQL Server developer's book tomorrow. Then I'll be on my way to becoming a SQL Server expert. I aspire to be half-to-three-quarters as great as Rocky, John Colby, Stuart McLachlan, Gustav Brock, Francisco Tapia, Susan Harkins, Gary Kjos, and Arthur Fuller. (Did I leave anybody out?) If I can get as smart as you guys (and Susan) at my advanced age, that will be an accomplishment! I suppose I should have started working on this a year ago - when I still had some money - but I was convinced that I was a 55-year-old version of Doyle Brunson on my way to earning vast riches at the poker table. Live and learn I suppose . Alan C. Lawhon From newsgrps at dalyn.co.nz Tue Aug 30 03:41:12 2011 From: newsgrps at dalyn.co.nz (newsgrps) Date: Tue, 30 Aug 2011 20:41:12 +1200 Subject: [dba-SQLServer] Joining temp tables in SPROC Message-ID: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> Group, Can someone please explain why this is I get an error "Must declare the variable ttmpWeeks" when I try to save the following in a stored procedure: ALTER PROCEDURE sprptProductionSummary ( @txtDate1 varchar(20), @txtDate2 varchar(20) ) AS SET NOCOUNT ON SET DATEFIRST 1 -- Monday DECLARE @ttmpWeeks table (WeekNo tinyint) DECLARE @tmpDate as datetime SET @tmpDate = @txtDate1 INSERT INTO @ttmpWeeks (WeekNo) VALUES (DATEPART(week, @tmpDate)) SET @tmpDate = DATEADD(week, 1, @tmpDate) WHILE @tmpdate < @txtDate2 BEGIN INSERT INTO @ttmpWeeks (WeekNo) VALUES (DATEPART(week, @tmpDate)) SET @tmpDate = DATEADD(week, 1, @tmpDate) END SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS KnittedWeight FROM dbo.tblRoll WHERE KnitDate BETWEEN @txtDate1 AND @txtDate2 GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum {rest of code continues} However, if I change the last line to GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = spKnit.WeekNum it saves and works. Why doesn't it accept the table part of the WeekNo field? Regards David Emerson Dalyn Software Ltd Wellington, New Zealand From garykjos at gmail.com Tue Aug 30 03:57:33 2011 From: garykjos at gmail.com (Gary Kjos) Date: Tue, 30 Aug 2011 03:57:33 -0500 Subject: [dba-SQLServer] [dba-OT] Success!! (I Think ...) In-Reply-To: <000701cc669e$de755880$9b600980$@net> References: <000701cc669e$de755880$9b600980$@net> Message-ID: Great! There are actually a lot of statistical analysis functions within Analysis Services which is part of the full version of SQL Server - not sure if it's in Express - that you might be able to use to analyze your poker game too. ;-) Keep up the good work Alan. You are gaining momentum. GK On Mon, Aug 29, 2011 at 5:56 PM, Alan Lawhon wrote: > It took me the better part of 4-5 hours, (including installation of all the > "prerequisite" software along with several service pack upgrades after the > installation), but I managed to successfully download and install the SQL > Server 2008 R2 "Express" edition (with Books Online) to my Windows XP SP3 > notebook computer. ?It took a bit of head scratching figuring it all out, > (there's a bunch of "stuff" about Windows authentication that I need to > learn), but I finally got it all to work. > > I'll download and attach the Accounts Payable sample database that goes with > my Murach SQL Server developer's book tomorrow. ?Then I'll be on my way to > becoming a SQL Server expert. ?I aspire to be half-to-three-quarters as > great as Rocky, John Colby, Stuart McLachlan, Gustav Brock, Francisco Tapia, > Susan Harkins, Gary Kjos, and Arthur Fuller. ?(Did I leave anybody out?) > > If I can get as smart as you guys (and Susan) at my advanced age, that will > be an accomplishment! > > I suppose I should have started working on this a year ago - when I still > had some money - but I was convinced that I was a 55-year-old version of > Doyle Brunson on my way to earning vast riches at the poker table. ?Live and > learn I suppose . > > Alan C. Lawhon > > > > _______________________________________________ > dba-OT mailing list > dba-OT at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-ot > Website: http://www.databaseadvisors.com > -- Gary Kjos garykjos at gmail.com From fuller.artful at gmail.com Tue Aug 30 04:44:47 2011 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 30 Aug 2011 05:44:47 -0400 Subject: [dba-SQLServer] [dba-OT] Success!! (I Think ...) In-Reply-To: References: <000701cc669e$de755880$9b600980$@net> Message-ID: BI + Poker = Broke :) The most intelligent poker play is Step Away From the Table. If you must gamble, try speed chess + the doubling cube (borrowed from backgammon), an innovation introduced by my friend and backgammon-mentor Vladimir Dobrich. Arthur On Tue, Aug 30, 2011 at 4:57 AM, Gary Kjos wrote: > Great! > > There are actually a lot of statistical analysis functions within > Analysis Services which is part of the full version of SQL Server - > not sure if it's in Express - that you might be able to use to analyze > your poker game too. ;-) > > Keep up the good work Alan. You are gaining momentum. > > GK > > From fhtapia at gmail.com Tue Aug 30 08:19:25 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 30 Aug 2011 06:19:25 -0700 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: i'm not sure, but i've always used an alias when I join my temp tables including variable tables, so my change would read FROM @ttmpWeeks AS tWeeks then your ON statment can read tWeeks.WeekNo = join clause -Francisco http://bit.ly/sqlthis | Tsql and More... On Tue, Aug 30, 2011 at 1:41 AM, newsgrps wrote: > Group, > > Can someone please explain why this is > > I get an error "Must declare the variable ttmpWeeks" when I try to save the > following in a stored procedure: > > ALTER PROCEDURE sprptProductionSummary > ( > @txtDate1 varchar(20), > @txtDate2 varchar(20) > ) > AS > SET NOCOUNT ON > > SET DATEFIRST 1 -- Monday > > DECLARE @ttmpWeeks table (WeekNo tinyint) > > DECLARE @tmpDate as datetime > > SET @tmpDate = @txtDate1 > > INSERT INTO @ttmpWeeks (WeekNo) > VALUES (DATEPART(week, @tmpDate)) > > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > WHILE @tmpdate < @txtDate2 > BEGIN > INSERT INTO @ttmpWeeks (WeekNo) > VALUES (DATEPART(week, @tmpDate)) > > SET @tmpDate = DATEADD(week, 1, @tmpDate) > END > > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS KnittedWeight > FROM dbo.tblRoll > WHERE KnitDate BETWEEN > @txtDate1 AND @txtDate2 > GROUP BY DATEPART(week, > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum > > {rest of code continues} > > However, if I change the last line to > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = > spKnit.WeekNum > it saves and works. > > Why doesn't it accept the table part of the WeekNo field? > > > Regards > > David Emerson > Dalyn Software Ltd > Wellington, New Zealand ______________________________**_________________ > dba-SQLServer mailing list > dba-SQLServer@**databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.**com > > From newsgrps at dalyn.co.nz Tue Aug 30 14:42:18 2011 From: newsgrps at dalyn.co.nz (newsgrps) Date: Wed, 31 Aug 2011 07:42:18 +1200 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Thanks Francisco. That worked and makes me more comfortable. David At 31/08/2011, Francisco Tapia wrote: >i'm not sure, but i've always used an alias when I join my temp tables >including variable tables, so my change would read > >FROM @ttmpWeeks AS tWeeks > >then your ON statment can read tWeeks.WeekNo = join clause > >-Francisco >http://bit.ly/sqlthis | Tsql and More... > > > > > >On Tue, Aug 30, 2011 at 1:41 AM, newsgrps wrote: > > > Group, > > > > Can someone please explain why this is > > > > I get an error "Must declare the variable ttmpWeeks" when I try to save the > > following in a stored procedure: > > > > ALTER PROCEDURE sprptProductionSummary > > ( > > @txtDate1 varchar(20), > > @txtDate2 varchar(20) > > ) > > AS > > SET NOCOUNT ON > > > > SET DATEFIRST 1 -- Monday > > > > DECLARE @ttmpWeeks table (WeekNo tinyint) > > > > DECLARE @tmpDate as datetime > > > > SET @tmpDate = @txtDate1 > > > > INSERT INTO @ttmpWeeks (WeekNo) > > VALUES (DATEPART(week, @tmpDate)) > > > > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > > > WHILE @tmpdate < @txtDate2 > > BEGIN > > INSERT INTO @ttmpWeeks (WeekNo) > > VALUES (DATEPART(week, @tmpDate)) > > > > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > END > > > > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight > > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS > KnittedWeight > > FROM dbo.tblRoll > > WHERE KnitDate BETWEEN > > @txtDate1 AND @txtDate2 > > GROUP BY DATEPART(week, > > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum > > > > {rest of code continues} > > > > However, if I change the last line to > > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = > > spKnit.WeekNum > > it saves and works. > > > > Why doesn't it accept the table part of the WeekNo field? > > > > > > Regards > > > > David Emerson > > Dalyn Software Ltd > > Wellington, New Zealand ______________________________**_________________ From marklbreen at gmail.com Wed Aug 31 10:36:32 2011 From: marklbreen at gmail.com (Mark Breen) Date: Wed, 31 Aug 2011 16:36:32 +0100 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: Hi David, what is the difference between Temp table and using a variable tables. I never used such an exotic thing ? thanks Mark On 30 August 2011 20:42, newsgrps wrote: > Thanks Francisco. That worked and makes me more comfortable. > > David > > > At 31/08/2011, Francisco Tapia wrote: > >> i'm not sure, but i've always used an alias when I join my temp tables >> including variable tables, so my change would read >> >> FROM @ttmpWeeks AS tWeeks >> >> then your ON statment can read tWeeks.WeekNo = join clause >> >> -Francisco >> http://bit.ly/sqlthis | Tsql and More... >> >> >> >> >> >> On Tue, Aug 30, 2011 at 1:41 AM, newsgrps wrote: >> >> > Group, >> > >> > Can someone please explain why this is >> > >> > I get an error "Must declare the variable ttmpWeeks" when I try to save >> the >> > following in a stored procedure: >> > >> > ALTER PROCEDURE sprptProductionSummary >> > ( >> > @txtDate1 varchar(20), >> > @txtDate2 varchar(20) >> > ) >> > AS >> > SET NOCOUNT ON >> > >> > SET DATEFIRST 1 -- Monday >> > >> > DECLARE @ttmpWeeks table (WeekNo tinyint) >> > >> > DECLARE @tmpDate as datetime >> > >> > SET @tmpDate = @txtDate1 >> > >> > INSERT INTO @ttmpWeeks (WeekNo) >> > VALUES (DATEPART(week, @tmpDate)) >> > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) >> > >> > WHILE @tmpdate < @txtDate2 >> > BEGIN >> > INSERT INTO @ttmpWeeks (WeekNo) >> > VALUES (DATEPART(week, @tmpDate)) >> > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) >> > END >> > >> > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight >> > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, >> > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS >> KnittedWeight >> > FROM dbo.tblRoll >> > WHERE KnitDate BETWEEN >> > @txtDate1 AND @txtDate2 >> > GROUP BY DATEPART(week, >> > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum >> > >> > {rest of code continues} >> > >> > However, if I change the last line to >> > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = >> > spKnit.WeekNum >> > it saves and works. >> > >> > Why doesn't it accept the table part of the WeekNo field? >> > >> > >> > Regards >> > >> > David Emerson >> > Dalyn Software Ltd >> > Wellington, New Zealand ______________________________** >> **_________________ >> > > ______________________________**_________________ > dba-SQLServer mailing list > dba-SQLServer@**databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.**com > > From fhtapia at gmail.com Wed Aug 31 10:43:01 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 31 Aug 2011 08:43:01 -0700 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: Variable tables are generally tables in memory and are meant to be light so that they can survive in memory. A major advantage is you can convert comma delimited lists to variable tables (generally a small-ish table) and have all the benefits of a normal table but in RAM. Temp tables if small will remain in memory, but if the server is busy with other major tasks that demand memory, your temp table will be written to disk. In general a placeholder is always created, but your data may just be in RAM vs on disk, my recommendation for people using variable tables or temp tables is that if you're going to be hauling a lot of data (or potentially a lot of data) then you should architect your solution with temp tables, otherwise for smaller datasets a variable table is a great performance option. -Francisco http://bit.ly/sqlthis | Tsql and More... On Wed, Aug 31, 2011 at 8:36 AM, Mark Breen wrote: > Hi David, > > what is the difference between Temp table and using a variable tables. I > never used such an exotic thing ? > > thanks > > Mark > > > On 30 August 2011 20:42, newsgrps wrote: > > > Thanks Francisco. That worked and makes me more comfortable. > > > > David > > > > > > At 31/08/2011, Francisco Tapia wrote: > > > >> i'm not sure, but i've always used an alias when I join my temp tables > >> including variable tables, so my change would read > >> > >> FROM @ttmpWeeks AS tWeeks > >> > >> then your ON statment can read tWeeks.WeekNo = join clause > >> > >> -Francisco > >> http://bit.ly/sqlthis | Tsql and More... > >> > >> > >> > >> > >> > >> On Tue, Aug 30, 2011 at 1:41 AM, newsgrps wrote: > >> > >> > Group, > >> > > >> > Can someone please explain why this is > >> > > >> > I get an error "Must declare the variable ttmpWeeks" when I try to > save > >> the > >> > following in a stored procedure: > >> > > >> > ALTER PROCEDURE sprptProductionSummary > >> > ( > >> > @txtDate1 varchar(20), > >> > @txtDate2 varchar(20) > >> > ) > >> > AS > >> > SET NOCOUNT ON > >> > > >> > SET DATEFIRST 1 -- Monday > >> > > >> > DECLARE @ttmpWeeks table (WeekNo tinyint) > >> > > >> > DECLARE @tmpDate as datetime > >> > > >> > SET @tmpDate = @txtDate1 > >> > > >> > INSERT INTO @ttmpWeeks (WeekNo) > >> > VALUES (DATEPART(week, @tmpDate)) > >> > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > >> > > >> > WHILE @tmpdate < @txtDate2 > >> > BEGIN > >> > INSERT INTO @ttmpWeeks (WeekNo) > >> > VALUES (DATEPART(week, @tmpDate)) > >> > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > >> > END > >> > > >> > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight > >> > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > >> > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS > >> KnittedWeight > >> > FROM dbo.tblRoll > >> > WHERE KnitDate BETWEEN > >> > @txtDate1 AND @txtDate2 > >> > GROUP BY DATEPART(week, > >> > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum > >> > > >> > {rest of code continues} > >> > > >> > However, if I change the last line to > >> > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = > >> > spKnit.WeekNum > >> > it saves and works. > >> > > >> > Why doesn't it accept the table part of the WeekNo field? > >> > > >> > > >> > Regards > >> > > >> > David Emerson > >> > Dalyn Software Ltd > >> > Wellington, New Zealand ______________________________** > >> **_________________ > >> > > > > ______________________________**_________________ > > dba-SQLServer mailing list > > dba-SQLServer@**databaseadvisors.com > > > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver< > 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 marklbreen at gmail.com Wed Aug 31 10:48:26 2011 From: marklbreen at gmail.com (Mark Breen) Date: Wed, 31 Aug 2011 16:48:26 +0100 Subject: [dba-SQLServer] Mirroring SQL DB's over the internet (as opposed to the LAN) Message-ID: Hello All, I recently set up a mirror of a db over the Lan and was shocked at how easy it is to do. I wonder whether it is feasible to run a mirror over a DSL line. Would it be terrible performance - is it usually only used over LAN speeds? I know I can just try it, but just in case you have any advice it will be welcome, In case you do not know,the steps are 1) switch recovery mode to Full 2) backup full db 3) restore full db to another server but set restore mode to "Restore with no recovery". It is the second radio button on same pane where you click "Verify backup". 4) On the properties tab of your main db, go to mirroring, use the wizard to click through about four steps where you set the authentication and bingo you have a mirrored server. note: I skipped the option of a witness server. Once you do that, you have a red hot backup of your main db at all times. thanks Mark From marklbreen at gmail.com Wed Aug 31 10:56:22 2011 From: marklbreen at gmail.com (Mark Breen) Date: Wed, 31 Aug 2011 16:56:22 +0100 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: Hello Francisco, Thank you for your time to respond. That is extremely interesting and happens to coincide with some sql that I am working on currently. I have a few sprocs that search through all tables, all columns, all schemas for some text and uses a temp table for temp storage on each iteration. I did not yet see how to avoid using a cursor, so the temp table is used each time I loop. Currently the routine takes 4 hours and I had to return my intel i7 to standard settings because it was reaching 90 degrees when all cores were maxed out! I can do some timings so when I do, I will post the results. thanks again, Mark On 31 August 2011 16:43, Francisco Tapia wrote: > Variable tables are generally tables in memory and are meant to be light so > that they can survive in memory. A major advantage is you can convert > comma > delimited lists to variable tables (generally a small-ish table) and have > all the benefits of a normal table but in RAM. Temp tables if small will > remain in memory, but if the server is busy with other major tasks that > demand memory, your temp table will be written to disk. In general a > placeholder is always created, but your data may just be in RAM vs on disk, > my recommendation for people using variable tables or temp tables is that > if > you're going to be hauling a lot of data (or potentially a lot of data) > then > you should architect your solution with temp tables, otherwise for smaller > datasets a variable table is a great performance option. > > > -Francisco > http://bit.ly/sqlthis | Tsql and More... > > > > > > On Wed, Aug 31, 2011 at 8:36 AM, Mark Breen wrote: > > > Hi David, > > > > what is the difference between Temp table and using a variable tables. I > > never used such an exotic thing ? > > > > thanks > > > > Mark > > > > > > On 30 August 2011 20:42, newsgrps wrote: > > > > > Thanks Francisco. That worked and makes me more comfortable. > > > > > > David > > > > > > > > > At 31/08/2011, Francisco Tapia wrote: > > > > > >> i'm not sure, but i've always used an alias when I join my temp tables > > >> including variable tables, so my change would read > > >> > > >> FROM @ttmpWeeks AS tWeeks > > >> > > >> then your ON statment can read tWeeks.WeekNo = join clause > > >> > > >> -Francisco > > >> http://bit.ly/sqlthis | Tsql and More... > > >> > > >> > > >> > > >> > > >> > > >> On Tue, Aug 30, 2011 at 1:41 AM, newsgrps > wrote: > > >> > > >> > Group, > > >> > > > >> > Can someone please explain why this is > > >> > > > >> > I get an error "Must declare the variable ttmpWeeks" when I try to > > save > > >> the > > >> > following in a stored procedure: > > >> > > > >> > ALTER PROCEDURE sprptProductionSummary > > >> > ( > > >> > @txtDate1 varchar(20), > > >> > @txtDate2 varchar(20) > > >> > ) > > >> > AS > > >> > SET NOCOUNT ON > > >> > > > >> > SET DATEFIRST 1 -- Monday > > >> > > > >> > DECLARE @ttmpWeeks table (WeekNo tinyint) > > >> > > > >> > DECLARE @tmpDate as datetime > > >> > > > >> > SET @tmpDate = @txtDate1 > > >> > > > >> > INSERT INTO @ttmpWeeks (WeekNo) > > >> > VALUES (DATEPART(week, @tmpDate)) > > >> > > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > >> > > > >> > WHILE @tmpdate < @txtDate2 > > >> > BEGIN > > >> > INSERT INTO @ttmpWeeks (WeekNo) > > >> > VALUES (DATEPART(week, @tmpDate)) > > >> > > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > >> > END > > >> > > > >> > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS > KnittedWeight > > >> > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > > >> > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS > > >> KnittedWeight > > >> > FROM dbo.tblRoll > > >> > WHERE KnitDate > BETWEEN > > >> > @txtDate1 AND @txtDate2 > > >> > GROUP BY > DATEPART(week, > > >> > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = > spKnit.WeekNum > > >> > > > >> > {rest of code continues} > > >> > > > >> > However, if I change the last line to > > >> > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = > > >> > spKnit.WeekNum > > >> > it saves and works. > > >> > > > >> > Why doesn't it accept the table part of the WeekNo field? > > >> > > > >> > > > >> > Regards > > >> > > > >> > David Emerson > > >> > Dalyn Software Ltd > > >> > Wellington, New Zealand ______________________________** > > >> **_________________ > > >> > > > > > > ______________________________**_________________ > > > dba-SQLServer mailing list > > > dba-SQLServer@**databaseadvisors.com < > dba-SQLServer at databaseadvisors.com > > > > > > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver< > > 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 fhtapia at gmail.com Wed Aug 31 11:07:33 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 31 Aug 2011 09:07:33 -0700 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: I wrote up a script that leverages another developer's solution, I co-wrote this article with Susan Harkins... http://www.devx.com/dbzone/Article/42340/1954?pf=true maybe you can extend or improve on what i've done to help leverage, I'm not sure if the link will prompt you to have a free login account (i may have my browser cookies saved, if so I'll re-post the script here) http://www.devx.com/dbzone/Article/42340/1954/1763?supportItem=1 -Francisco http://bit.ly/sqlthis | Tsql and More... On Wed, Aug 31, 2011 at 8:56 AM, Mark Breen wrote: > Hello Francisco, > > Thank you for your time to respond. > > That is extremely interesting and happens to coincide with some sql that I > am working on currently. > > I have a few sprocs that search through all tables, all columns, all > schemas > for some text and uses a temp table for temp storage on each iteration. > > I did not yet see how to avoid using a cursor, so the temp table is used > each time I loop. > > Currently the routine takes 4 hours and I had to return my intel i7 to > standard settings because it was reaching 90 degrees when all cores were > maxed out! > > I can do some timings so when I do, I will post the results. > > thanks again, > Mark > > > > > On 31 August 2011 16:43, Francisco Tapia wrote: > > > Variable tables are generally tables in memory and are meant to be light > so > > that they can survive in memory. A major advantage is you can convert > > comma > > delimited lists to variable tables (generally a small-ish table) and have > > all the benefits of a normal table but in RAM. Temp tables if small will > > remain in memory, but if the server is busy with other major tasks that > > demand memory, your temp table will be written to disk. In general a > > placeholder is always created, but your data may just be in RAM vs on > disk, > > my recommendation for people using variable tables or temp tables is that > > if > > you're going to be hauling a lot of data (or potentially a lot of data) > > then > > you should architect your solution with temp tables, otherwise for > smaller > > datasets a variable table is a great performance option. > > > > > > -Francisco > > http://bit.ly/sqlthis | Tsql and More... > > > > > > > > > > > > On Wed, Aug 31, 2011 at 8:36 AM, Mark Breen > wrote: > > > > > Hi David, > > > > > > what is the difference between Temp table and using a variable tables. > I > > > never used such an exotic thing ? > > > > > > thanks > > > > > > Mark > > > > > > > > > On 30 August 2011 20:42, newsgrps wrote: > > > > > > > Thanks Francisco. That worked and makes me more comfortable. > > > > > > > > David > > > > > > > > > > > > At 31/08/2011, Francisco Tapia wrote: > > > > > > > >> i'm not sure, but i've always used an alias when I join my temp > tables > > > >> including variable tables, so my change would read > > > >> > > > >> FROM @ttmpWeeks AS tWeeks > > > >> > > > >> then your ON statment can read tWeeks.WeekNo = join clause > > > >> > > > >> -Francisco > > > >> http://bit.ly/sqlthis | Tsql and More... > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> On Tue, Aug 30, 2011 at 1:41 AM, newsgrps > > wrote: > > > >> > > > >> > Group, > > > >> > > > > >> > Can someone please explain why this is > > > >> > > > > >> > I get an error "Must declare the variable ttmpWeeks" when I try to > > > save > > > >> the > > > >> > following in a stored procedure: > > > >> > > > > >> > ALTER PROCEDURE sprptProductionSummary > > > >> > ( > > > >> > @txtDate1 varchar(20), > > > >> > @txtDate2 varchar(20) > > > >> > ) > > > >> > AS > > > >> > SET NOCOUNT ON > > > >> > > > > >> > SET DATEFIRST 1 -- Monday > > > >> > > > > >> > DECLARE @ttmpWeeks table (WeekNo tinyint) > > > >> > > > > >> > DECLARE @tmpDate as datetime > > > >> > > > > >> > SET @tmpDate = @txtDate1 > > > >> > > > > >> > INSERT INTO @ttmpWeeks (WeekNo) > > > >> > VALUES (DATEPART(week, @tmpDate)) > > > >> > > > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > > >> > > > > >> > WHILE @tmpdate < @txtDate2 > > > >> > BEGIN > > > >> > INSERT INTO @ttmpWeeks (WeekNo) > > > >> > VALUES (DATEPART(week, @tmpDate)) > > > >> > > > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > > >> > END > > > >> > > > > >> > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS > > KnittedWeight > > > >> > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > > > >> > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS > > > >> KnittedWeight > > > >> > FROM dbo.tblRoll > > > >> > WHERE KnitDate > > BETWEEN > > > >> > @txtDate1 AND @txtDate2 > > > >> > GROUP BY > > DATEPART(week, > > > >> > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = > > spKnit.WeekNum > > > >> > > > > >> > {rest of code continues} > > > >> > > > > >> > However, if I change the last line to > > > >> > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo > = > > > >> > spKnit.WeekNum > > > >> > it saves and works. > > > >> > > > > >> > Why doesn't it accept the table part of the WeekNo field? > > > >> > > > > >> > > > > >> > Regards > > > >> > > > > >> > David Emerson > > > >> > Dalyn Software Ltd > > > >> > Wellington, New Zealand ______________________________** > > > >> **_________________ > > > >> > > > > > > > > ______________________________**_________________ > > > > dba-SQLServer mailing list > > > > dba-SQLServer@**databaseadvisors.com < > > dba-SQLServer at databaseadvisors.com > > > > > > > > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver< > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver> > > > > http://www.databaseadvisors.**com > > > > > > > > > > > _______________________________________________ > > > dba-SQLServer mailing list > > > dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fhtapia at gmail.com Wed Aug 31 12:16:35 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 31 Aug 2011 10:16:35 -0700 Subject: [dba-SQLServer] Mirroring SQL DB's over the internet (as opposed to the LAN) In-Reply-To: References: Message-ID: I think you can definitely run in this scenario, but there are some things you want to think about...performance will be greatly affected because in the past when I worked with db mirroring, users had to wait until the log shipping completed on the destination database. I remember that this was one of the big performance features that was being worked on for 2008, but I never returned to see if this was actually fixed, the demo's of course made it seem like you could have db mirroring across continents w/o even the thought of latency in the mix. report back your results, I am very interested. -Francisco http://bit.ly/sqlthis | Tsql and More... On Wed, Aug 31, 2011 at 8:48 AM, Mark Breen wrote: > Hello All, > > I recently set up a mirror of a db over the Lan and was shocked at how easy > it is to do. > > I wonder whether it is feasible to run a mirror over a DSL line. Would it > be terrible performance - is it usually only used over LAN speeds? > > I know I can just try it, but just in case you have any advice it will be > welcome, > > In case you do not know,the steps are > > 1) switch recovery mode to Full > 2) backup full db > 3) restore full db to another server but set restore mode to "Restore with > no recovery". It is the second radio button on same pane where you click > "Verify backup". > 4) On the properties tab of your main db, go to mirroring, use the wizard > to > click through about four steps where you set the authentication and bingo > you have a mirrored server. > note: I skipped the option of a witness server. > > Once you do that, you have a red hot backup of your main db at all times. > > thanks > > Mark > _______________________________________________ > 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 Thu Aug 4 15:53:56 2011 From: jnatola at hotmail.com (Jean-Paul natola) Date: Thu, 4 Aug 2011 16:53:56 -0400 Subject: [dba-SQLServer] syslock help Message-ID: Hi all, We have a user that got "locked" in some process or transaction or table, excuse the language here, the former version of the program had a syslocks utility to release anything in that type of situation, it turns out that utlity was removed and the only thing i could find to point me in the right direction was a querey i found online, SELECT * FROM master.dbo.syslockinfo here is what it output but i can really make heads or tails I know its not a lot to go on, but any pointers thoughts would be appreciated column headers are rsc_bin,rsc_valblk,rsc_dbid,rsc_indid,rsc_objid,rsc_type,_rsc_flag,req_mode,req_statu,req_refcnt,req_cryrefecnt,req_lifetime,req_spid,req_ecid,req_ownertype,req_transactionid,req_transactionUOW 0x00000000000000000000000005000200 0x00000000000000000000000000000000 5 0 0 2 0 3 1 1 0 0 53 0 4 0 00000000-0000-0000-0000-000000000000 0x00000000000000000000000005000200 0x00000000000000000000000000000000 5 0 0 2 0 3 1 1 0 0 51 0 4 0 00000000-0000-0000-0000-000000000000 0x00000000000000000000000007000200 0x00000000000000000000000000000000 7 0 0 2 0 3 1 1 0 0 56 0 4 0 00000000-0000-0000-0000-000000000000 0x00000000000000000000000007000200 0x00000000000000000000000000000000 7 0 0 2 0 3 1 1 0 0 54 0 4 0 00000000-0000-0000-0000-000000000000 0x00000000000000000000000007000200 0x00000000000000000000000000000000 7 0 0 2 0 3 1 1 0 0 52 0 4 0 00000000-0000-0000-0000-000000000000 From jwcolby at colbyconsulting.com Fri Aug 5 16:36:34 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Fri, 05 Aug 2011 17:36:34 -0400 Subject: [dba-SQLServer] Stored procedure parameters Message-ID: <4E3C6262.5090002@colbyconsulting.com> I have a form which I want to open and display a single record in. I am building a SP to pull just that one record but I have two different parameters that I can use to find the record, the PKID (an Integer) and a string "opus number". IOW I will pass one or the other but not both. Should I build a single SP with two params and just do a test internal to the SP to determine which param has a value in it? Should I build two different SPs? Should I use some third strategy? -- John W. Colby www.ColbyConsulting.com From davidmcafee at gmail.com Fri Aug 5 17:12:20 2011 From: davidmcafee at gmail.com (David McAfee) Date: Fri, 5 Aug 2011 15:12:20 -0700 Subject: [dba-SQLServer] Stored procedure parameters In-Reply-To: <4E3C6262.5090002@colbyconsulting.com> References: <4E3C6262.5090002@colbyconsulting.com> Message-ID: You can do it your way with two parameters: CREATE PROCEDURE stpJCsSproc (@PKID INT NULL, @Opus NVARCHAR(10)) AS IF ISNULL(PKID,0) <> 0 SELECT * FROM BLAH WHERE PKID = @PKID ELSE SELECT * FROM BLEH WHERE Opus = @Opus or you can do something like this CREATE PROCEDURE stpJCsSproc (@IntMode INT, @Opus NVARCHAR(20)) AS IF @IntMode = 1 --By PKID SELECT * FROM BLAH WHERE PKID = CAST(@Opus AS INT) ELSE IF @intMode = 2 --By Opus SELECT * FROM BLEH WHERE Opus = @Opus --any future more can be added here without changing input parameters --ELSE IF @intMode = 3 --By Composer -- SELECT * FROM tblMusic WHERE Composer = @Opus On Fri, Aug 5, 2011 at 2:36 PM, jwcolby wrote: > I have a form which I want to open and display a single record in. I am > building a SP to pull just that one record but I have two different > parameters that I can use to find the record, the PKID (an Integer) and a > string "opus number". IOW I will pass one or the other but not both. > > Should I build a single SP with two params and just do a test internal to > the SP to determine which param has a value in it? Should I build two > different SPs? Should I use some third strategy? > > -- > John W. Colby > www.ColbyConsulting.com > ______________________________**_________________ > dba-SQLServer mailing list > dba-SQLServer@**databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.**com > > From wilw31 at gmail.com Sun Aug 7 22:06:23 2011 From: wilw31 at gmail.com (Wil Wakely) Date: Sun, 7 Aug 2011 20:06:23 -0700 Subject: [dba-SQLServer] Delete Message-ID: Is this a correct sql statement to delete the first 5 rows (oldest dates) of a recordset for Access 2002? I'm new to SQL. strSQL1 = "DELETE FROM rs WHERE TOP 5, player=1 ORDER BY playdate ASC;" DoCmd.RunSQL strSQL1 ==wilw -- ===wil wakely sunny san diego ca From michael at ddisolutions.com.au Mon Aug 8 02:51:48 2011 From: michael at ddisolutions.com.au (Michael Maddison) Date: Mon, 8 Aug 2011 17:51:48 +1000 Subject: [dba-SQLServer] Delete References: Message-ID: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> Hi Wil, Others will probably jump in but I think you could end up deleting more than 5 rows. If there are multiple 5th top rows ie with the same date. In SQL Server you would do something like... DELETE FROM [tableName] WHERE ID IN ( SELECT TOP 5 ID FROM [tableName] WHERE [tableName]. player = 1 ORDER BY playdate ASC ) I see you are using a Access recordset. This won't work. I don't think you can run a query against a recordset. Why not just open the recordset sorted and loop 5 times deleting as you go? I'm not sure but I seem to recall you don't need to movenext if you are deleteing. Cheers Michael M -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Wil Wakely Sent: Monday, 8 August 2011 1:06 PM To: sql-dba Subject: [dba-SQLServer] Delete Is this a correct sql statement to delete the first 5 rows (oldest dates) of a recordset for Access 2002? I'm new to SQL. strSQL1 = "DELETE FROM rs WHERE TOP 5, player=1 ORDER BY playdate ASC;" DoCmd.RunSQL strSQL1 ==wilw -- ===wil wakely sunny san diego ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com ----- No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1391 / Virus Database: 1520/3820 - Release Date: 08/07/11 From marklbreen at gmail.com Mon Aug 8 03:45:40 2011 From: marklbreen at gmail.com (Mark Breen) Date: Mon, 8 Aug 2011 09:45:40 +0100 Subject: [dba-SQLServer] Delete In-Reply-To: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> References: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> Message-ID: Hello Michael and Wil, Wil, thanks for that, I did not know that you could use TOP n in the where clause, I only use it when I select. Michael, thanks for highlighting the potential additional records, I am looking forward to playing with TOP in where clauses, Mark On 8 August 2011 08:51, Michael Maddison wrote: > Hi Wil, > > Others will probably jump in but I think you could end up deleting more > than 5 rows. If there are multiple 5th top rows ie with the same date. > In SQL Server you would do something like... > DELETE FROM [tableName] > WHERE ID IN ( SELECT TOP 5 ID FROM [tableName] WHERE [tableName]. > player = 1 ORDER BY playdate ASC ) > > I see you are using a Access recordset. This won't work. I don't think > you can run a query against a recordset. > > Why not just open the recordset sorted and loop 5 times deleting as you > go? I'm not sure but I seem to recall you don't need to movenext if you > are deleteing. > > Cheers > > Michael M > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Wil > Wakely > Sent: Monday, 8 August 2011 1:06 PM > To: sql-dba > Subject: [dba-SQLServer] Delete > > Is this a correct sql statement to delete the first 5 rows (oldest > dates) of a recordset for Access 2002? I'm new to SQL. > > strSQL1 = "DELETE FROM rs WHERE TOP 5, player=1 ORDER BY playdate ASC;" > DoCmd.RunSQL strSQL1 > > ==wilw > > -- > ===wil wakely > sunny san diego ca > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > > ----- > No virus found in this message. > Checked by AVG - www.avg.com > Version: 10.0.1391 / Virus Database: 1520/3820 - Release Date: 08/07/11 > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From dw-murphy at cox.net Mon Aug 8 11:02:41 2011 From: dw-murphy at cox.net (Doug Murphy) Date: Mon, 8 Aug 2011 09:02:41 -0700 Subject: [dba-SQLServer] Delete In-Reply-To: References: Message-ID: <002d01cc55e4$9a48aba0$ceda02e0$@cox.net> Don't know. I am more of an empirical developer. I'd try it. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Wil Wakely Sent: Sunday, August 07, 2011 8:06 PM To: sql-dba Subject: [dba-SQLServer] Delete Is this a correct sql statement to delete the first 5 rows (oldest dates) of a recordset for Access 2002? I'm new to SQL. strSQL1 = "DELETE FROM rs WHERE TOP 5, player=1 ORDER BY playdate ASC;" DoCmd.RunSQL strSQL1 ==wilw -- ===wil wakely sunny san diego ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From wilw31 at gmail.com Mon Aug 8 12:47:44 2011 From: wilw31 at gmail.com (Wil Wakely) Date: Mon, 8 Aug 2011 10:47:44 -0700 Subject: [dba-SQLServer] Delete In-Reply-To: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> References: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> Message-ID: Thanks for reply, MIchael. >Why not just open the recordset sorted and loop 5 times deleting as you go? I'm not sure but I seem to recall you don't need to movenext if you are deleteing. Like this? 'select rs and order by date strsql1 = "SELECT * FROM rs WHERE player=1 ORDER BY playdate ASC DoCmd.runsql strsql1 rs.movefirst for n = 1 to 5 rs.delete next n rs.update Woops! I just read that a snapshot RS cannot be edited. I don't want to modify the underlying table so I used snapshot rs. Is there another way to play with the data in the table without modifying the underlying table? -- ===wil wakely sunny san diego ca From michael at ddisolutions.com.au Tue Aug 9 02:20:09 2011 From: michael at ddisolutions.com.au (Michael Maddison) Date: Tue, 9 Aug 2011 17:20:09 +1000 Subject: [dba-SQLServer] Delete References: <99266C61B516644D9727F983FAFAB465086721@remote.ddisolutions.com.au> Message-ID: <99266C61B516644D9727F983FAFAB465086727@remote.ddisolutions.com.au> Ok, the plot thickens :-) So you only want to remove the rows from the recordset not the underlying data? To disconnect the ADO recordset from the database you set the connection to nothing, after loading the recordset. You will have to trial and error to see what type of recordset you need, snapshot won't work as you have discovered. I havn't used access as a FE for years so others might want to chip in??? Cheers Michael M -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Wil Wakely Sent: Tuesday, 9 August 2011 3:48 AM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Delete Thanks for reply, MIchael. >Why not just open the recordset sorted and loop 5 times deleting as you go? I'm not sure but I seem to recall you don't need to movenext if you are deleteing. Like this? 'select rs and order by date strsql1 = "SELECT * FROM rs WHERE player=1 ORDER BY playdate ASC DoCmd.runsql strsql1 rs.movefirst for n = 1 to 5 rs.delete next n rs.update Woops! I just read that a snapshot RS cannot be edited. I don't want to modify the underlying table so I used snapshot rs. Is there another way to play with the data in the table without modifying the underlying table? -- ===wil wakely sunny san diego ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com ----- No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1391 / Virus Database: 1520/3820 - Release Date: 08/07/11 From lawhonac at hiwaay.net Tue Aug 16 04:47:49 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Tue, 16 Aug 2011 04:47:49 -0500 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites Message-ID: <000501cc5bf9$8f8b30f0$aea192d0$@net> This is my first post to the dba-sqlserver list, (and I am a total "noobie" to SQL Server), so I hope no one will consider this a dumb question. I have decided to study for and pursue certification in Microsoft's SQL Server 2008 R2 database platform. My previous work experience was primarily in Access development with some Visual Basic coding. I have virtually no SQL Server experience. Thanks to a recommendation from Susan Harkins, I plan to download and install SQL Server 2008 R2 (the free "Express" edition) and learn all I can using that tool along with books and study guides. My initial plan is to study for (and pass) exam 70-432, "TS: Microsoft SQL Server 2008, Implementation and Maintenance," followed by exams 70-433 and 70-448. (After obtaining those three certifications, hopefully I can find a job because poverty sucks!) One of the first resources I have discovered is Microsoft's online eBook "Introducing Microsoft SQL Server 2008 R2" by Ross Mistry and Stacia Misner. In chapter 1 of Ross and Stacia's book, (i.e. "SQL Server 2008 R2 Editions and Enhancements"), under subsection "SQL Server 2008 R2 Enhancements for DBAs," the following quotation appears in the final sentence of the second paragraph on page 3: Enhancements to scalability and performance, high availability, enterprise security, enterprise manageability, data warehousing, reporting, self-service BI, collaboration, and tight integration with Microsoft Visual Studio 2010, Microsoft SharePoint 2010, and SQL Server PowerPivot for SharePoint make it the best database platform available. My question concerns the three Microsoft products mentioned in that sentence, specifically "Microsoft Visual Studio 2010, Microsoft SharePoint 2010, and SQL Server PowerPivot for SharePoint." Is knowledge and experience with these three products taken for granted - an assumed prerequisite - prior to pursuing a SQL Server certification? (I have no knowledge or experience with any of these three products - I don't even know what SharePoint is - or what SharePoint does.) As far as PowerPivot is concerned, I think that has something to do with Excel spreadsheets. My prior experience with Excel was limited to converting (and copying over) spreadsheet data to Access tables. Is a detailed knowledge of these three Microsoft technologies required (or assumed) as a prerequisite to pursuing a SQL Server certification? TIA. (I suspect this is going to be the first of many questions.) Alan C. Lawhon From stuart at lexacorp.com.pg Tue Aug 16 06:56:36 2011 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Tue, 16 Aug 2011 21:56:36 +1000 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: <000501cc5bf9$8f8b30f0$aea192d0$@net> References: <000501cc5bf9$8f8b30f0$aea192d0$@net> Message-ID: <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> Hi Alan, Nice to see you over on this list. SQL Server is a Database Management System. It is generally used as the back-end to some sort of front end application. You can use anything you like for the front end. A number here and on the VB List use Visual Studio but it is not the only thing to use ( I stopped using VS years ago). Sharepoint is used by a small minority of SQL users. Forget about Excel, PowerPivot has nothing to do with that application. At this stage, you would probably be best off sticking to Access as the front end with ODBC linked tables and PassThrough Queries to stored procedures in SQL Server. You get your head around the fundamentals of tables, triggers, SQL and stored procedures, how user permissions work, how backups work, how import and export works. They are the key components of managing SQL Server. Then you can look at other front ends if required. Many DBAs (Database Administrators) don't get involved in front end application development at all - they just manage the back end and leave it up to others to use the data in real-world applications. -- Stuart On 16 Aug 2011 at 4:47, Alan Lawhon wrote: > > My question concerns the three Microsoft products mentioned in that > sentence, specifically "Microsoft Visual Studio 2010, Microsoft > SharePoint 2010, and SQL Server PowerPivot for SharePoint." Is > knowledge and experience with these three products taken for granted - > an assumed prerequisite - prior to pursuing a SQL Server > certification? (I have no knowledge or experience with any of these > three products - I don't even know what SharePoint is - or what > SharePoint does.) As far as PowerPivot is concerned, I think that has > something to do with Excel spreadsheets. My prior experience with > Excel was limited to converting (and copying over) spreadsheet data to > Access tables. Is a detailed knowledge of these three Microsoft > technologies required (or assumed) as a prerequisite to pursuing a SQL > Server certification? > > TIA. (I suspect this is going to be the first of many questions.) > > Alan C. Lawhon > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From lawhonac at hiwaay.net Tue Aug 16 09:08:52 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Tue, 16 Aug 2011 09:08:52 -0500 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> References: <000501cc5bf9$8f8b30f0$aea192d0$@net> <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> Message-ID: <000101cc5c1e$076dc370$16494a50$@net> Stuart: Thanks. This is encouraging. I vaguely remember SQL pass-through queries, ODBC, and linked tables from my Access days. I even recall playing around a bit with ADO. In my last software job, we had an Access application that was being converted to a SQL Server back end, but I left before the conversion was completed. That was over five years ago. I did get a small amount of experience with SQL Server. (I recall a GUI interface labeled "Enterprise Manager" that resembled a tree-like structure with a lot of lower-level branches - or something similar to that.) This may not be as difficult as I originally thought. From what you're describing, combined with my past experience, I should be able to pick up most of the major implementation and maintenance topics in fairly short order. According to this: http://tinyurl.com/27f4fzt blog posting by Buck Woody, there are over 40 major study areas covered in the 70-432 exam. At first glance, most of the topics - and the links to their corresponding MSDN articles - don't look familiar, but surely I've been exposed to some of this before. With determined effort, (and a little help from my friends), I believe I can master this material and ace the exam. (Thank goodness I don't have to become a SharePoint and Visual Studio expert in order to pass the exam. That's a relief!) Five years ago I turned downed an offer of a Database Administrator job in Iraq. I was worried that I might not be qualified, but I was even more worried about being surrounded by terrorists! With perfect 20/20 hindsight, I probably should have taken that job - whether I was qualified or not - and "grown" into it once I was over there. Once I've passed 70-432 and obtained my (first) certification, I feel fairly confident that I'll find a DBA job somewhere - even if it's on a remote island in the middle of the South Pacific. (It will be nice to work someplace where you can walk to work and you don't need a car.) Thanks again for the good news. I'm now even more motivated to study my butt off. Alan C. Lawhon -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Tuesday, August 16, 2011 6:57 AM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites Hi Alan, Nice to see you over on this list. SQL Server is a Database Management System. It is generally used as the back-end to some sort of front end application. You can use anything you like for the front end. A number here and on the VB List use Visual Studio but it is not the only thing to use ( I stopped using VS years ago). Sharepoint is used by a small minority of SQL users. Forget about Excel, PowerPivot has nothing to do with that application. At this stage, you would probably be best off sticking to Access as the front end with ODBC linked tables and PassThrough Queries to stored procedures in SQL Server. You get your head around the fundamentals of tables, triggers, SQL and stored procedures, how user permissions work, how backups work, how import and export works. They are the key components of managing SQL Server. Then you can look at other front ends if required. Many DBAs (Database Administrators) don't get involved in front end application development at all - they just manage the back end and leave it up to others to use the data in real-world applications. -- Stuart On 16 Aug 2011 at 4:47, Alan Lawhon wrote: > > My question concerns the three Microsoft products mentioned in that > sentence, specifically "Microsoft Visual Studio 2010, Microsoft > SharePoint 2010, and SQL Server PowerPivot for SharePoint." Is > knowledge and experience with these three products taken for granted - > an assumed prerequisite - prior to pursuing a SQL Server > certification? (I have no knowledge or experience with any of these > three products - I don't even know what SharePoint is - or what > SharePoint does.) As far as PowerPivot is concerned, I think that has > something to do with Excel spreadsheets. My prior experience with > Excel was limited to converting (and copying over) spreadsheet data to > Access tables. Is a detailed knowledge of these three Microsoft > technologies required (or assumed) as a prerequisite to pursuing a SQL > Server certification? > > TIA. (I suspect this is going to be the first of many questions.) > > Alan C. Lawhon > > > > _______________________________________________ > 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 stuart at lexacorp.com.pg Tue Aug 16 09:56:43 2011 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 17 Aug 2011 00:56:43 +1000 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: <000101cc5c1e$076dc370$16494a50$@net> References: <000501cc5bf9$8f8b30f0$aea192d0$@net>, <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg>, <000101cc5c1e$076dc370$16494a50$@net> Message-ID: <4E4A852B.24866.20250749@stuart.lexacorp.com.pg> Based on the link, that exam is purely DB Administration stuff.. After a bit of research, I'd suggest you need to work on 70-433 concurrently. See: http://www.microsoft.com/learning/en/us/Exam.aspx?ID=70-433&locale=en-us#tab2 On 16 Aug 2011 at 9:08, Alan Lawhon wrote: > Stuart: > > Thanks. This is encouraging. I vaguely remember SQL pass-through > queries, ODBC, and linked tables from my Access days. I even recall > playing around a bit with ADO. In my last software job, we had an > Access application that was being converted to a SQL Server back end, > but I left before the conversion was completed. That was over five > years ago. I did get a small amount of experience with SQL Server. > (I recall a GUI interface labeled "Enterprise Manager" that resembled > a tree-like structure with a lot of lower-level branches - or > something similar to that.) > > This may not be as difficult as I originally thought. From what > you're describing, combined with my past experience, I should be able > to pick up most of the major implementation and maintenance topics in > fairly short order. According to this: > > http://tinyurl.com/27f4fzt > > blog posting by Buck Woody, there are over 40 major study areas > covered in the 70-432 exam. At first glance, most of the topics - and > the links to their corresponding MSDN articles - don't look familiar, > but surely I've been exposed to some of this before. With determined > effort, (and a little help from my friends), I believe I can master > this material and ace the exam. (Thank goodness I don't have to > become a SharePoint and Visual Studio expert in order to pass the > exam. That's a relief!) > > Five years ago I turned downed an offer of a Database Administrator > job in Iraq. I was worried that I might not be qualified, but I was > even more worried about being surrounded by terrorists! With perfect > 20/20 hindsight, I probably should have taken that job - whether I was > qualified or not - and "grown" into it once I was over there. Once > I've passed 70-432 and obtained my (first) certification, I feel > fairly confident that I'll find a DBA job somewhere - even if it's on > a remote island in the middle of the South Pacific. (It will be nice > to work someplace where you can walk to work and you don't need a > car.) > > Thanks again for the good news. I'm now even more motivated to study > my butt off. > > Alan C. Lawhon > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > Stuart McLachlan Sent: Tuesday, August 16, 2011 6:57 AM To: Discussion > concerning MS SQL Server Subject: Re: [dba-SQLServer] Question > Concerning Microsoft SQL Server 2008 R2 Prerequisites > > Hi Alan, > > Nice to see you over on this list. > > SQL Server is a Database Management System. It is generally used as > the back-end to some sort of front end application. You can use > anything you like for the front end. A number here and on the VB List > use Visual Studio but it is not the only thing to use ( I stopped > using VS years ago). > > Sharepoint is used by a small minority of SQL users. > Forget about Excel, PowerPivot has nothing to do with that > application. > > At this stage, you would probably be best off sticking to Access as > the front end with ODBC linked tables and PassThrough Queries to > stored procedures in SQL Server. You get your head around the > fundamentals of tables, triggers, SQL and stored procedures, how user > permissions work, how backups work, how import and export works. > They are the key components of managing SQL Server. Then you can > look at other front ends if required. > > Many DBAs (Database Administrators) don't get involved in front end > application development at all - they just manage the back end and > leave it up to others to use the data in real-world applications. > > -- > Stuart > > On 16 Aug 2011 at 4:47, Alan Lawhon wrote: > > > > My question concerns the three Microsoft products mentioned in that > > sentence, specifically "Microsoft Visual Studio 2010, Microsoft > > SharePoint 2010, and SQL Server PowerPivot for SharePoint." Is > > knowledge and experience with these three products taken for granted > > - an assumed prerequisite - prior to pursuing a SQL Server > > certification? (I have no knowledge or experience with any of these > > three products - I don't even know what SharePoint is - or what > > SharePoint does.) As far as PowerPivot is concerned, I think that > > has something to do with Excel spreadsheets. My prior experience > > with Excel was limited to converting (and copying over) spreadsheet > > data to Access tables. Is a detailed knowledge of these three > > Microsoft technologies required (or assumed) as a prerequisite to > > pursuing a SQL Server certification? > > > > TIA. (I suspect this is going to be the first of many questions.) > > > > Alan C. Lawhon > > > > > > > > _______________________________________________ > > 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 garykjos at gmail.com Tue Aug 16 12:51:58 2011 From: garykjos at gmail.com (Gary Kjos) Date: Tue, 16 Aug 2011 12:51:58 -0500 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> References: <000501cc5bf9$8f8b30f0$aea192d0$@net> <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg> Message-ID: Hmmmm, it is my understanding that Powerpivot is an add in for Excel 2010..... http://www.powerpivot.com/ I've seen demos of it and it is really a powerful tool for analyzing Data Warehouse type data - almost gives end users the ability to create their own data marts. But it would be outside of a SQL Server DBA kind of tool. GK On Tue, Aug 16, 2011 at 6:56 AM, Stuart McLachlan wrote: > Hi Alan, > > Nice to see you over on this list. > > SQL Server is a Database Management System. ?It is generally used as the back-end to > some sort of front end application. ?You can use anything you like for the front end. ?A > number here and on the VB List use Visual Studio but it is not the only thing to use ( I > stopped using VS years ago). > > Sharepoint is used by a small minority of SQL users. > Forget about Excel, PowerPivot has nothing to do with ?that application. > > At this stage, you would probably be best off sticking to Access as the front end with ODBC > linked tables and PassThrough Queries to stored procedures in SQL Server. ? You get your > head around the fundamentals of tables, triggers, SQL and stored procedures, how user > permissions ?work, how backups work, how import and export works. ?They are the key > components of managing SQL Server. ? Then you can look at other front ends if required. > > Many DBAs (Database Administrators) don't get involved in front end application > development at all - they just manage the back end and leave it up to others to use the data > in real-world applications. > > -- > Stuart > > On 16 Aug 2011 at 4:47, Alan Lawhon wrote: >> >> My question concerns the three Microsoft products mentioned in that >> sentence, specifically "Microsoft Visual Studio 2010, Microsoft >> SharePoint 2010, and SQL Server PowerPivot for SharePoint." ?Is >> knowledge and experience with these three products taken for granted - >> an assumed prerequisite - prior to pursuing a SQL Server >> certification? ?(I have no knowledge or experience with any of these >> three products - I don't even know what SharePoint is - or what >> SharePoint does.) ?As far as PowerPivot is concerned, I think that has >> something to do with Excel spreadsheets. ?My prior experience with >> Excel was limited to converting (and copying over) spreadsheet data to >> Access tables. ?Is a detailed knowledge of these three Microsoft >> technologies required (or assumed) as a prerequisite to pursuing a SQL >> Server certification? >> >> TIA. ?(I suspect this is going to be the first of many questions.) >> >> Alan C. Lawhon >> >> >> >> _______________________________________________ >> 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 > > -- Gary Kjos garykjos at gmail.com From stuart at lexacorp.com.pg Tue Aug 16 16:21:22 2011 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 17 Aug 2011 07:21:22 +1000 Subject: [dba-SQLServer] Question Concerning Microsoft SQL Server 2008 R2 Prerequisites In-Reply-To: References: <000501cc5bf9$8f8b30f0$aea192d0$@net>, <4E4A5AF4.16689.1F801BEE@stuart.lexacorp.com.pg>, Message-ID: <4E4ADF52.5536.21852DD3@stuart.lexacorp.com.pg> I should have been more specific. There are two PowerPivots components: PowerPivot for Excel and PowerPivot for Sharepoint. I was referring to the latter which Alan's asked about. -- Stuart On 16 Aug 2011 at 12:51, Gary Kjos wrote: > Hmmmm, it is my understanding that Powerpivot is an add in for Excel > 2010..... > > http://www.powerpivot.com/ > > I've seen demos of it and it is really a powerful tool for analyzing > Data Warehouse type data - almost gives end users the ability to > create their own data marts. > > But it would be outside of a SQL Server DBA kind of tool. > > GK > > On Tue, Aug 16, 2011 at 6:56 AM, Stuart McLachlan > wrote: > > Hi Alan, > > > > Nice to see you over on this list. > > > > SQL Server is a Database Management System. ?It is generally used as > > the back-end to some sort of front end application. ?You can use > > anything you like for the front end. ?A number here and on the VB > > List use Visual Studio but it is not the only thing to use ( I > > stopped using VS years ago). > > > > Sharepoint is used by a small minority of SQL users. > > Forget about Excel, PowerPivot has nothing to do with ?that > > application. > > > > At this stage, you would probably be best off sticking to Access as > > the front end with ODBC linked tables and PassThrough Queries to > > stored procedures in SQL Server. ? You get your head around the > > fundamentals of tables, triggers, SQL and stored procedures, how > > user permissions ?work, how backups work, how import and export > > works. ?They are the key components of managing SQL Server. ? Then > > you can look at other front ends if required. > > > > Many DBAs (Database Administrators) don't get involved in front end > > application development at all - they just manage the back end and > > leave it up to others to use the data in real-world applications. > > > > -- > > Stuart > > > > On 16 Aug 2011 at 4:47, Alan Lawhon wrote: > >> > >> My question concerns the three Microsoft products mentioned in that > >> sentence, specifically "Microsoft Visual Studio 2010, Microsoft > >> SharePoint 2010, and SQL Server PowerPivot for SharePoint." ?Is > >> knowledge and experience with these three products taken for > >> granted - an assumed prerequisite - prior to pursuing a SQL Server > >> certification? ?(I have no knowledge or experience with any of > >> these three products - I don't even know what SharePoint is - or > >> what SharePoint does.) ?As far as PowerPivot is concerned, I think > >> that has something to do with Excel spreadsheets. ?My prior > >> experience with Excel was limited to converting (and copying over) > >> spreadsheet data to Access tables. ?Is a detailed knowledge of > >> these three Microsoft technologies required (or assumed) as a > >> prerequisite to pursuing a SQL Server certification? > >> > >> TIA. ?(I suspect this is going to be the first of many questions.) > >> > >> Alan C. Lawhon > >> > >> > >> > >> _______________________________________________ > >> 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 > > > > > > > > -- > Gary Kjos > garykjos at gmail.com > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From lawhonac at hiwaay.net Fri Aug 19 22:03:19 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Fri, 19 Aug 2011 22:03:19 -0500 Subject: [dba-SQLServer] SQL Server Book Message-ID: <000f01cc5ee5$b7215b00$25641100$@net> I plunked down a little over $50 today and bought a copy of "murach's SQL Server 2008 for developers" book. This is a 750 page tome (including a couple of Appendixes) that include instructions for downloading SQL Server Express (with Tools), the Management Studio, Books Online and two sample databases. There are 22 chapters in this book with heavy emphasis on T-SQL, so I think this will be a very good study resource and prep guide for passing the SQL Server Developer's exam - (i.e. 70-433). In scanning this book prior to purchase, I noticed that each chapter ends with a section of "Terms" that were covered in the chapter. For instance, I have seen frequent references to the term "instance" in Books Online, but I've never been sure exactly what "instance" (or an "instance") means. Based on what I'm reading in this book, an entity is a class of objects (for instance "cars") and a particular car would be a member of that class, so if a table represents a class of objects, then a row within the table would be an instance. (An instance is not a copy - it's a member of a class.) That's where I was getting confused - I thought "instance" was a copy, but apparently it's not. What has me confused now is another section of the book where I read that you can have "two instances" of SQL Server running simultaneously on the same machine. If I recalled correctly, that would seem to imply that an "instance" is a copy! (Maybe what that sentence was implying is that you can have SQL Server running two different [application] databases off the same SQL Server database engine simultaneously - so the two separate databases are the "instances" - while the [installed] SQL Server database engine is the entity.) Hopefully this book will help me unravel all the terminology and clear out the cobwebs. Alan C. Lawhon From stuart at lexacorp.com.pg Fri Aug 19 22:53:38 2011 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Sat, 20 Aug 2011 13:53:38 +1000 Subject: [dba-SQLServer] SQL Server Book In-Reply-To: <000f01cc5ee5$b7215b00$25641100$@net> References: <000f01cc5ee5$b7215b00$25641100$@net> Message-ID: <4E4F2FC2.28180.7F736D@stuart.lexacorp.com.pg> Two instances of SQL Server, means that you have two separate installations od the database engine running concurrently on the same machine The first time you instal SQL Server on a machine, it is automatically installed as the "Default Instance". You can then do a complete instal of SQL Server again, this time as a "Named Instance" where you specify a different name and different port(s) for it to operate on. The concept was introduces with SQL Server 2000. See http://msdn.microsoft.com/en-us/library/aa174516%28v=sql.80%29.aspx -- Stuart On 19 Aug 2011 at 22:03, Alan Lawhon wrote: > > What has me confused now is another section of the book where I read > that you can have "two instances" of SQL Server running simultaneously > on the same machine. If I recalled correctly, that would seem to > imply that an "instance" is a copy! (Maybe what that sentence was > implying is that you can have SQL Server running two different > [application] databases off the same SQL Server database engine > simultaneously - so the two separate databases are the "instances" - > while the [installed] SQL Server database engine is the entity.) > > From jwcolby at colbyconsulting.com Fri Aug 19 23:14:26 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 20 Aug 2011 00:14:26 -0400 Subject: [dba-SQLServer] SQL Server Book In-Reply-To: <000f01cc5ee5$b7215b00$25641100$@net> References: <000f01cc5ee5$b7215b00$25641100$@net> Message-ID: <4E4F34A2.1090902@colbyconsulting.com> My understanding is that the instances are actual services, the SQL Server service is running twice. Any instance can be running many different databases simultaneously. But what do I know? ;) John W. Colby www.ColbyConsulting.com On 8/19/2011 11:03 PM, Alan Lawhon wrote: > I plunked down a little over $50 today and bought a copy of "murach's SQL > Server 2008 for developers" book. This is a 750 page tome (including a > couple of Appendixes) that include instructions for downloading SQL Server > Express (with Tools), the Management Studio, Books Online and two sample > databases. There are 22 chapters in this book with heavy emphasis on T-SQL, > so I think this will be a very good study resource and prep guide for > passing the SQL Server Developer's exam - (i.e. 70-433). > > > > In scanning this book prior to purchase, I noticed that each chapter ends > with a section of "Terms" that were covered in the chapter. For instance, I > have seen frequent references to the term "instance" in Books Online, but > I've never been sure exactly what "instance" (or an "instance") means. > Based on what I'm reading in this book, an entity is a class of objects (for > instance "cars") and a particular car would be a member of that class, so if > a table represents a class of objects, then a row within the table would be > an instance. (An instance is not a copy - it's a member of a class.) > That's where I was getting confused - I thought "instance" was a copy, but > apparently it's not. > > > > What has me confused now is another section of the book where I read that > you can have "two instances" of SQL Server running simultaneously on the > same machine. If I recalled correctly, that would seem to imply that an > "instance" is a copy! (Maybe what that sentence was implying is that you > can have SQL Server running two different [application] databases off the > same SQL Server database engine simultaneously - so the two separate > databases are the "instances" - while the [installed] SQL Server database > engine is the entity.) > > > > Hopefully this book will help me unravel all the terminology and clear out > the cobwebs. > > > > Alan C. Lawhon > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From lawhonac at hiwaay.net Sat Aug 20 00:24:27 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Sat, 20 Aug 2011 00:24:27 -0500 Subject: [dba-SQLServer] SQL Server Book In-Reply-To: <4E4F2FC2.28180.7F736D@stuart.lexacorp.com.pg> References: <000f01cc5ee5$b7215b00$25641100$@net> <4E4F2FC2.28180.7F736D@stuart.lexacorp.com.pg> Message-ID: <000101cc5ef9$6e0d1300$4a273900$@net> Stuart: Thanks for the link. I think I understand why you would have named instances on the same machine. You might have one named instance for the engineering department of a very large company and a second named instance for the accounting department - with each department having their own databases and applications - and their own copy of SQL Server dedicated solely to their instance with both instances running on the same computer. (That computer better have a lot of horsepower - especially if you have multiple named instances running concurrently with lots of users on each instance.) Alan C. Lawhon -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Friday, August 19, 2011 10:54 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] SQL Server Book Two instances of SQL Server, means that you have two separate installations od the database engine running concurrently on the same machine The first time you instal SQL Server on a machine, it is automatically installed as the "Default Instance". You can then do a complete instal of SQL Server again, this time as a "Named Instance" where you specify a different name and different port(s) for it to operate on. The concept was introduces with SQL Server 2000. See http://msdn.microsoft.com/en-us/library/aa174516%28v=sql.80%29.aspx -- Stuart On 19 Aug 2011 at 22:03, Alan Lawhon wrote: > > What has me confused now is another section of the book where I read > that you can have "two instances" of SQL Server running simultaneously > on the same machine. If I recalled correctly, that would seem to > imply that an "instance" is a copy! (Maybe what that sentence was > implying is that you can have SQL Server running two different > [application] databases off the same SQL Server database engine > simultaneously - so the two separate databases are the "instances" - > while the [installed] SQL Server database engine is the entity.) > > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From jwcolby at colbyconsulting.com Sat Aug 20 07:47:45 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 20 Aug 2011 08:47:45 -0400 Subject: [dba-SQLServer] SQL Server Book In-Reply-To: <000101cc5ef9$6e0d1300$4a273900$@net> References: <000f01cc5ee5$b7215b00$25641100$@net> <4E4F2FC2.28180.7F736D@stuart.lexacorp.com.pg> <000101cc5ef9$6e0d1300$4a273900$@net> Message-ID: <4E4FACF1.2050200@colbyconsulting.com> SQL Server has properties for assigning physical cores to it as well as amounts of memory. I have a 16 core server with 32 gigs of memory. If I run two instances I can assign one SQL Server instance 4 cores and 8 gigs of memory, another instance 8 cores and 20 gigs of memory. All cores and memory not assigned are left for the OS. John W. Colby www.ColbyConsulting.com On 8/20/2011 1:24 AM, Alan Lawhon wrote: > Stuart: > > Thanks for the link. I think I understand why you would have named > instances on the same machine. You might have one named instance for the > engineering department of a very large company and a second named instance > for the accounting department - with each department having their own > databases and applications - and their own copy of SQL Server dedicated > solely to their instance with both instances running on the same computer. > (That computer better have a lot of horsepower - especially if you have > multiple named instances running concurrently with lots of users on each > instance.) > > Alan C. Lawhon > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Stuart > McLachlan > Sent: Friday, August 19, 2011 10:54 PM > To: Discussion concerning MS SQL Server > Subject: Re: [dba-SQLServer] SQL Server Book > > Two instances of SQL Server, means that you have two separate installations > od the > database engine running concurrently on the same machine > > The first time you instal SQL Server on a machine, it is automatically > installed as the "Default > Instance". You can then do a complete instal of SQL Server again, this > time as a "Named > Instance" where you specify a different name and different port(s) for it > to operate on. > > The concept was introduces with SQL Server 2000. > > See http://msdn.microsoft.com/en-us/library/aa174516%28v=sql.80%29.aspx > From jwcolby at colbyconsulting.com Sun Aug 28 17:40:51 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sun, 28 Aug 2011 18:40:51 -0400 Subject: [dba-SQLServer] Enforcing a rule Message-ID: <4E5AC3F3.2010000@colbyconsulting.com> I have a table where the client is either a parent type (from a list of parent types) or a professional type (from a list of professional types). I need to enforce that at least one of the fields is filled. IOW both cannot be null, but either one can be null or both can be filled. How do I do something like that? I have never used database level constraints other than pk/fk so I do not know how to set something like this up. Any detailed instructions or a pointer to a web page would be appreciated. Thanks, -- John W. Colby www.ColbyConsulting.com From rockysmolin at bchacc.com Sun Aug 28 18:52:11 2011 From: rockysmolin at bchacc.com (Rocky Smolin) Date: Sun, 28 Aug 2011 16:52:11 -0700 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <4E5AC3F3.2010000@colbyconsulting.com> References: <4E5AC3F3.2010000@colbyconsulting.com> Message-ID: <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> I would use the Before Update event of the form to verify that at last choice was made. Rocky -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: August 28, 2011 3:41 PM To: Sqlserver-Dba Subject: [dba-SQLServer] Enforcing a rule I have a table where the client is either a parent type (from a list of parent types) or a professional type (from a list of professional types). I need to enforce that at least one of the fields is filled. IOW both cannot be null, but either one can be null or both can be filled. How do I do something like that? I have never used database level constraints other than pk/fk so I do not know how to set something like this up. Any detailed instructions or a pointer to a web page would be appreciated. Thanks, -- John W. Colby www.ColbyConsulting.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From jwcolby at colbyconsulting.com Sun Aug 28 20:47:06 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sun, 28 Aug 2011 21:47:06 -0400 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> References: <4E5AC3F3.2010000@colbyconsulting.com> <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> Message-ID: <4E5AEF9A.40105@colbyconsulting.com> I can certainly do that but I am hoping to learn how to use the SQL Server engine to do these things. John W. Colby www.ColbyConsulting.com On 8/28/2011 7:52 PM, Rocky Smolin wrote: > I would use the Before Update event of the form to verify that at last > choice was made. > > Rocky > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby > Sent: August 28, 2011 3:41 PM > To: Sqlserver-Dba > Subject: [dba-SQLServer] Enforcing a rule > > I have a table where the client is either a parent type (from a list of > parent types) or a professional type (from a list of professional types). I > need to enforce that at least one of the fields is filled. IOW both cannot > be null, but either one can be null or both can be filled. > > How do I do something like that? I have never used database level > constraints other than pk/fk so I do not know how to set something like this > up. Any detailed instructions or a pointer to a web page would be > appreciated. > > Thanks, > > -- > John W. Colby > www.ColbyConsulting.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 fhtapia at gmail.com Sun Aug 28 20:49:13 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Sun, 28 Aug 2011 18:49:13 -0700 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <4E5AEF9A.40105@colbyconsulting.com> References: <4E5AC3F3.2010000@colbyconsulting.com> <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> <4E5AEF9A.40105@colbyconsulting.com> Message-ID: <-4307288342993314064@unknownmsgid> Have you looked into update triggers on tables? Sent from my mobile On Aug 28, 2011, at 6:47 PM, jwcolby wrote: > I can certainly do that but I am hoping to learn how to use the SQL Server engine to do these things. > > John W. Colby > www.ColbyConsulting.com > > On 8/28/2011 7:52 PM, Rocky Smolin wrote: >> I would use the Before Update event of the form to verify that at last >> choice was made. >> >> Rocky >> >> >> -----Original Message----- >> From: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby >> Sent: August 28, 2011 3:41 PM >> To: Sqlserver-Dba >> Subject: [dba-SQLServer] Enforcing a rule >> >> I have a table where the client is either a parent type (from a list of >> parent types) or a professional type (from a list of professional types). I >> need to enforce that at least one of the fields is filled. IOW both cannot >> be null, but either one can be null or both can be filled. >> >> How do I do something like that? I have never used database level >> constraints other than pk/fk so I do not know how to set something like this >> up. Any detailed instructions or a pointer to a web page would be >> appreciated. >> >> Thanks, >> >> -- >> John W. Colby >> www.ColbyConsulting.com >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From lawhonac at hiwaay.net Mon Aug 29 02:22:21 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Mon, 29 Aug 2011 02:22:21 -0500 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <-4307288342993314064@unknownmsgid> References: <4E5AC3F3.2010000@colbyconsulting.com> <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> <4E5AEF9A.40105@colbyconsulting.com> <-4307288342993314064@unknownmsgid> Message-ID: <000101cc661c$64a871e0$2df955a0$@net> John: I'm not sure exactly how triggers would apply to your specific situation, (i.e. exactly how you would go about coding a solution to your problem), but Francisco may be on to something. In "Section 4 - Advanced SQL skills" on pages 470 and 471 of "murach's SQL Server 2008 for developers" book, the author has a section entitled "How to use triggers to enforce data consistency". The problem (and solution) he presents may not be precisely applicable to the problem you're describing, but you may be able to get a good idea of how to go about solving your problem from reading those pages. I'm in the early stages of trying to figure out and "learn" SQL Server. >From what I've read so far, triggers seem to be designed to ensure data validation (data consistency) and maintain relationships between tables. What you're trying to do seems related to this, so maybe a stored procedure that includes a trigger will solve your problem. This is great - I'm now a SQL Server consultant! :-))) Alan C. Lawhon -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Francisco Tapia Sent: Sunday, August 28, 2011 8:49 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Enforcing a rule Have you looked into update triggers on tables? Sent from my mobile On Aug 28, 2011, at 6:47 PM, jwcolby wrote: > I can certainly do that but I am hoping to learn how to use the SQL Server engine to do these things. > > John W. Colby > www.ColbyConsulting.com > > On 8/28/2011 7:52 PM, Rocky Smolin wrote: >> I would use the Before Update event of the form to verify that at last >> choice was made. >> >> Rocky >> >> >> -----Original Message----- >> From: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby >> Sent: August 28, 2011 3:41 PM >> To: Sqlserver-Dba >> Subject: [dba-SQLServer] Enforcing a rule >> >> I have a table where the client is either a parent type (from a list of >> parent types) or a professional type (from a list of professional types). I >> need to enforce that at least one of the fields is filled. IOW both cannot >> be null, but either one can be null or both can be filled. >> >> How do I do something like that? I have never used database level >> constraints other than pk/fk so I do not know how to set something like this >> up. Any detailed instructions or a pointer to a web page would be >> appreciated. >> >> Thanks, >> >> -- >> John W. Colby >> www.ColbyConsulting.com >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From Gustav at cactus.dk Mon Aug 29 02:25:56 2011 From: Gustav at cactus.dk (Gustav Brock) Date: Mon, 29 Aug 2011 09:25:56 +0200 Subject: [dba-SQLServer] Enforcing a rule Message-ID: Hi John Just add a new constraint, name it properly, and add an expression that states the rule you explain, like: Not ([ParentType] Is Null And [ProfessionalType] Is Null) And mark: Enforce for INSERTs and UPDATEs /gustav >>> jwcolby at colbyconsulting.com 29-08-2011 00:40 >>> I have a table where the client is either a parent type (from a list of parent types) or a professional type (from a list of professional types). I need to enforce that at least one of the fields is filled. IOW both cannot be null, but either one can be null or both can be filled. How do I do something like that? I have never used database level constraints other than pk/fk so I do not know how to set something like this up. Any detailed instructions or a pointer to a web page would be appreciated. Thanks, -- John W. Colby www.ColbyConsulting.com From fuller.artful at gmail.com Mon Aug 29 04:56:32 2011 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 29 Aug 2011 05:56:32 -0400 Subject: [dba-SQLServer] Enforcing a rule In-Reply-To: <000101cc661c$64a871e0$2df955a0$@net> References: <4E5AC3F3.2010000@colbyconsulting.com> <01A2935C8A474586B5A1BEF00DD96A2A@HAL9007> <4E5AEF9A.40105@colbyconsulting.com> <-4307288342993314064@unknownmsgid> <000101cc661c$64a871e0$2df955a0$@net> Message-ID: Besdies ensuring data consistency, triggers are often used for maintaining an audit trail. On an insert it doesn't make much sense, but on update and delete it does (you can write the old row to a table before doing the actual update, or write the old row to a table before doing the delete). IIRC, Susan and I wrote about that some time ago in TechRepublic. Arthur From jwcolby at colbyconsulting.com Mon Aug 29 11:32:39 2011 From: jwcolby at colbyconsulting.com (jwcolby) Date: Mon, 29 Aug 2011 12:32:39 -0400 Subject: [dba-SQLServer] Are indexes unique Message-ID: <4E5BBF27.90305@colbyconsulting.com> If I have a clustered index on my PK (autoincrement int) and that is used in all indexes without specififying that it be used (my understanding) does that mean that every index is by definition unique? Do I need to check the unique box when creating the index? Or does "unique" only count on the actual fields specified in the index? -- John W. Colby www.ColbyConsulting.com From fuller.artful at gmail.com Mon Aug 29 12:12:41 2011 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 29 Aug 2011 13:12:41 -0400 Subject: [dba-SQLServer] Are indexes unique In-Reply-To: <4E5BBF27.90305@colbyconsulting.com> References: <4E5BBF27.90305@colbyconsulting.com> Message-ID: Unique only counts on the specified fields. A. On Mon, Aug 29, 2011 at 12:32 PM, jwcolby wrote: > If I have a clustered index on my PK (autoincrement int) and that is used > in all indexes without specififying that it be used (my understanding) does > that mean that every index is by definition unique? Do I need to check the > unique box when creating the index? > > Or does "unique" only count on the actual fields specified in the index? > From lawhonac at hiwaay.net Mon Aug 29 17:56:20 2011 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Mon, 29 Aug 2011 17:56:20 -0500 Subject: [dba-SQLServer] Success!! (I Think ...) Message-ID: <000701cc669e$de755880$9b600980$@net> It took me the better part of 4-5 hours, (including installation of all the "prerequisite" software along with several service pack upgrades after the installation), but I managed to successfully download and install the SQL Server 2008 R2 "Express" edition (with Books Online) to my Windows XP SP3 notebook computer. It took a bit of head scratching figuring it all out, (there's a bunch of "stuff" about Windows authentication that I need to learn), but I finally got it all to work. I'll download and attach the Accounts Payable sample database that goes with my Murach SQL Server developer's book tomorrow. Then I'll be on my way to becoming a SQL Server expert. I aspire to be half-to-three-quarters as great as Rocky, John Colby, Stuart McLachlan, Gustav Brock, Francisco Tapia, Susan Harkins, Gary Kjos, and Arthur Fuller. (Did I leave anybody out?) If I can get as smart as you guys (and Susan) at my advanced age, that will be an accomplishment! I suppose I should have started working on this a year ago - when I still had some money - but I was convinced that I was a 55-year-old version of Doyle Brunson on my way to earning vast riches at the poker table. Live and learn I suppose . Alan C. Lawhon From newsgrps at dalyn.co.nz Tue Aug 30 03:41:12 2011 From: newsgrps at dalyn.co.nz (newsgrps) Date: Tue, 30 Aug 2011 20:41:12 +1200 Subject: [dba-SQLServer] Joining temp tables in SPROC Message-ID: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> Group, Can someone please explain why this is I get an error "Must declare the variable ttmpWeeks" when I try to save the following in a stored procedure: ALTER PROCEDURE sprptProductionSummary ( @txtDate1 varchar(20), @txtDate2 varchar(20) ) AS SET NOCOUNT ON SET DATEFIRST 1 -- Monday DECLARE @ttmpWeeks table (WeekNo tinyint) DECLARE @tmpDate as datetime SET @tmpDate = @txtDate1 INSERT INTO @ttmpWeeks (WeekNo) VALUES (DATEPART(week, @tmpDate)) SET @tmpDate = DATEADD(week, 1, @tmpDate) WHILE @tmpdate < @txtDate2 BEGIN INSERT INTO @ttmpWeeks (WeekNo) VALUES (DATEPART(week, @tmpDate)) SET @tmpDate = DATEADD(week, 1, @tmpDate) END SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS KnittedWeight FROM dbo.tblRoll WHERE KnitDate BETWEEN @txtDate1 AND @txtDate2 GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum {rest of code continues} However, if I change the last line to GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = spKnit.WeekNum it saves and works. Why doesn't it accept the table part of the WeekNo field? Regards David Emerson Dalyn Software Ltd Wellington, New Zealand From garykjos at gmail.com Tue Aug 30 03:57:33 2011 From: garykjos at gmail.com (Gary Kjos) Date: Tue, 30 Aug 2011 03:57:33 -0500 Subject: [dba-SQLServer] [dba-OT] Success!! (I Think ...) In-Reply-To: <000701cc669e$de755880$9b600980$@net> References: <000701cc669e$de755880$9b600980$@net> Message-ID: Great! There are actually a lot of statistical analysis functions within Analysis Services which is part of the full version of SQL Server - not sure if it's in Express - that you might be able to use to analyze your poker game too. ;-) Keep up the good work Alan. You are gaining momentum. GK On Mon, Aug 29, 2011 at 5:56 PM, Alan Lawhon wrote: > It took me the better part of 4-5 hours, (including installation of all the > "prerequisite" software along with several service pack upgrades after the > installation), but I managed to successfully download and install the SQL > Server 2008 R2 "Express" edition (with Books Online) to my Windows XP SP3 > notebook computer. ?It took a bit of head scratching figuring it all out, > (there's a bunch of "stuff" about Windows authentication that I need to > learn), but I finally got it all to work. > > I'll download and attach the Accounts Payable sample database that goes with > my Murach SQL Server developer's book tomorrow. ?Then I'll be on my way to > becoming a SQL Server expert. ?I aspire to be half-to-three-quarters as > great as Rocky, John Colby, Stuart McLachlan, Gustav Brock, Francisco Tapia, > Susan Harkins, Gary Kjos, and Arthur Fuller. ?(Did I leave anybody out?) > > If I can get as smart as you guys (and Susan) at my advanced age, that will > be an accomplishment! > > I suppose I should have started working on this a year ago - when I still > had some money - but I was convinced that I was a 55-year-old version of > Doyle Brunson on my way to earning vast riches at the poker table. ?Live and > learn I suppose . > > Alan C. Lawhon > > > > _______________________________________________ > dba-OT mailing list > dba-OT at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-ot > Website: http://www.databaseadvisors.com > -- Gary Kjos garykjos at gmail.com From fuller.artful at gmail.com Tue Aug 30 04:44:47 2011 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 30 Aug 2011 05:44:47 -0400 Subject: [dba-SQLServer] [dba-OT] Success!! (I Think ...) In-Reply-To: References: <000701cc669e$de755880$9b600980$@net> Message-ID: BI + Poker = Broke :) The most intelligent poker play is Step Away From the Table. If you must gamble, try speed chess + the doubling cube (borrowed from backgammon), an innovation introduced by my friend and backgammon-mentor Vladimir Dobrich. Arthur On Tue, Aug 30, 2011 at 4:57 AM, Gary Kjos wrote: > Great! > > There are actually a lot of statistical analysis functions within > Analysis Services which is part of the full version of SQL Server - > not sure if it's in Express - that you might be able to use to analyze > your poker game too. ;-) > > Keep up the good work Alan. You are gaining momentum. > > GK > > From fhtapia at gmail.com Tue Aug 30 08:19:25 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 30 Aug 2011 06:19:25 -0700 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: i'm not sure, but i've always used an alias when I join my temp tables including variable tables, so my change would read FROM @ttmpWeeks AS tWeeks then your ON statment can read tWeeks.WeekNo = join clause -Francisco http://bit.ly/sqlthis | Tsql and More... On Tue, Aug 30, 2011 at 1:41 AM, newsgrps wrote: > Group, > > Can someone please explain why this is > > I get an error "Must declare the variable ttmpWeeks" when I try to save the > following in a stored procedure: > > ALTER PROCEDURE sprptProductionSummary > ( > @txtDate1 varchar(20), > @txtDate2 varchar(20) > ) > AS > SET NOCOUNT ON > > SET DATEFIRST 1 -- Monday > > DECLARE @ttmpWeeks table (WeekNo tinyint) > > DECLARE @tmpDate as datetime > > SET @tmpDate = @txtDate1 > > INSERT INTO @ttmpWeeks (WeekNo) > VALUES (DATEPART(week, @tmpDate)) > > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > WHILE @tmpdate < @txtDate2 > BEGIN > INSERT INTO @ttmpWeeks (WeekNo) > VALUES (DATEPART(week, @tmpDate)) > > SET @tmpDate = DATEADD(week, 1, @tmpDate) > END > > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS KnittedWeight > FROM dbo.tblRoll > WHERE KnitDate BETWEEN > @txtDate1 AND @txtDate2 > GROUP BY DATEPART(week, > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum > > {rest of code continues} > > However, if I change the last line to > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = > spKnit.WeekNum > it saves and works. > > Why doesn't it accept the table part of the WeekNo field? > > > Regards > > David Emerson > Dalyn Software Ltd > Wellington, New Zealand ______________________________**_________________ > dba-SQLServer mailing list > dba-SQLServer@**databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.**com > > From newsgrps at dalyn.co.nz Tue Aug 30 14:42:18 2011 From: newsgrps at dalyn.co.nz (newsgrps) Date: Wed, 31 Aug 2011 07:42:18 +1200 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Thanks Francisco. That worked and makes me more comfortable. David At 31/08/2011, Francisco Tapia wrote: >i'm not sure, but i've always used an alias when I join my temp tables >including variable tables, so my change would read > >FROM @ttmpWeeks AS tWeeks > >then your ON statment can read tWeeks.WeekNo = join clause > >-Francisco >http://bit.ly/sqlthis | Tsql and More... > > > > > >On Tue, Aug 30, 2011 at 1:41 AM, newsgrps wrote: > > > Group, > > > > Can someone please explain why this is > > > > I get an error "Must declare the variable ttmpWeeks" when I try to save the > > following in a stored procedure: > > > > ALTER PROCEDURE sprptProductionSummary > > ( > > @txtDate1 varchar(20), > > @txtDate2 varchar(20) > > ) > > AS > > SET NOCOUNT ON > > > > SET DATEFIRST 1 -- Monday > > > > DECLARE @ttmpWeeks table (WeekNo tinyint) > > > > DECLARE @tmpDate as datetime > > > > SET @tmpDate = @txtDate1 > > > > INSERT INTO @ttmpWeeks (WeekNo) > > VALUES (DATEPART(week, @tmpDate)) > > > > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > > > WHILE @tmpdate < @txtDate2 > > BEGIN > > INSERT INTO @ttmpWeeks (WeekNo) > > VALUES (DATEPART(week, @tmpDate)) > > > > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > END > > > > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight > > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS > KnittedWeight > > FROM dbo.tblRoll > > WHERE KnitDate BETWEEN > > @txtDate1 AND @txtDate2 > > GROUP BY DATEPART(week, > > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum > > > > {rest of code continues} > > > > However, if I change the last line to > > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = > > spKnit.WeekNum > > it saves and works. > > > > Why doesn't it accept the table part of the WeekNo field? > > > > > > Regards > > > > David Emerson > > Dalyn Software Ltd > > Wellington, New Zealand ______________________________**_________________ From marklbreen at gmail.com Wed Aug 31 10:36:32 2011 From: marklbreen at gmail.com (Mark Breen) Date: Wed, 31 Aug 2011 16:36:32 +0100 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: Hi David, what is the difference between Temp table and using a variable tables. I never used such an exotic thing ? thanks Mark On 30 August 2011 20:42, newsgrps wrote: > Thanks Francisco. That worked and makes me more comfortable. > > David > > > At 31/08/2011, Francisco Tapia wrote: > >> i'm not sure, but i've always used an alias when I join my temp tables >> including variable tables, so my change would read >> >> FROM @ttmpWeeks AS tWeeks >> >> then your ON statment can read tWeeks.WeekNo = join clause >> >> -Francisco >> http://bit.ly/sqlthis | Tsql and More... >> >> >> >> >> >> On Tue, Aug 30, 2011 at 1:41 AM, newsgrps wrote: >> >> > Group, >> > >> > Can someone please explain why this is >> > >> > I get an error "Must declare the variable ttmpWeeks" when I try to save >> the >> > following in a stored procedure: >> > >> > ALTER PROCEDURE sprptProductionSummary >> > ( >> > @txtDate1 varchar(20), >> > @txtDate2 varchar(20) >> > ) >> > AS >> > SET NOCOUNT ON >> > >> > SET DATEFIRST 1 -- Monday >> > >> > DECLARE @ttmpWeeks table (WeekNo tinyint) >> > >> > DECLARE @tmpDate as datetime >> > >> > SET @tmpDate = @txtDate1 >> > >> > INSERT INTO @ttmpWeeks (WeekNo) >> > VALUES (DATEPART(week, @tmpDate)) >> > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) >> > >> > WHILE @tmpdate < @txtDate2 >> > BEGIN >> > INSERT INTO @ttmpWeeks (WeekNo) >> > VALUES (DATEPART(week, @tmpDate)) >> > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) >> > END >> > >> > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight >> > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, >> > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS >> KnittedWeight >> > FROM dbo.tblRoll >> > WHERE KnitDate BETWEEN >> > @txtDate1 AND @txtDate2 >> > GROUP BY DATEPART(week, >> > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum >> > >> > {rest of code continues} >> > >> > However, if I change the last line to >> > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = >> > spKnit.WeekNum >> > it saves and works. >> > >> > Why doesn't it accept the table part of the WeekNo field? >> > >> > >> > Regards >> > >> > David Emerson >> > Dalyn Software Ltd >> > Wellington, New Zealand ______________________________** >> **_________________ >> > > ______________________________**_________________ > dba-SQLServer mailing list > dba-SQLServer@**databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.**com > > From fhtapia at gmail.com Wed Aug 31 10:43:01 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 31 Aug 2011 08:43:01 -0700 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: Variable tables are generally tables in memory and are meant to be light so that they can survive in memory. A major advantage is you can convert comma delimited lists to variable tables (generally a small-ish table) and have all the benefits of a normal table but in RAM. Temp tables if small will remain in memory, but if the server is busy with other major tasks that demand memory, your temp table will be written to disk. In general a placeholder is always created, but your data may just be in RAM vs on disk, my recommendation for people using variable tables or temp tables is that if you're going to be hauling a lot of data (or potentially a lot of data) then you should architect your solution with temp tables, otherwise for smaller datasets a variable table is a great performance option. -Francisco http://bit.ly/sqlthis | Tsql and More... On Wed, Aug 31, 2011 at 8:36 AM, Mark Breen wrote: > Hi David, > > what is the difference between Temp table and using a variable tables. I > never used such an exotic thing ? > > thanks > > Mark > > > On 30 August 2011 20:42, newsgrps wrote: > > > Thanks Francisco. That worked and makes me more comfortable. > > > > David > > > > > > At 31/08/2011, Francisco Tapia wrote: > > > >> i'm not sure, but i've always used an alias when I join my temp tables > >> including variable tables, so my change would read > >> > >> FROM @ttmpWeeks AS tWeeks > >> > >> then your ON statment can read tWeeks.WeekNo = join clause > >> > >> -Francisco > >> http://bit.ly/sqlthis | Tsql and More... > >> > >> > >> > >> > >> > >> On Tue, Aug 30, 2011 at 1:41 AM, newsgrps wrote: > >> > >> > Group, > >> > > >> > Can someone please explain why this is > >> > > >> > I get an error "Must declare the variable ttmpWeeks" when I try to > save > >> the > >> > following in a stored procedure: > >> > > >> > ALTER PROCEDURE sprptProductionSummary > >> > ( > >> > @txtDate1 varchar(20), > >> > @txtDate2 varchar(20) > >> > ) > >> > AS > >> > SET NOCOUNT ON > >> > > >> > SET DATEFIRST 1 -- Monday > >> > > >> > DECLARE @ttmpWeeks table (WeekNo tinyint) > >> > > >> > DECLARE @tmpDate as datetime > >> > > >> > SET @tmpDate = @txtDate1 > >> > > >> > INSERT INTO @ttmpWeeks (WeekNo) > >> > VALUES (DATEPART(week, @tmpDate)) > >> > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > >> > > >> > WHILE @tmpdate < @txtDate2 > >> > BEGIN > >> > INSERT INTO @ttmpWeeks (WeekNo) > >> > VALUES (DATEPART(week, @tmpDate)) > >> > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > >> > END > >> > > >> > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS KnittedWeight > >> > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > >> > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS > >> KnittedWeight > >> > FROM dbo.tblRoll > >> > WHERE KnitDate BETWEEN > >> > @txtDate1 AND @txtDate2 > >> > GROUP BY DATEPART(week, > >> > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = spKnit.WeekNum > >> > > >> > {rest of code continues} > >> > > >> > However, if I change the last line to > >> > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = > >> > spKnit.WeekNum > >> > it saves and works. > >> > > >> > Why doesn't it accept the table part of the WeekNo field? > >> > > >> > > >> > Regards > >> > > >> > David Emerson > >> > Dalyn Software Ltd > >> > Wellington, New Zealand ______________________________** > >> **_________________ > >> > > > > ______________________________**_________________ > > dba-SQLServer mailing list > > dba-SQLServer@**databaseadvisors.com > > > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver< > 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 marklbreen at gmail.com Wed Aug 31 10:48:26 2011 From: marklbreen at gmail.com (Mark Breen) Date: Wed, 31 Aug 2011 16:48:26 +0100 Subject: [dba-SQLServer] Mirroring SQL DB's over the internet (as opposed to the LAN) Message-ID: Hello All, I recently set up a mirror of a db over the Lan and was shocked at how easy it is to do. I wonder whether it is feasible to run a mirror over a DSL line. Would it be terrible performance - is it usually only used over LAN speeds? I know I can just try it, but just in case you have any advice it will be welcome, In case you do not know,the steps are 1) switch recovery mode to Full 2) backup full db 3) restore full db to another server but set restore mode to "Restore with no recovery". It is the second radio button on same pane where you click "Verify backup". 4) On the properties tab of your main db, go to mirroring, use the wizard to click through about four steps where you set the authentication and bingo you have a mirrored server. note: I skipped the option of a witness server. Once you do that, you have a red hot backup of your main db at all times. thanks Mark From marklbreen at gmail.com Wed Aug 31 10:56:22 2011 From: marklbreen at gmail.com (Mark Breen) Date: Wed, 31 Aug 2011 16:56:22 +0100 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: Hello Francisco, Thank you for your time to respond. That is extremely interesting and happens to coincide with some sql that I am working on currently. I have a few sprocs that search through all tables, all columns, all schemas for some text and uses a temp table for temp storage on each iteration. I did not yet see how to avoid using a cursor, so the temp table is used each time I loop. Currently the routine takes 4 hours and I had to return my intel i7 to standard settings because it was reaching 90 degrees when all cores were maxed out! I can do some timings so when I do, I will post the results. thanks again, Mark On 31 August 2011 16:43, Francisco Tapia wrote: > Variable tables are generally tables in memory and are meant to be light so > that they can survive in memory. A major advantage is you can convert > comma > delimited lists to variable tables (generally a small-ish table) and have > all the benefits of a normal table but in RAM. Temp tables if small will > remain in memory, but if the server is busy with other major tasks that > demand memory, your temp table will be written to disk. In general a > placeholder is always created, but your data may just be in RAM vs on disk, > my recommendation for people using variable tables or temp tables is that > if > you're going to be hauling a lot of data (or potentially a lot of data) > then > you should architect your solution with temp tables, otherwise for smaller > datasets a variable table is a great performance option. > > > -Francisco > http://bit.ly/sqlthis | Tsql and More... > > > > > > On Wed, Aug 31, 2011 at 8:36 AM, Mark Breen wrote: > > > Hi David, > > > > what is the difference between Temp table and using a variable tables. I > > never used such an exotic thing ? > > > > thanks > > > > Mark > > > > > > On 30 August 2011 20:42, newsgrps wrote: > > > > > Thanks Francisco. That worked and makes me more comfortable. > > > > > > David > > > > > > > > > At 31/08/2011, Francisco Tapia wrote: > > > > > >> i'm not sure, but i've always used an alias when I join my temp tables > > >> including variable tables, so my change would read > > >> > > >> FROM @ttmpWeeks AS tWeeks > > >> > > >> then your ON statment can read tWeeks.WeekNo = join clause > > >> > > >> -Francisco > > >> http://bit.ly/sqlthis | Tsql and More... > > >> > > >> > > >> > > >> > > >> > > >> On Tue, Aug 30, 2011 at 1:41 AM, newsgrps > wrote: > > >> > > >> > Group, > > >> > > > >> > Can someone please explain why this is > > >> > > > >> > I get an error "Must declare the variable ttmpWeeks" when I try to > > save > > >> the > > >> > following in a stored procedure: > > >> > > > >> > ALTER PROCEDURE sprptProductionSummary > > >> > ( > > >> > @txtDate1 varchar(20), > > >> > @txtDate2 varchar(20) > > >> > ) > > >> > AS > > >> > SET NOCOUNT ON > > >> > > > >> > SET DATEFIRST 1 -- Monday > > >> > > > >> > DECLARE @ttmpWeeks table (WeekNo tinyint) > > >> > > > >> > DECLARE @tmpDate as datetime > > >> > > > >> > SET @tmpDate = @txtDate1 > > >> > > > >> > INSERT INTO @ttmpWeeks (WeekNo) > > >> > VALUES (DATEPART(week, @tmpDate)) > > >> > > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > >> > > > >> > WHILE @tmpdate < @txtDate2 > > >> > BEGIN > > >> > INSERT INTO @ttmpWeeks (WeekNo) > > >> > VALUES (DATEPART(week, @tmpDate)) > > >> > > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > >> > END > > >> > > > >> > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS > KnittedWeight > > >> > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > > >> > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS > > >> KnittedWeight > > >> > FROM dbo.tblRoll > > >> > WHERE KnitDate > BETWEEN > > >> > @txtDate1 AND @txtDate2 > > >> > GROUP BY > DATEPART(week, > > >> > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = > spKnit.WeekNum > > >> > > > >> > {rest of code continues} > > >> > > > >> > However, if I change the last line to > > >> > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo = > > >> > spKnit.WeekNum > > >> > it saves and works. > > >> > > > >> > Why doesn't it accept the table part of the WeekNo field? > > >> > > > >> > > > >> > Regards > > >> > > > >> > David Emerson > > >> > Dalyn Software Ltd > > >> > Wellington, New Zealand ______________________________** > > >> **_________________ > > >> > > > > > > ______________________________**_________________ > > > dba-SQLServer mailing list > > > dba-SQLServer@**databaseadvisors.com < > dba-SQLServer at databaseadvisors.com > > > > > > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver< > > 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 fhtapia at gmail.com Wed Aug 31 11:07:33 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 31 Aug 2011 09:07:33 -0700 Subject: [dba-SQLServer] Joining temp tables in SPROC In-Reply-To: References: <20110830084330.FOET6405.mta02.xtra.co.nz@David-PC.dalyn.co.nz> <20110830194439.XYME13922.mta03.xtra.co.nz@David-PC.dalyn.co.nz> Message-ID: I wrote up a script that leverages another developer's solution, I co-wrote this article with Susan Harkins... http://www.devx.com/dbzone/Article/42340/1954?pf=true maybe you can extend or improve on what i've done to help leverage, I'm not sure if the link will prompt you to have a free login account (i may have my browser cookies saved, if so I'll re-post the script here) http://www.devx.com/dbzone/Article/42340/1954/1763?supportItem=1 -Francisco http://bit.ly/sqlthis | Tsql and More... On Wed, Aug 31, 2011 at 8:56 AM, Mark Breen wrote: > Hello Francisco, > > Thank you for your time to respond. > > That is extremely interesting and happens to coincide with some sql that I > am working on currently. > > I have a few sprocs that search through all tables, all columns, all > schemas > for some text and uses a temp table for temp storage on each iteration. > > I did not yet see how to avoid using a cursor, so the temp table is used > each time I loop. > > Currently the routine takes 4 hours and I had to return my intel i7 to > standard settings because it was reaching 90 degrees when all cores were > maxed out! > > I can do some timings so when I do, I will post the results. > > thanks again, > Mark > > > > > On 31 August 2011 16:43, Francisco Tapia wrote: > > > Variable tables are generally tables in memory and are meant to be light > so > > that they can survive in memory. A major advantage is you can convert > > comma > > delimited lists to variable tables (generally a small-ish table) and have > > all the benefits of a normal table but in RAM. Temp tables if small will > > remain in memory, but if the server is busy with other major tasks that > > demand memory, your temp table will be written to disk. In general a > > placeholder is always created, but your data may just be in RAM vs on > disk, > > my recommendation for people using variable tables or temp tables is that > > if > > you're going to be hauling a lot of data (or potentially a lot of data) > > then > > you should architect your solution with temp tables, otherwise for > smaller > > datasets a variable table is a great performance option. > > > > > > -Francisco > > http://bit.ly/sqlthis | Tsql and More... > > > > > > > > > > > > On Wed, Aug 31, 2011 at 8:36 AM, Mark Breen > wrote: > > > > > Hi David, > > > > > > what is the difference between Temp table and using a variable tables. > I > > > never used such an exotic thing ? > > > > > > thanks > > > > > > Mark > > > > > > > > > On 30 August 2011 20:42, newsgrps wrote: > > > > > > > Thanks Francisco. That worked and makes me more comfortable. > > > > > > > > David > > > > > > > > > > > > At 31/08/2011, Francisco Tapia wrote: > > > > > > > >> i'm not sure, but i've always used an alias when I join my temp > tables > > > >> including variable tables, so my change would read > > > >> > > > >> FROM @ttmpWeeks AS tWeeks > > > >> > > > >> then your ON statment can read tWeeks.WeekNo = join clause > > > >> > > > >> -Francisco > > > >> http://bit.ly/sqlthis | Tsql and More... > > > >> > > > >> > > > >> > > > >> > > > >> > > > >> On Tue, Aug 30, 2011 at 1:41 AM, newsgrps > > wrote: > > > >> > > > >> > Group, > > > >> > > > > >> > Can someone please explain why this is > > > >> > > > > >> > I get an error "Must declare the variable ttmpWeeks" when I try to > > > save > > > >> the > > > >> > following in a stored procedure: > > > >> > > > > >> > ALTER PROCEDURE sprptProductionSummary > > > >> > ( > > > >> > @txtDate1 varchar(20), > > > >> > @txtDate2 varchar(20) > > > >> > ) > > > >> > AS > > > >> > SET NOCOUNT ON > > > >> > > > > >> > SET DATEFIRST 1 -- Monday > > > >> > > > > >> > DECLARE @ttmpWeeks table (WeekNo tinyint) > > > >> > > > > >> > DECLARE @tmpDate as datetime > > > >> > > > > >> > SET @tmpDate = @txtDate1 > > > >> > > > > >> > INSERT INTO @ttmpWeeks (WeekNo) > > > >> > VALUES (DATEPART(week, @tmpDate)) > > > >> > > > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > > >> > > > > >> > WHILE @tmpdate < @txtDate2 > > > >> > BEGIN > > > >> > INSERT INTO @ttmpWeeks (WeekNo) > > > >> > VALUES (DATEPART(week, @tmpDate)) > > > >> > > > > >> > SET @tmpDate = DATEADD(week, 1, @tmpDate) > > > >> > END > > > >> > > > > >> > SELECT WeekNo, ISNULL(spKnit.KnittedWeight,0) AS > > KnittedWeight > > > >> > FROM @ttmpWeeks LEFT OUTER JOIN (SELECT DATEPART(week, > > > >> > dbo.tblRoll.KnitDate) AS WeekNum, ISNULL(SUM(KnitWeight),0) AS > > > >> KnittedWeight > > > >> > FROM dbo.tblRoll > > > >> > WHERE KnitDate > > BETWEEN > > > >> > @txtDate1 AND @txtDate2 > > > >> > GROUP BY > > DATEPART(week, > > > >> > dbo.tblRoll.KnitDate)) AS spKnit ON @ttmpWeeks.WeekNo = > > spKnit.WeekNum > > > >> > > > > >> > {rest of code continues} > > > >> > > > > >> > However, if I change the last line to > > > >> > GROUP BY DATEPART(week, dbo.tblRoll.KnitDate)) AS spKnit ON WeekNo > = > > > >> > spKnit.WeekNum > > > >> > it saves and works. > > > >> > > > > >> > Why doesn't it accept the table part of the WeekNo field? > > > >> > > > > >> > > > > >> > Regards > > > >> > > > > >> > David Emerson > > > >> > Dalyn Software Ltd > > > >> > Wellington, New Zealand ______________________________** > > > >> **_________________ > > > >> > > > > > > > > ______________________________**_________________ > > > > dba-SQLServer mailing list > > > > dba-SQLServer@**databaseadvisors.com < > > dba-SQLServer at databaseadvisors.com > > > > > > > > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver< > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver> > > > > http://www.databaseadvisors.**com > > > > > > > > > > > _______________________________________________ > > > dba-SQLServer mailing list > > > dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fhtapia at gmail.com Wed Aug 31 12:16:35 2011 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 31 Aug 2011 10:16:35 -0700 Subject: [dba-SQLServer] Mirroring SQL DB's over the internet (as opposed to the LAN) In-Reply-To: References: Message-ID: I think you can definitely run in this scenario, but there are some things you want to think about...performance will be greatly affected because in the past when I worked with db mirroring, users had to wait until the log shipping completed on the destination database. I remember that this was one of the big performance features that was being worked on for 2008, but I never returned to see if this was actually fixed, the demo's of course made it seem like you could have db mirroring across continents w/o even the thought of latency in the mix. report back your results, I am very interested. -Francisco http://bit.ly/sqlthis | Tsql and More... On Wed, Aug 31, 2011 at 8:48 AM, Mark Breen wrote: > Hello All, > > I recently set up a mirror of a db over the Lan and was shocked at how easy > it is to do. > > I wonder whether it is feasible to run a mirror over a DSL line. Would it > be terrible performance - is it usually only used over LAN speeds? > > I know I can just try it, but just in case you have any advice it will be > welcome, > > In case you do not know,the steps are > > 1) switch recovery mode to Full > 2) backup full db > 3) restore full db to another server but set restore mode to "Restore with > no recovery". It is the second radio button on same pane where you click > "Verify backup". > 4) On the properties tab of your main db, go to mirroring, use the wizard > to > click through about four steps where you set the authentication and bingo > you have a mirrored server. > note: I skipped the option of a witness server. > > Once you do that, you have a red hot backup of your main db at all times. > > thanks > > Mark > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > >