From darryl at whittleconsulting.com.au Mon Jan 6 23:18:19 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Tue, 7 Jan 2014 05:18:19 +0000 Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" Message-ID: <4003064f16494290b3d08a560a8044cb@HKXPR04MB184.apcprd04.prod.outlook.com> Hi There, I am hoping someone can help me out here, although it seems rather quiet on this list, but hey, I will try here first. Using SQL Server 2008 R2 express. Been migrating an existing MS Access Solution to SQL Server and so far things have been going fairly well. However I have bumped into an issue when updating a bit of MS Access code to a SQL Server Stored Proc. Indeed, maybe I don't even need to use a Stored Proc as I have some code that passes the SQL String directly to the server via VBA and can run it that way. For some reason using an SP seemed the better solution, but I am open to Ideas and opinions here. The Current VBA code is UPDATE Key_tblPortions INNER JOIN Temp_tblPortionSteps ON Key_tblPortions.PortionID = Temp_tblPortionSteps.PortionID SET Key_tblPortions.EveID = [Temp_tblPortionSteps].[EveID] The SP code on the Server is pretty much identical (which usually work fine, albeit with some minor tweaks if necessary) UPDATE dbo.Key_tblPortions INNER JOIN dbo.Temp_tblPortionSteps ON dbo.Key_tblPortions.PortionID = dbo.Temp_tblPortionSteps.PortionID SET dbo.Key_tblPortions.EveID = [dbo.Temp_tblPortionSteps].[EveID] However in this instance SQL Server is returning the error "Incorrect syntax near the keyword 'INNER'." Which is both perfectly clear but confusing for me at the same time. The set up is I have two tables linked on and ID field (PortionID). The EveID field in Table2 should be written in to the matching EveID field in Table1 where their portionID's match. Simple enough, but not sure how to do this in the SP on SQL Server. Any suggestions? Cheers Darryl. From darryl at whittleconsulting.com.au Mon Jan 6 23:33:48 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Tue, 7 Jan 2014 05:33:48 +0000 Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" In-Reply-To: <4003064f16494290b3d08a560a8044cb@HKXPR04MB184.apcprd04.prod.outlook.com> References: <4003064f16494290b3d08a560a8044cb@HKXPR04MB184.apcprd04.prod.outlook.com> Message-ID: <3ff2ce0f8e804a45be90d3e2f6189c31@HKXPR04MB184.apcprd04.prod.outlook.com> Aaaah.... That is typical. Sent this email. Figured it out about 30 seconds later. Duh! :) '------------------------------------------------------------------------------------------------------------------ UPDATE dbo.Key_tblPortions SET dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID FROM dbo.Key_tblPortions INNER JOIN dbo.Temp_tblPortionSteps ON dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID '------------------------------------------------------------------------------------------------------------------ Cheers Darryl -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Tuesday, 7 January 2014 4:18 PM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" Hi There, I am hoping someone can help me out here, although it seems rather quiet on this list, but hey, I will try here first. Using SQL Server 2008 R2 express. Been migrating an existing MS Access Solution to SQL Server and so far things have been going fairly well. However I have bumped into an issue when updating a bit of MS Access code to a SQL Server Stored Proc. Indeed, maybe I don't even need to use a Stored Proc as I have some code that passes the SQL String directly to the server via VBA and can run it that way. For some reason using an SP seemed the better solution, but I am open to Ideas and opinions here. The Current VBA code is UPDATE Key_tblPortions INNER JOIN Temp_tblPortionSteps ON Key_tblPortions.PortionID = Temp_tblPortionSteps.PortionID SET Key_tblPortions.EveID = [Temp_tblPortionSteps].[EveID] The SP code on the Server is pretty much identical (which usually work fine, albeit with some minor tweaks if necessary) UPDATE dbo.Key_tblPortions INNER JOIN dbo.Temp_tblPortionSteps ON dbo.Key_tblPortions.PortionID = dbo.Temp_tblPortionSteps.PortionID SET dbo.Key_tblPortions.EveID = [dbo.Temp_tblPortionSteps].[EveID] However in this instance SQL Server is returning the error "Incorrect syntax near the keyword 'INNER'." Which is both perfectly clear but confusing for me at the same time. The set up is I have two tables linked on and ID field (PortionID). The EveID field in Table2 should be written in to the matching EveID field in Table1 where their portionID's match. Simple enough, but not sure how to do this in the SP on SQL Server. Any suggestions? Cheers Darryl. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From accessd at shaw.ca Tue Jan 7 01:20:24 2014 From: accessd at shaw.ca (Jim Lawrence) Date: Tue, 7 Jan 2014 00:20:24 -0700 (MST) Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" In-Reply-To: <3ff2ce0f8e804a45be90d3e2f6189c31@HKXPR04MB184.apcprd04.prod.outlook.com> Message-ID: <681496725.113501923.1389079224960.JavaMail.root@cds002> Hi Darryl: I was just about say that. ;-) Jim ----- Original Message ----- From: "Darryl Collins" To: "Discussion concerning MS SQL Server" Sent: Monday, January 6, 2014 9:33:48 PM Subject: Re: [dba-SQLServer] Stored Procedure Syntax using "Update" Aaaah.... That is typical. Sent this email. Figured it out about 30 seconds later. Duh! :) '------------------------------------------------------------------------------------------------------------------ UPDATE dbo.Key_tblPortions SET dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID FROM dbo.Key_tblPortions INNER JOIN dbo.Temp_tblPortionSteps ON dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID '------------------------------------------------------------------------------------------------------------------ Cheers Darryl -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Tuesday, 7 January 2014 4:18 PM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" Hi There, I am hoping someone can help me out here, although it seems rather quiet on this list, but hey, I will try here first. Using SQL Server 2008 R2 express. Been migrating an existing MS Access Solution to SQL Server and so far things have been going fairly well. However I have bumped into an issue when updating a bit of MS Access code to a SQL Server Stored Proc. Indeed, maybe I don't even need to use a Stored Proc as I have some code that passes the SQL String directly to the server via VBA and can run it that way. For some reason using an SP seemed the better solution, but I am open to Ideas and opinions here. The Current VBA code is UPDATE Key_tblPortions INNER JOIN Temp_tblPortionSteps ON Key_tblPortions.PortionID = Temp_tblPortionSteps.PortionID SET Key_tblPortions.EveID = [Temp_tblPortionSteps].[EveID] The SP code on the Server is pretty much identical (which usually work fine, albeit with some minor tweaks if necessary) UPDATE dbo.Key_tblPortions INNER JOIN dbo.Temp_tblPortionSteps ON dbo.Key_tblPortions.PortionID = dbo.Temp_tblPortionSteps.PortionID SET dbo.Key_tblPortions.EveID = [dbo.Temp_tblPortionSteps].[EveID] However in this instance SQL Server is returning the error "Incorrect syntax near the keyword 'INNER'." Which is both perfectly clear but confusing for me at the same time. The set up is I have two tables linked on and ID field (PortionID). The EveID field in Table2 should be written in to the matching EveID field in Table1 where their portionID's match. Simple enough, but not sure how to do this in the SP on SQL Server. Any suggestions? Cheers Darryl. _______________________________________________ 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 marklbreen at gmail.com Tue Jan 7 03:30:05 2014 From: marklbreen at gmail.com (Mark Breen) Date: Tue, 7 Jan 2014 09:30:05 +0000 Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" In-Reply-To: <3ff2ce0f8e804a45be90d3e2f6189c31@HKXPR04MB184.apcprd04.prod.outlook.com> References: <4003064f16494290b3d08a560a8044cb@HKXPR04MB184.apcprd04.prod.outlook.com> <3ff2ce0f8e804a45be90d3e2f6189c31@HKXPR04MB184.apcprd04.prod.outlook.com> Message-ID: Hello Darryl, yes, that is the way we would write it over here on SQL - we are a small but beautiful list :) Sometimes, for various reasons I may struggle to use this approach and I use the following as a less elegant but still functional alternative '----------------------------------------------------------- ------------------------------------------------------- UPDATE dbo.Key_tblPortions SET dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID Where dbo.Key_tblPortions.Id In ( Select Id from vw_Complex_Set_Of_Criteria ) '----------------------------------------------------------- ------------------------------------------------------- The added benefit of this approach is you can see the Ids before you run the update / delete. In summary, your first approach is the best one. This is just FYI. HTH Mark On 7 January 2014 05:33, Darryl Collins wrote: > > Aaaah.... That is typical. Sent this email. Figured it out about 30 > seconds later. Duh! :) > > > > '------------------------------------------------------------------------------------------------------------------ > UPDATE dbo.Key_tblPortions > SET dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID > > FROM dbo.Key_tblPortions > > INNER JOIN dbo.Temp_tblPortionSteps > ON dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID > > '------------------------------------------------------------------------------------------------------------------ > > Cheers > Darryl > > > > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com [mailto: > dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins > Sent: Tuesday, 7 January 2014 4:18 PM > To: dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" > > Hi There, > > I am hoping someone can help me out here, although it seems rather quiet > on this list, but hey, I will try here first. > > Using SQL Server 2008 R2 express. > > Been migrating an existing MS Access Solution to SQL Server and so far > things have been going fairly well. However I have bumped into an issue > when updating a bit of MS Access code to a SQL Server Stored Proc. Indeed, > maybe I don't even need to use a Stored Proc as I have some code that > passes the SQL String directly to the server via VBA and can run it that > way. > > For some reason using an SP seemed the better solution, but I am open to > Ideas and opinions here. > > The Current VBA code is > > UPDATE > Key_tblPortions > INNER JOIN Temp_tblPortionSteps > ON Key_tblPortions.PortionID = Temp_tblPortionSteps.PortionID SET > Key_tblPortions.EveID = [Temp_tblPortionSteps].[EveID] > > > The SP code on the Server is pretty much identical (which usually work > fine, albeit with some minor tweaks if necessary) > > UPDATE > dbo.Key_tblPortions > INNER JOIN > dbo.Temp_tblPortionSteps > ON > dbo.Key_tblPortions.PortionID = dbo.Temp_tblPortionSteps.PortionID > SET dbo.Key_tblPortions.EveID = [dbo.Temp_tblPortionSteps].[EveID] > > However in this instance SQL Server is returning the error > > "Incorrect syntax near the keyword 'INNER'." > > Which is both perfectly clear but confusing for me at the same time. > > The set up is I have two tables linked on and ID field (PortionID). > > The EveID field in Table2 should be written in to the matching EveID field > in Table1 where their portionID's match. > > Simple enough, but not sure how to do this in the SP on SQL Server. > > Any suggestions? > > Cheers > Darryl. > _______________________________________________ > 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 darryl at whittleconsulting.com.au Tue Jan 7 16:20:30 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Tue, 7 Jan 2014 22:20:30 +0000 Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" In-Reply-To: References: <4003064f16494290b3d08a560a8044cb@HKXPR04MB184.apcprd04.prod.outlook.com> <3ff2ce0f8e804a45be90d3e2f6189c31@HKXPR04MB184.apcprd04.prod.outlook.com> Message-ID: Thanks Guys, Appreciate the feedback. I am sure I will have some other issues I am going to need help with, although I generally try to figure them out first rather than just palming off the work to the list. Mark: thanks for your suggestion too - it is good to see alternative methods to these things. Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Mark Breen Sent: Tuesday, 7 January 2014 8:30 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Stored Procedure Syntax using "Update" Hello Darryl, yes, that is the way we would write it over here on SQL - we are a small but beautiful list :) Sometimes, for various reasons I may struggle to use this approach and I use the following as a less elegant but still functional alternative '----------------------------------------------------------- ------------------------------------------------------- UPDATE dbo.Key_tblPortions SET dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID Where dbo.Key_tblPortions.Id In ( Select Id from vw_Complex_Set_Of_Criteria ) '----------------------------------------------------------- ------------------------------------------------------- The added benefit of this approach is you can see the Ids before you run the update / delete. In summary, your first approach is the best one. This is just FYI. HTH Mark On 7 January 2014 05:33, Darryl Collins wrote: > > Aaaah.... That is typical. Sent this email. Figured it out about 30 > seconds later. Duh! :) > > > > '--------------------------------------------------------------------- > --------------------------------------------- > UPDATE dbo.Key_tblPortions > SET dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID > > FROM dbo.Key_tblPortions > > INNER JOIN dbo.Temp_tblPortionSteps > ON dbo.Key_tblPortions.EveID = dbo.Temp_tblPortionSteps.EveID > > '--------------------------------------------------------------------- > --------------------------------------------- > > Cheers > Darryl > > > > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com [mailto: > dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl > Collins > Sent: Tuesday, 7 January 2014 4:18 PM > To: dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] Stored Procedure Syntax using "Update" > > Hi There, > > I am hoping someone can help me out here, although it seems rather > quiet on this list, but hey, I will try here first. > > Using SQL Server 2008 R2 express. > > Been migrating an existing MS Access Solution to SQL Server and so far > things have been going fairly well. However I have bumped into an > issue when updating a bit of MS Access code to a SQL Server Stored > Proc. Indeed, maybe I don't even need to use a Stored Proc as I have > some code that passes the SQL String directly to the server via VBA > and can run it that way. > > For some reason using an SP seemed the better solution, but I am open > to Ideas and opinions here. > > The Current VBA code is > > UPDATE > Key_tblPortions > INNER JOIN Temp_tblPortionSteps > ON Key_tblPortions.PortionID = Temp_tblPortionSteps.PortionID SET > Key_tblPortions.EveID = [Temp_tblPortionSteps].[EveID] > > > The SP code on the Server is pretty much identical (which usually work > fine, albeit with some minor tweaks if necessary) > > UPDATE > dbo.Key_tblPortions > INNER JOIN > dbo.Temp_tblPortionSteps > ON > dbo.Key_tblPortions.PortionID = dbo.Temp_tblPortionSteps.PortionID > SET dbo.Key_tblPortions.EveID = [dbo.Temp_tblPortionSteps].[EveID] > > However in this instance SQL Server is returning the error > > "Incorrect syntax near the keyword 'INNER'." > > Which is both perfectly clear but confusing for me at the same time. > > The set up is I have two tables linked on and ID field (PortionID). > > The EveID field in Table2 should be written in to the matching EveID > field in Table1 where their portionID's match. > > Simple enough, but not sure how to do this in the SP on SQL Server. > > Any suggestions? > > Cheers > Darryl. > _______________________________________________ > 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 john at winhaven.net Wed Jan 8 23:16:39 2014 From: john at winhaven.net (John Bartow) Date: Wed, 8 Jan 2014 23:16:39 -0600 Subject: [dba-SQLServer] Transact-SQL Named Programming Language of 2013 Message-ID: <017b01cf0cf9$fa8b58e0$efa20aa0$@winhaven.net> The TIOBE Index of the most popular programming languages named Transact-SQL as the programming language of 2013. According to the TIOBE Index, maintained by TIOBE Software, Transact-SQL was the biggest mover of 2013. Last year, Transact-SQL won almost 1 percent of popularity (0.98 percent to be precise), followed by Objective-C at 0.81 percent and F# at 0.53 percent. "It is a bit strange that Transact-SQL wins the award because its major application field, Microsoft's database engine SQL Server, is losing popularity," TIOBE officials said. The general conclusion is that Transact-SQL won because actually not much happened in 2013. In former years, the award winner gained many percentage points in a year. Transact-SQL (T-SQL) is Microsoft and Sybase's proprietary extension to the Structured Query Language (SQL). SQL is a standardized computer language that was originally developed by IBM for querying, altering and defining relational databases, using declarative statements. T-SQL expands on the SQL standard to include procedural programming, local variables, various support functions for string processing, date processing, mathematics, etc., and changes to the DELETE and UPDATE statements. These additional features make Transact-SQL Turing complete. Transact-SQL is central to using Microsoft SQL Server. All applications that communicate with an instance of SQL Server do so by sending Transact-SQL statements to the server, regardless of the user interface of the application. As the last decade has shown, programming language popularity is largely influenced by external trends, TIOBE said. The most important ones at the moment are mobile phone apps and Web development. Android (mainly Java) and iOS (Objective-C) are the major mobile platforms, while Windows Phone (mainly C#) is catching up. Meanwhile, in the Web development world, TIOBE officials said there is not much happening yet despite all the HTML5 discussions. JavaScript should be the big winner but has not gained much popularity on the list as it holds stable at around the No. 9 spot. Yet, JavaScript's alternatives are faring even worse, with Dart ranked at 124, CoffeeScript at 170 and TypeScript at 205. TIOBE changed the TIOBE index algorithm at the end of 2013. The two major changes are: 1) Search engines now contribute much more to the TIOBE index based on their Alexa rankings and suitability to process data automatically, and 2) in the past the sum of the ratings of the top 50 languages was 100 percent, but now the sum of all languages is 100 percent. As a result, most top languages dropped by about 0.5 percent. The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers worldwide, courses and third-party vendors. Popular search engines such as Google, Bing, Yahoo, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. TIOBE index is not about the best programming language or the language in which most lines of code have been written. From darryl at whittleconsulting.com.au Wed Jan 8 23:35:24 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Thu, 9 Jan 2014 05:35:24 +0000 Subject: [dba-SQLServer] Transact-SQL Named Programming Language of 2013 In-Reply-To: <017b01cf0cf9$fa8b58e0$efa20aa0$@winhaven.net> References: <017b01cf0cf9$fa8b58e0$efa20aa0$@winhaven.net> Message-ID: Hehe... I would have added a few points to the T-SQL count this month if they are including Google searches on SQL Server Code :) Been flat out ironing out those little MS Access SQL to T-SQL issues. Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of John Bartow Sent: Thursday, 9 January 2014 4:17 PM To: DBA-Tech; dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Transact-SQL Named Programming Language of 2013 The TIOBE Index of the most popular programming languages named Transact-SQL as the programming language of 2013. According to the TIOBE Index, maintained by TIOBE Software, Transact-SQL was the biggest mover of 2013. Last year, Transact-SQL won almost 1 percent of popularity (0.98 percent to be precise), followed by Objective-C at 0.81 percent and F# at 0.53 percent. "It is a bit strange that Transact-SQL wins the award because its major application field, Microsoft's database engine SQL Server, is losing popularity," TIOBE officials said. The general conclusion is that Transact-SQL won because actually not much happened in 2013. In former years, the award winner gained many percentage points in a year. Transact-SQL (T-SQL) is Microsoft and Sybase's proprietary extension to the Structured Query Language (SQL). SQL is a standardized computer language that was originally developed by IBM for querying, altering and defining relational databases, using declarative statements. T-SQL expands on the SQL standard to include procedural programming, local variables, various support functions for string processing, date processing, mathematics, etc., and changes to the DELETE and UPDATE statements. These additional features make Transact-SQL Turing complete. Transact-SQL is central to using Microsoft SQL Server. All applications that communicate with an instance of SQL Server do so by sending Transact-SQL statements to the server, regardless of the user interface of the application. As the last decade has shown, programming language popularity is largely influenced by external trends, TIOBE said. The most important ones at the moment are mobile phone apps and Web development. Android (mainly Java) and iOS (Objective-C) are the major mobile platforms, while Windows Phone (mainly C#) is catching up. Meanwhile, in the Web development world, TIOBE officials said there is not much happening yet despite all the HTML5 discussions. JavaScript should be the big winner but has not gained much popularity on the list as it holds stable at around the No. 9 spot. Yet, JavaScript's alternatives are faring even worse, with Dart ranked at 124, CoffeeScript at 170 and TypeScript at 205. TIOBE changed the TIOBE index algorithm at the end of 2013. The two major changes are: 1) Search engines now contribute much more to the TIOBE index based on their Alexa rankings and suitability to process data automatically, and 2) in the past the sum of the ratings of the top 50 languages was 100 percent, but now the sum of all languages is 100 percent. As a result, most top languages dropped by about 0.5 percent. The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers worldwide, courses and third-party vendors. Popular search engines such as Google, Bing, Yahoo, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. TIOBE index is not about the best programming language or the language in which most lines of code have been written. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From accessd at shaw.ca Thu Jan 9 11:05:04 2014 From: accessd at shaw.ca (Jim Lawrence) Date: Thu, 9 Jan 2014 10:05:04 -0700 (MST) Subject: [dba-SQLServer] Transact-SQL Named Programming Language of 2013 In-Reply-To: <017b01cf0cf9$fa8b58e0$efa20aa0$@winhaven.net> Message-ID: <1335099011.116113807.1389287104721.JavaMail.root@cds002> Hi John: Interesting method used to rate a language... Of the top ten languages used Transact-SQL is by far the least used and its use is dropping: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Being a MS SQL user, I use it of course but the use of other languages by developers is massive in comparison. Jim ----- Original Message ----- From: "John Bartow" To: "DBA-Tech" , dba-sqlserver at databaseadvisors.com Sent: Wednesday, January 8, 2014 9:16:39 PM Subject: [dba-SQLServer] Transact-SQL Named Programming Language of 2013 The TIOBE Index of the most popular programming languages named Transact-SQL as the programming language of 2013. According to the TIOBE Index, maintained by TIOBE Software, Transact-SQL was the biggest mover of 2013. Last year, Transact-SQL won almost 1 percent of popularity (0.98 percent to be precise), followed by Objective-C at 0.81 percent and F# at 0.53 percent. "It is a bit strange that Transact-SQL wins the award because its major application field, Microsoft's database engine SQL Server, is losing popularity," TIOBE officials said. The general conclusion is that Transact-SQL won because actually not much happened in 2013. In former years, the award winner gained many percentage points in a year. Transact-SQL (T-SQL) is Microsoft and Sybase's proprietary extension to the Structured Query Language (SQL). SQL is a standardized computer language that was originally developed by IBM for querying, altering and defining relational databases, using declarative statements. T-SQL expands on the SQL standard to include procedural programming, local variables, various support functions for string processing, date processing, mathematics, etc., and changes to the DELETE and UPDATE statements. These additional features make Transact-SQL Turing complete. Transact-SQL is central to using Microsoft SQL Server. All applications that communicate with an instance of SQL Server do so by sending Transact-SQL statements to the server, regardless of the user interface of the application. As the last decade has shown, programming language popularity is largely influenced by external trends, TIOBE said. The most important ones at the moment are mobile phone apps and Web development. Android (mainly Java) and iOS (Objective-C) are the major mobile platforms, while Windows Phone (mainly C#) is catching up. Meanwhile, in the Web development world, TIOBE officials said there is not much happening yet despite all the HTML5 discussions. JavaScript should be the big winner but has not gained much popularity on the list as it holds stable at around the No. 9 spot. Yet, JavaScript's alternatives are faring even worse, with Dart ranked at 124, CoffeeScript at 170 and TypeScript at 205. TIOBE changed the TIOBE index algorithm at the end of 2013. The two major changes are: 1) Search engines now contribute much more to the TIOBE index based on their Alexa rankings and suitability to process data automatically, and 2) in the past the sum of the ratings of the top 50 languages was 100 percent, but now the sum of all languages is 100 percent. As a result, most top languages dropped by about 0.5 percent. The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers worldwide, courses and third-party vendors. Popular search engines such as Google, Bing, Yahoo, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. TIOBE index is not about the best programming language or the language in which most lines of code have been written. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From darryl at whittleconsulting.com.au Thu Jan 9 21:46:56 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Fri, 10 Jan 2014 03:46:56 +0000 Subject: [dba-SQLServer] Bulk Insert? Message-ID: <769389618fdf419ba574cde94a978af4@HKXPR04MB184.apcprd04.prod.outlook.com> Hi Folks, I am trying to get BULK INSERT to work in SQL Server 2008 R2 (Express version). Ideally Integrated Services would be a more elegant solution, but that is not available in the Express Version from what I understand. That said, BULK INSERT should do the job. I am running test to check it out and I cannot get it to work at all. T-SQL is: '===================================================================================== BULK INSERT dbo.ProbC_tblProcedureClasses FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_ProcedureClasses.txt' WITH ( FIELDTERMINATOR =',', FIRSTROW = 2, ROWTERMINATOR = '\n') '===================================================================================== The text file is in the target location and contains: '===================================================================================== ProcedureClassName,ProcedureClassType MaterialSource,Mining Processing,Downstream '===================================================================================== Table in SQL Server looks like (PK is SeqID_ProcClass): '===================================================================================== Column Name Data Type Allow Nulls ProcedureClassType nvarchar(32) Checked ProcedureClassName nvarchar(32) Checked SeqID_ProcClass int Unchecked SeqID_ProcClassManual int Checked '===================================================================================== If I use the .TransferText method to a linked table in MS Access than the data loads fine into SQL Server. However the BULK INSERT Code in SQL Server the query runs 'successfully', but returns "(0 row(s) affected)" and (obviously based on that message) no data is loaded into the table. Most curious. Any idea what I am stuffing up here? Cheers Darryl. From darryl at whittleconsulting.com.au Thu Jan 9 22:04:50 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Fri, 10 Jan 2014 04:04:50 +0000 Subject: [dba-SQLServer] Bulk Insert? In-Reply-To: <769389618fdf419ba574cde94a978af4@HKXPR04MB184.apcprd04.prod.outlook.com> References: <769389618fdf419ba574cde94a978af4@HKXPR04MB184.apcprd04.prod.outlook.com> Message-ID: <0a409d3b74ce4a3491b5b7452cb70e82@HKXPR04MB184.apcprd04.prod.outlook.com> Ok... I suspect I can see the issue with this example. I have " SeqID_ProcClassManual" as a field that is not included in the original text file (it is populated later). That might be why this is failing. That said, not having much luck with *any* of them at this stage (I have about 40 text files to load). Clearly I will use a SPOC with variable when it comes to the real thing, but right now, I just want ONE of them to work manually. Meh! Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 2:47 PM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] Bulk Insert? Hi Folks, I am trying to get BULK INSERT to work in SQL Server 2008 R2 (Express version). Ideally Integrated Services would be a more elegant solution, but that is not available in the Express Version from what I understand. That said, BULK INSERT should do the job. I am running test to check it out and I cannot get it to work at all. T-SQL is: '===================================================================================== BULK INSERT dbo.ProbC_tblProcedureClasses FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_ProcedureClasses.txt' WITH ( FIELDTERMINATOR =',', FIRSTROW = 2, ROWTERMINATOR = '\n') '===================================================================================== The text file is in the target location and contains: '===================================================================================== ProcedureClassName,ProcedureClassType MaterialSource,Mining Processing,Downstream '===================================================================================== Table in SQL Server looks like (PK is SeqID_ProcClass): '===================================================================================== Column Name Data Type Allow Nulls ProcedureClassType nvarchar(32) Checked ProcedureClassName nvarchar(32) Checked SeqID_ProcClass int Unchecked SeqID_ProcClassManual int Checked '===================================================================================== If I use the .TransferText method to a linked table in MS Access than the data loads fine into SQL Server. However the BULK INSERT Code in SQL Server the query runs 'successfully', but returns "(0 row(s) affected)" and (obviously based on that message) no data is loaded into the table. Most curious. Any idea what I am stuffing up here? Cheers Darryl. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From darryl at whittleconsulting.com.au Thu Jan 9 22:15:11 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Fri, 10 Jan 2014 04:15:11 +0000 Subject: [dba-SQLServer] Bulk Insert? In-Reply-To: <0a409d3b74ce4a3491b5b7452cb70e82@HKXPR04MB184.apcprd04.prod.outlook.com> References: <769389618fdf419ba574cde94a978af4@HKXPR04MB184.apcprd04.prod.outlook.com> <0a409d3b74ce4a3491b5b7452cb70e82@HKXPR04MB184.apcprd04.prod.outlook.com> Message-ID: Ok... Making progress, but happy for someone to come up with a better solution if they can think of one. Using a #Temp Table first, I can load the data into the real table successfully. This looks a lot more painful to set up as I will need to build each temp table manually (at least I think I do), but I guess I only need to do it once. '=============================================================================== IF OBJECT_ID('tempdb..#test1') IS NOT NULL DROP TABLE #test1; GO CREATE TABLE #test1 ( RowNumber int, HeadingLevel int, Periods int, ColumnA nvarchar(255), ColumnB nvarchar(255), ColumnC nvarchar(255), ColumnD nvarchar(255), ColumnE nvarchar(255), ColumnF nvarchar(255) ) BULK INSERT #test1 FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_SettingsBase.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) INSERT INTO dbo.ProbC_tblSettingsBase SELECT * FROM #test1 DROP TABLE #test1 '=============================================================================== Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 3:05 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Bulk Insert? Ok... I suspect I can see the issue with this example. I have " SeqID_ProcClassManual" as a field that is not included in the original text file (it is populated later). That might be why this is failing. That said, not having much luck with *any* of them at this stage (I have about 40 text files to load). Clearly I will use a SPOC with variable when it comes to the real thing, but right now, I just want ONE of them to work manually. Meh! Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 2:47 PM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] Bulk Insert? Hi Folks, I am trying to get BULK INSERT to work in SQL Server 2008 R2 (Express version). Ideally Integrated Services would be a more elegant solution, but that is not available in the Express Version from what I understand. That said, BULK INSERT should do the job. I am running test to check it out and I cannot get it to work at all. T-SQL is: '===================================================================================== BULK INSERT dbo.ProbC_tblProcedureClasses FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_ProcedureClasses.txt' WITH ( FIELDTERMINATOR =',', FIRSTROW = 2, ROWTERMINATOR = '\n') '===================================================================================== The text file is in the target location and contains: '===================================================================================== ProcedureClassName,ProcedureClassType MaterialSource,Mining Processing,Downstream '===================================================================================== Table in SQL Server looks like (PK is SeqID_ProcClass): '===================================================================================== Column Name Data Type Allow Nulls ProcedureClassType nvarchar(32) Checked ProcedureClassName nvarchar(32) Checked SeqID_ProcClass int Unchecked SeqID_ProcClassManual int Checked '===================================================================================== If I use the .TransferText method to a linked table in MS Access than the data loads fine into SQL Server. However the BULK INSERT Code in SQL Server the query runs 'successfully', but returns "(0 row(s) affected)" and (obviously based on that message) no data is loaded into the table. Most curious. Any idea what I am stuffing up here? Cheers Darryl. _______________________________________________ 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 accessd at shaw.ca Fri Jan 10 14:03:32 2014 From: accessd at shaw.ca (Jim Lawrence) Date: Fri, 10 Jan 2014 13:03:32 -0700 (MST) Subject: [dba-SQLServer] Bulk Insert? In-Reply-To: Message-ID: <1792181896.117537252.1389384212770.JavaMail.root@cds002> Hi Darryl: This is probably your best method. It is best never to import raw data straight into an active table. Jim ----- Original Message ----- From: "Darryl Collins" To: "Discussion concerning MS SQL Server" Sent: Thursday, January 9, 2014 8:15:11 PM Subject: Re: [dba-SQLServer] Bulk Insert? Ok... Making progress, but happy for someone to come up with a better solution if they can think of one. Using a #Temp Table first, I can load the data into the real table successfully. This looks a lot more painful to set up as I will need to build each temp table manually (at least I think I do), but I guess I only need to do it once. '=============================================================================== IF OBJECT_ID('tempdb..#test1') IS NOT NULL DROP TABLE #test1; GO CREATE TABLE #test1 ( RowNumber int, HeadingLevel int, Periods int, ColumnA nvarchar(255), ColumnB nvarchar(255), ColumnC nvarchar(255), ColumnD nvarchar(255), ColumnE nvarchar(255), ColumnF nvarchar(255) ) BULK INSERT #test1 FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_SettingsBase.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) INSERT INTO dbo.ProbC_tblSettingsBase SELECT * FROM #test1 DROP TABLE #test1 '=============================================================================== Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 3:05 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Bulk Insert? Ok... I suspect I can see the issue with this example. I have " SeqID_ProcClassManual" as a field that is not included in the original text file (it is populated later). That might be why this is failing. That said, not having much luck with *any* of them at this stage (I have about 40 text files to load). Clearly I will use a SPOC with variable when it comes to the real thing, but right now, I just want ONE of them to work manually. Meh! Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 2:47 PM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] Bulk Insert? Hi Folks, I am trying to get BULK INSERT to work in SQL Server 2008 R2 (Express version). Ideally Integrated Services would be a more elegant solution, but that is not available in the Express Version from what I understand. That said, BULK INSERT should do the job. I am running test to check it out and I cannot get it to work at all. T-SQL is: '===================================================================================== BULK INSERT dbo.ProbC_tblProcedureClasses FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_ProcedureClasses.txt' WITH ( FIELDTERMINATOR =',', FIRSTROW = 2, ROWTERMINATOR = '\n') '===================================================================================== The text file is in the target location and contains: '===================================================================================== ProcedureClassName,ProcedureClassType MaterialSource,Mining Processing,Downstream '===================================================================================== Table in SQL Server looks like (PK is SeqID_ProcClass): '===================================================================================== Column Name Data Type Allow Nulls ProcedureClassType nvarchar(32) Checked ProcedureClassName nvarchar(32) Checked SeqID_ProcClass int Unchecked SeqID_ProcClassManual int Checked '===================================================================================== If I use the .TransferText method to a linked table in MS Access than the data loads fine into SQL Server. However the BULK INSERT Code in SQL Server the query runs 'successfully', but returns "(0 row(s) affected)" and (obviously based on that message) no data is loaded into the table. Most curious. Any idea what I am stuffing up here? Cheers Darryl. _______________________________________________ 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 darryl at whittleconsulting.com.au Fri Jan 10 19:23:19 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Sat, 11 Jan 2014 01:23:19 +0000 Subject: [dba-SQLServer] Bulk Insert? In-Reply-To: <1792181896.117537252.1389384212770.JavaMail.root@cds002> References: , <1792181896.117537252.1389384212770.JavaMail.root@cds002> Message-ID: <80sdw8q9899ylg054bgtpe8d.1389403396120@email.android.com> Thanks Jim. A Job for Monday, but at least I know what to do and how to do it. Cheers Darryl Sent from my Galaxy Note II. Please excuse any gibberish and/or brevity. -------- Original message -------- From: Jim Lawrence Date: 11/01/2014 07:04 (GMT+10:00) To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Bulk Insert? Hi Darryl: This is probably your best method. It is best never to import raw data straight into an active table. Jim ----- Original Message ----- From: "Darryl Collins" To: "Discussion concerning MS SQL Server" Sent: Thursday, January 9, 2014 8:15:11 PM Subject: Re: [dba-SQLServer] Bulk Insert? Ok... Making progress, but happy for someone to come up with a better solution if they can think of one. Using a #Temp Table first, I can load the data into the real table successfully. This looks a lot more painful to set up as I will need to build each temp table manually (at least I think I do), but I guess I only need to do it once. '=============================================================================== IF OBJECT_ID('tempdb..#test1') IS NOT NULL DROP TABLE #test1; GO CREATE TABLE #test1 ( RowNumber int, HeadingLevel int, Periods int, ColumnA nvarchar(255), ColumnB nvarchar(255), ColumnC nvarchar(255), ColumnD nvarchar(255), ColumnE nvarchar(255), ColumnF nvarchar(255) ) BULK INSERT #test1 FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_SettingsBase.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) INSERT INTO dbo.ProbC_tblSettingsBase SELECT * FROM #test1 DROP TABLE #test1 '=============================================================================== Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 3:05 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Bulk Insert? Ok... I suspect I can see the issue with this example. I have " SeqID_ProcClassManual" as a field that is not included in the original text file (it is populated later). That might be why this is failing. That said, not having much luck with *any* of them at this stage (I have about 40 text files to load). Clearly I will use a SPOC with variable when it comes to the real thing, but right now, I just want ONE of them to work manually. Meh! Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 2:47 PM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] Bulk Insert? Hi Folks, I am trying to get BULK INSERT to work in SQL Server 2008 R2 (Express version). Ideally Integrated Services would be a more elegant solution, but that is not available in the Express Version from what I understand. That said, BULK INSERT should do the job. I am running test to check it out and I cannot get it to work at all. T-SQL is: '===================================================================================== BULK INSERT dbo.ProbC_tblProcedureClasses FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_ProcedureClasses.txt' WITH ( FIELDTERMINATOR =',', FIRSTROW = 2, ROWTERMINATOR = '\n') '===================================================================================== The text file is in the target location and contains: '===================================================================================== ProcedureClassName,ProcedureClassType MaterialSource,Mining Processing,Downstream '===================================================================================== Table in SQL Server looks like (PK is SeqID_ProcClass): '===================================================================================== Column Name Data Type Allow Nulls ProcedureClassType nvarchar(32) Checked ProcedureClassName nvarchar(32) Checked SeqID_ProcClass int Unchecked SeqID_ProcClassManual int Checked '===================================================================================== If I use the .TransferText method to a linked table in MS Access than the data loads fine into SQL Server. However the BULK INSERT Code in SQL Server the query runs 'successfully', but returns "(0 row(s) affected)" and (obviously based on that message) no data is loaded into the table. Most curious. Any idea what I am stuffing up here? Cheers Darryl. _______________________________________________ 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 darryl at whittleconsulting.com.au Wed Jan 15 16:37:54 2014 From: darryl at whittleconsulting.com.au (Darryl Collins) Date: Wed, 15 Jan 2014 22:37:54 +0000 Subject: [dba-SQLServer] Bulk Insert? In-Reply-To: <80sdw8q9899ylg054bgtpe8d.1389403396120@email.android.com> References: , <1792181896.117537252.1389384212770.JavaMail.root@cds002> <80sdw8q9899ylg054bgtpe8d.1389403396120@email.android.com> Message-ID: Well, it has been fun. My "Job for Monday" turned out to be about 3 days' work but I have learnt a few new tricks on the way when converting the existing import and update process from using MS Access to SQL Server instead. But happy to say it is now working well and is about twice as fast as MS Access - all good there. I also appreciate you folks listening to me working through these ideas. You might think you didn't do much, but I found your responses helpful - even if it is just confirmation that I am on the right track (I have been on the wrong track often enough to be Leary of these things!). Using CAST was interesting and caused me some (self-inflicted) grief, as was some strange rules about JOINs and unbound field etc. Still not sure why I need to use the "AS x" syntax but, but it works and is simple enough to set up and I guess it makes things neater. Finding out about MERGE was interesting too. MERGE dbo.vPopulateActivityProcedure_Sub1 AS t USING dbo.vPopulateActivityProcedure_Sub2 AS s ON t.PredActivityID = s.ActivityID WHEN Matched THEN UPDATE SET t.ProcedureClassType = s.[ProcedureClassType], t.ProcedureName = s.[ProcedureName], t.ProcedureClassName = s.[ProcedureClassName], t.MaterialClassName = s.[MaterialClassName]; and IIF doesn't work - needed to change them all to CASE. Again, this is ok once you know what you are doing. Fun stuff. Anyway, first part is done, now onto the more complicated second part - The output of the reporting into Excel. :) Thanks for your assistance. Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Saturday, 11 January 2014 12:23 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Bulk Insert? Thanks Jim. A Job for Monday, but at least I know what to do and how to do it. Cheers Darryl Sent from my Galaxy Note II. Please excuse any gibberish and/or brevity. -------- Original message -------- From: Jim Lawrence Date: 11/01/2014 07:04 (GMT+10:00) To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Bulk Insert? Hi Darryl: This is probably your best method. It is best never to import raw data straight into an active table. Jim ----- Original Message ----- From: "Darryl Collins" To: "Discussion concerning MS SQL Server" Sent: Thursday, January 9, 2014 8:15:11 PM Subject: Re: [dba-SQLServer] Bulk Insert? Ok... Making progress, but happy for someone to come up with a better solution if they can think of one. Using a #Temp Table first, I can load the data into the real table successfully. This looks a lot more painful to set up as I will need to build each temp table manually (at least I think I do), but I guess I only need to do it once. '=============================================================================== IF OBJECT_ID('tempdb..#test1') IS NOT NULL DROP TABLE #test1; GO CREATE TABLE #test1 ( RowNumber int, HeadingLevel int, Periods int, ColumnA nvarchar(255), ColumnB nvarchar(255), ColumnC nvarchar(255), ColumnD nvarchar(255), ColumnE nvarchar(255), ColumnF nvarchar(255) ) BULK INSERT #test1 FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_SettingsBase.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) INSERT INTO dbo.ProbC_tblSettingsBase SELECT * FROM #test1 DROP TABLE #test1 '=============================================================================== Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 3:05 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] Bulk Insert? Ok... I suspect I can see the issue with this example. I have " SeqID_ProcClassManual" as a field that is not included in the original text file (it is populated later). That might be why this is failing. That said, not having much luck with *any* of them at this stage (I have about 40 text files to load). Clearly I will use a SPOC with variable when it comes to the real thing, but right now, I just want ONE of them to work manually. Meh! Cheers Darryl. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Friday, 10 January 2014 2:47 PM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] Bulk Insert? Hi Folks, I am trying to get BULK INSERT to work in SQL Server 2008 R2 (Express version). Ideally Integrated Services would be a more elegant solution, but that is not available in the Express Version from what I understand. That said, BULK INSERT should do the job. I am running test to check it out and I cannot get it to work at all. T-SQL is: '===================================================================================== BULK INSERT dbo.ProbC_tblProcedureClasses FROM 'C:\Users\Darryl\Documents\ProberC_Transit\PrcMWA093_ProcedureClasses.txt' WITH ( FIELDTERMINATOR =',', FIRSTROW = 2, ROWTERMINATOR = '\n') '===================================================================================== The text file is in the target location and contains: '===================================================================================== ProcedureClassName,ProcedureClassType MaterialSource,Mining Processing,Downstream '===================================================================================== Table in SQL Server looks like (PK is SeqID_ProcClass): '===================================================================================== Column Name Data Type Allow Nulls ProcedureClassType nvarchar(32) Checked ProcedureClassName nvarchar(32) Checked SeqID_ProcClass int Unchecked SeqID_ProcClassManual int Checked '===================================================================================== If I use the .TransferText method to a linked table in MS Access than the data loads fine into SQL Server. However the BULK INSERT Code in SQL Server the query runs 'successfully', but returns "(0 row(s) affected)" and (obviously based on that message) no data is loaded into the table. Most curious. Any idea what I am stuffing up here? Cheers Darryl. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From gustav at cactus.dk Mon Jan 20 08:44:15 2014 From: gustav at cactus.dk (Gustav Brock) Date: Mon, 20 Jan 2014 15:44:15 +0100 Subject: [dba-SQLServer] [AccessD] Hash value of record fields Message-ID: <006801cf15ee$17a60630$46f21290$@cactus.dk> Hi all As the tables live in SQL Server, I found out that T-SQL contains a function CheckSum for exactly this. So I could just run a pass-through query to get the checksum/hash value. Or do I miss something? /gustav -----Oprindelig meddelelse----- Fra: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] P? vegne af Gustav Brock Sendt: 20. januar 2014 14:48 Til: 'Access Developers discussion and problem solving' Emne: [AccessD] Hash value of record fields Hi all I remember that JC worked with hash values for full records to identify dupes. I'm looking for a fast native VBA function to return a hash value for a variable count of fields (using ParamArray). It doesn't have to be fancy MD5 or the like, just fast. Before I start binging/googling, I wonder if anyone have a proven function at hand? /gustav From fuller.artful at gmail.com Mon Jan 20 10:40:19 2014 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 20 Jan 2014 11:40:19 -0500 Subject: [dba-SQLServer] [AccessD] Hash value of record fields In-Reply-To: <006801cf15ee$17a60630$46f21290$@cactus.dk> References: <006801cf15ee$17a60630$46f21290$@cactus.dk> Message-ID: Gustav, I'm HUGE Fan of PTQs. I don't think you're going to need any fancy VBA code to do this -- unless I'm mistaking your intent. On the Back End, create an SP that accepts a variety of optional parameters. Then ether create a new PTQ or modify a template PTQ and pass in the values of interest. Arthur From gustav at cactus.dk Mon Jan 20 10:51:43 2014 From: gustav at cactus.dk (Gustav Brock) Date: Mon, 20 Jan 2014 17:51:43 +0100 Subject: [dba-SQLServer] [AccessD] Hash value of record fields Message-ID: <00b901cf15ff$e5c91c80$b15b5580$@cactus.dk> Hi Arthur Yes, I just did a test, and T-SQL's CheckSum works great. Very handy. /gustav -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arthur Fuller Sendt: 20. januar 2014 17:40 Til: Discussion concerning MS SQL Server Emne: Re: [dba-SQLServer] [AccessD] Hash value of record fields Gustav, I'm HUGE Fan of PTQs. I don't think you're going to need any fancy VBA code to do this -- unless I'm mistaking your intent. On the Back End, create an SP that accepts a variety of optional parameters. Then ether create a new PTQ or modify a template PTQ and pass in the values of interest. Arthur From fuller.artful at gmail.com Mon Jan 20 10:58:07 2014 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 20 Jan 2014 11:58:07 -0500 Subject: [dba-SQLServer] [AccessD] Hash value of record fields In-Reply-To: <00b901cf15ff$e5c91c80$b15b5580$@cactus.dk> References: <00b901cf15ff$e5c91c80$b15b5580$@cactus.dk> Message-ID: Gustav, My overall design philosophy is, "Whatever the BE can do, the FE should not bother." Happy to help. Arthur On Mon, Jan 20, 2014 at 11:51 AM, Gustav Brock wrote: > Hi Arthur > > Yes, I just did a test, and T-SQL's CheckSum works great. Very handy. > > /gustav > > >