From jwcolby at colbyconsulting.com Sat May 5 07:49:54 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 05 May 2012 08:49:54 -0400 Subject: [dba-SQLServer] Holding a SQL Server connection open Message-ID: <4FA521F2.4090205@colbyconsulting.com> My Address Validation program caches records in sql server into class instances, then updates properties on those records (in those classes) and in many cases writes the changes back to SQL Server immediately. What this means is that a specific field of the record is updated in the class and in SQL Server as some processing step is completed. I am having a connectivity issue in my network where every once in a while the flag write will not manage to open the connection to SQL Server before timing out. From a system design perspective I need guidance on what I am doing. ATM the flag actually opens a connection, writes the data to the field of the specific record then closes the connection. While that certainly works, it is causing (or finding) problems with the occasional "can't connect", plus it seems logical that it is slower than just having a shared connection that is kept open. I have been coached to keep connections open for the minimum time necessary, but I am wondering whether it would be appropriate in this case to get a connection, hold it open as long as the program is open, then share that connection. -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From jwcolby at colbyconsulting.com Thu May 17 07:29:36 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 17 May 2012 08:29:36 -0400 Subject: [dba-SQLServer] Cancel SQL Server requests initiated from C# Message-ID: <4FB4EF30.9030602@colbyconsulting.com> I automate SQL Server from C# using the command object to execute various queries. Some of them are long running, for example selecting a large recordset into a temp destination table from a source table. It is possible to shut down my C# program "in the middle" which leaves that query running out on SQL Server. Is it possible to somehow tell SQL Server to stop the activity? Perhaps encapsulate the SQL in transactions and tell the command object to stop the transaction? -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From jwcolby at colbyconsulting.com Mon May 21 17:17:44 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Mon, 21 May 2012 18:17:44 -0400 Subject: [dba-SQLServer] Is there any chance? Message-ID: <4FBABF08.2010708@colbyconsulting.com> I am trying to get Bulk Insert (import) working with CSV files ("," delimited) using a format file. I have about 60 files with around 250 million total records that I need to import. Just using the built-in wizard works but is a royal PITA because I have to modify each and every time to widen the fields to 250 characters, build each file by hand etc. So I have a SP that creates the tables. I then use the following to try to do the import: USE [_DataEmailDD] GO /****** Object: StoredProcedure [dbo].[sp_AZIn_BCPInOneFile] Script Date: 05/21/2012 17:19:43 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= ALTER PROCEDURE [dbo].[sp_AZIn_BCPInOneFile] -- Add the parameters for the stored procedure here @DBName varchar(50), @TblName varchar(50), @FilePath varchar(1000), @FileName varchar(255) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here declare @sql varchar(8000) DECLARE @FileSpec varchar(1000) Declare @ErrorDesc varchar(4000) Declare @ErrorNo int Declare @RecsAffected int set @filespec = @FilePath set @filespec = @filespec + @FileName begin try set @SQL = 'BULK INSERT [' + @DBName + '].[dbo].[' + @TblName + '] FROM ' + '''' + @filespec + '''' + ' WITH (FORMATFILE= ' + '''' + '\\Azul\PSM\data\_DataEmailDD\EmailImpFormat.xml' + '''' + ')' print @SQL exec (@SQL) select @RecsAffected = @@RowCount select @ErrorDesc = 'Success' select @ErrorNo = 0 return 0 end try begin catch select @ErrorNo = @@Error select @ErrorDesc = ERROR_MESSAGE() print 'There was a BCP error IMPORTING data into ' + @DBName print ERROR_MESSAGE() return -1 end catch -- Standard stuff except for the SQL Statement which when printed gives me the following: BULK INSERT [_DataEmailDD].[dbo].[ConsEmail_AK] FROM '\\Azul\PSM\Data\_DataEmailDD\ConsEmail_AK.CSV' WITH (FORMATFILE= '\\Azul\PSM\data\_DataEmailDD\EmailImpFormat.xml') and execution thereof gives me the infamous (and totally useless) There was a BCP error IMPORTING data into _DataEmailDD Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)". It just seems like my chance of making this work is pretty minimal. I have spent about 4 hours Googling to even get as far as I am and the Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)". returns about a million entirely different pages for a million entirely different problems. It is as if any problem whatsoever returns this message. So, what do you say? Is this a "you gotta be an expert so forget it" kinda deal? All of the various web pages explaining how to do this make it sound so easy but of course no one mentions how to troubleshoot the mess. -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From jwcolby at colbyconsulting.com Wed May 23 12:44:09 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 23 May 2012 13:44:09 -0400 Subject: [dba-SQLServer] The strangest thing 00 Message-ID: <4FBD21E9.4010900@colbyconsulting.com> I just ran into the strangest problem. I am importing CSV files into SQL Server manually (using the import wizard) All is working or so it seems. Suddenly I run into a set of files where the first column is missing. The field exists, the column name exists, but the data is not being imported. Looking at a preview of the data in the wizard shows it there. Looking *very carefully* at the text file using Ultra Edit shows the first line of actual data pushed over by a character. Looking at the data in ASCII in Untra Edit shows a 00 in front of the opening ". 00 is an unprintable character and is a Null. IOW each line of these files start with a NULL, except for the first (field names). Stripping all of these nulls out leaves the file importing correctly. Odd that the preview for the import wizard ignored the null but the actual import code did not. -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From gustav at cactus.dk Wed May 23 13:25:42 2012 From: gustav at cactus.dk (Gustav Brock) Date: Wed, 23 May 2012 20:25:42 +0200 Subject: [dba-SQLServer] The strangest thing 00 Message-ID: Hi John Yes, just as you think you have seen everything, then this. Probably bad programming of the export, because what purpose could a leading 00 serve? /gustav >>> jwcolby at colbyconsulting.com 23-05-12 19:44 >>> I just ran into the strangest problem. I am importing CSV files into SQL Server manually (using the import wizard) All is working or so it seems. Suddenly I run into a set of files where the first column is missing. The field exists, the column name exists, but the data is not being imported. Looking at a preview of the data in the wizard shows it there. Looking *very carefully* at the text file using Ultra Edit shows the first line of actual data pushed over by a character. Looking at the data in ASCII in Untra Edit shows a 00 in front of the opening ". 00 is an unprintable character and is a Null. IOW each line of these files start with a NULL, except for the first (field names). Stripping all of these nulls out leaves the file importing correctly. Odd that the preview for the import wizard ignored the null but the actual import code did not. -- John W. Colby Colby Consulting From garykjos at gmail.com Wed May 23 14:51:20 2012 From: garykjos at gmail.com (Gary Kjos) Date: Wed, 23 May 2012 14:51:20 -0500 Subject: [dba-SQLServer] The strangest thing 00 In-Reply-To: <4FBD21E9.4010900@colbyconsulting.com> References: <4FBD21E9.4010900@colbyconsulting.com> Message-ID: Those nulls will bite you. Or BYTE you? We used to call them LOW-VALUES back in my mainframe days. Dating myself. GK On Wed, May 23, 2012 at 12:44 PM, jwcolby wrote: > I just ran into the strangest problem. ?I am importing CSV files into SQL > Server manually (using the import wizard) ?All is working or so it seems. > ?Suddenly I run into a set of files where the first column is missing. ?The > field exists, the column name exists, but the data is not being imported. > Looking at a preview of the data in the wizard shows it there. > > Looking *very carefully* at the text file using Ultra Edit shows the first > line of actual data pushed over by a character. ?Looking at the data in > ASCII in Untra Edit shows a 00 in front of the opening ". ?00 is an > unprintable character and is a Null. ?IOW each line of these files start > with a NULL, except for the first (field names). > > Stripping all of these nulls out leaves the file importing correctly. > > Odd that the preview for the import wizard ignored the null but the actual > import code did not. > > -- > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > _______________________________________________ > 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 jnatola at hotmail.com Thu May 24 14:22:52 2012 From: jnatola at hotmail.com (Jean-Paul N) Date: Thu, 24 May 2012 15:22:52 -0400 Subject: [dba-SQLServer] ) errors In-Reply-To: References: <4FBD21E9.4010900@colbyconsulting.com>, Message-ID: hi all, I'm trying to figure out what sql doesnt like about this parenthesis; LINE 12 CREATE ENDPOINT WebServiceTest AUTHORIZATION [sa] STATE = STARTED AS HTTP ( AUTHENTICATION = (INTEGRATED), PATH = '/MyTestWebservicepath/', PORTS = (CLEAR), CLEAR_PORT = 8045, SITE = '*', ) THIS PAREN THROWS THE ERROR FOR SOAP ( WEBMETHOD 'urn:www.codeproject.com'.'GetProduct' ( NAME = 'Northwind.dbo.GetProduct', SCHEMA = STANDARD, FORMAT = ALL_RESULTS ), WSDL = DEFAULT, BATCHES = DISABLED, SCHEMA = STANDARD, LOGIN_TYPE = WINDOWS, SESSION_TIMEOUT = 100, DATABASE = 'Northwind', NAMESPACE = 'www.codeproject.com', CHARACTER_SET = XML ) From garykjos at gmail.com Thu May 24 14:43:14 2012 From: garykjos at gmail.com (Gary Kjos) Date: Thu, 24 May 2012 14:43:14 -0500 Subject: [dba-SQLServer] ) errors In-Reply-To: References: <4FBD21E9.4010900@colbyconsulting.com> Message-ID: Comma at end of line 11? On Thu, May 24, 2012 at 2:22 PM, Jean-Paul N wrote: > > > hi all, > > I'm trying to figure out what sql doesnt like about this parenthesis; LINE 12 > > CREATE ENDPOINT WebServiceTest > AUTHORIZATION [sa] > STATE = STARTED > AS HTTP > ( > AUTHENTICATION = (INTEGRATED), > PATH = '/MyTestWebservicepath/', > PORTS = (CLEAR), > CLEAR_PORT = 8045, > SITE = '*', > > ) ?THIS PAREN ?THROWS THE ERROR > FOR SOAP > ( > WEBMETHOD 'urn:www.codeproject.com'.'GetProduct' > ( > NAME = 'Northwind.dbo.GetProduct', > SCHEMA = STANDARD, > FORMAT = ALL_RESULTS > ), > WSDL = DEFAULT, > BATCHES = DISABLED, > SCHEMA = STANDARD, > LOGIN_TYPE = WINDOWS, > SESSION_TIMEOUT = 100, > DATABASE = 'Northwind', > NAMESPACE = 'www.codeproject.com', > CHARACTER_SET = XML > ) > > > > > > > > > > > > > _______________________________________________ > 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 jnatola at hotmail.com Thu May 24 14:47:54 2012 From: jnatola at hotmail.com (Jean-Paul N) Date: Thu, 24 May 2012 15:47:54 -0400 Subject: [dba-SQLServer] ) errors In-Reply-To: References: <4FBD21E9.4010900@colbyconsulting.com>, , , Message-ID: I think you are onto something , removing the comma now returns this error Msg 7878, Level 16, State 1, Line 1 This "CREATE ENDPOINT" statement is not supported on this edition of SQL Server. Jean-Paul Natola > Date: Thu, 24 May 2012 14:43:14 -0500 > From: garykjos at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] ) errors > > Comma at end of line 11? > > On Thu, May 24, 2012 at 2:22 PM, Jean-Paul N wrote: > > > > > > hi all, > > > > I'm trying to figure out what sql doesnt like about this parenthesis; LINE 12 > > > > CREATE ENDPOINT WebServiceTest > > AUTHORIZATION [sa] > > STATE = STARTED > > AS HTTP > > ( > > AUTHENTICATION = (INTEGRATED), > > PATH = '/MyTestWebservicepath/', > > PORTS = (CLEAR), > > CLEAR_PORT = 8045, > > SITE = '*', > > > > ) THIS PAREN THROWS THE ERROR > > FOR SOAP > > ( > > WEBMETHOD 'urn:www.codeproject.com'.'GetProduct' > > ( > > NAME = 'Northwind.dbo.GetProduct', > > SCHEMA = STANDARD, > > FORMAT = ALL_RESULTS > > ), > > WSDL = DEFAULT, > > BATCHES = DISABLED, > > SCHEMA = STANDARD, > > LOGIN_TYPE = WINDOWS, > > SESSION_TIMEOUT = 100, > > DATABASE = 'Northwind', > > NAMESPACE = 'www.codeproject.com', > > CHARACTER_SET = XML > > ) > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > 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 jnatola at hotmail.com Thu May 24 14:49:55 2012 From: jnatola at hotmail.com (Jean-Paul N) Date: Thu, 24 May 2012 15:49:55 -0400 Subject: [dba-SQLServer] ) errors In-Reply-To: References: <4FBD21E9.4010900@colbyconsulting.com>, , , Message-ID: and im running sql2005 Jean-Paul Natola > Date: Thu, 24 May 2012 14:43:14 -0500 > From: garykjos at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] ) errors > > Comma at end of line 11? > > On Thu, May 24, 2012 at 2:22 PM, Jean-Paul N wrote: > > > > > > hi all, > > > > I'm trying to figure out what sql doesnt like about this parenthesis; LINE 12 > > > > CREATE ENDPOINT WebServiceTest > > AUTHORIZATION [sa] > > STATE = STARTED > > AS HTTP > > ( > > AUTHENTICATION = (INTEGRATED), > > PATH = '/MyTestWebservicepath/', > > PORTS = (CLEAR), > > CLEAR_PORT = 8045, > > SITE = '*', > > > > ) THIS PAREN THROWS THE ERROR > > FOR SOAP > > ( > > WEBMETHOD 'urn:www.codeproject.com'.'GetProduct' > > ( > > NAME = 'Northwind.dbo.GetProduct', > > SCHEMA = STANDARD, > > FORMAT = ALL_RESULTS > > ), > > WSDL = DEFAULT, > > BATCHES = DISABLED, > > SCHEMA = STANDARD, > > LOGIN_TYPE = WINDOWS, > > SESSION_TIMEOUT = 100, > > DATABASE = 'Northwind', > > NAMESPACE = 'www.codeproject.com', > > CHARACTER_SET = XML > > ) > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > 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 paul.hartland at googlemail.com Fri May 25 07:35:21 2012 From: paul.hartland at googlemail.com (Paul Hartland) Date: Fri, 25 May 2012 13:35:21 +0100 Subject: [dba-SQLServer] Is a cursor the way to go Message-ID: To all, I will try and explain the problem as best as I possibly can, for this purpose lets say I have two tables, PODetail which holds detail records for a purchase order, and a table containing a value which we have currently allocated to a single purchase order number POAllocation PODetail PoNumber Amount Allocated RowID 123456 50.00 0 1 123456 20.00 0 2 123456 76.00 0 3 POAllocation PONumber Allocated 123456 141.00 What I need to do is update the Allocated field in PODetail with a value, the way I want to do this is get the PO number and allocated amount from POAllocation and then loop through the PODetail records updating the Allocated field, so I would come to record (rowid) 1 if the allocated amount is less than 50.00 then update the allocated field with that value, if the allocated amount is great than 50.00 then update the allocated field to 50.00, take 50.00 away from 141.00 to get 91.00 then report the process for record (rowid) 2. I am thinking/in middle of writing a cursor inside a cursor, anyone else any better ideas on how to do this. Thanks in advance for any help. -- Paul Hartland paul.hartland at googlemail.com From fhtapia at gmail.com Fri May 25 08:53:00 2012 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 25 May 2012 06:53:00 -0700 Subject: [dba-SQLServer] back at it again... Message-ID: so last week I completed my first ever for production mobile application on iOS. It was a great learning opportunity, and I was able to really get into the working concepts of Objective C. This little app allows users to barcode their orders, view the materials they need to gather for their task and review their pdf work instructions without needing to resort to paper, fumble through pages to get to their instructions, and lastly they can process their completed work from the iPad w/o having to go stand in line at the computer workstation to log their work. It was fun, and now that we have the demo units out and we are testing we are looking at other "mobile" opportunities. The company wants a device agnostic mobile, product (so HTML5). They have an idea concept of a Troubleshooting guide (McAfee, if you're reading this, yes, the idea is back). It's actually a simple concept, You visit the site, punch in your Serial Number so that the system can gather information about what you might be having trouble with and then you simply pick and choose from the array of questions and answers such as: SN: 12345 I am having trouble with my Machine Spindle (because the user punched in the SN, the questions would lead him straight to the group of questions that match his product, ie: A type Machine with Spindles that are in-line. the user is the presented with a group of choices / questions, ie: The spindle will not turn the spindle is noisy the spindle turns rough the spindle is hot to the touch each choice invokes a group of response until the final answer leads the user to a set of procedures. examples would be: Is the Spindle within Specs? > procedure: how to measure spindle temparture. *yes *no (and so forth) So my impulse idea is I need a star schema. I'd need dimension tables For Questions, Answers and Procedures. I think the trick is in my Fact table when I'm deciding to present the user with a result like the above... Question: ---Procedure Link Did you Test A (Here is the procedure to test A) Answers: *Yes *No this is really the first hash at this and any followup ideas are welcomed as I hope to invoke further discussion on decision-supports solutions... comments, questions, ideas? Thank you, -Francisco http://bit.ly/sqlthis | Tsql and More... From davidmcafee at gmail.com Fri May 25 10:27:41 2012 From: davidmcafee at gmail.com (David McAfee) Date: Fri, 25 May 2012 08:27:41 -0700 Subject: [dba-SQLServer] back at it again... In-Reply-To: References: Message-ID: Think of it like a dynamic survey. I think Duane Hookem or Darryl Johnson had a sample db on Rogers site (in Access). I'm currently playing with JQuery Mobile and I am thinking of implementing Phone Gap as a cross platform common language. How are things with iOS? I had to friends ask me to write apps for them. I was turned off when I found out that in order to place an app on my or (their devices), I have to pay the $99 annual developer fee. If that fee isn't kept current (I get by a bus or something) then the app dies on their phones o3 or 90 days later?!?!?! I could see if this was a market app, but something that I just threw together for a friend gets killed too? Do you know if this is true? This is going to kill it for me. While I like a lot of things better about iOS, I do like the fact that I can make an Android app and give it to a buddy and it is theirs to keep forever. Sorry, for the off topic hijack, D On Fri, May 25, 2012 at 6:53 AM, Francisco Tapia wrote: > so last week I completed my first ever for production mobile application on > iOS. It was a great learning opportunity, and I was able to really get > into the working concepts of Objective C. This little app allows users to > barcode their orders, view the materials they need to gather for their task > and review their pdf work instructions without needing to resort to paper, > fumble through pages to get to their instructions, and lastly they can > process their completed work from the iPad w/o having to go stand in line > at the computer workstation to log their work. It was fun, and now that we > have the demo units out and we are testing we are looking at other "mobile" > opportunities. > > The company wants a device agnostic mobile, product (so HTML5). They have > an idea concept of a Troubleshooting guide (McAfee, if you're reading this, > yes, the idea is back). It's actually a simple concept, You visit the > site, punch in your Serial Number so that the system can gather information > about what you might be having trouble with and then you simply pick and > choose from the array of questions and answers such as: > > SN: 12345 > > I am having trouble with my Machine Spindle (because the user punched in > the SN, the questions would lead him straight to the group of questions > that match his product, ie: A type Machine with Spindles that are in-line. > > the user is the presented with a group of choices / questions, ie: > > The spindle will not turn > the spindle is noisy > the spindle turns rough > the spindle is hot to the touch > > > each choice invokes a group of response until the final answer leads the > user to a set of procedures. examples would be: > > Is the Spindle within Specs? > > procedure: how to measure spindle temparture. > > *yes > *no > > (and so forth) > > So my impulse idea is I need a star schema. > > I'd need dimension tables For Questions, Answers and Procedures. I think > the trick is in my Fact table when I'm deciding to present the user with a > result like the above... > > Question: ---Procedure Link > Did you Test A (Here is the procedure to test A) > Answers: > *Yes > *No > > this is really the first hash at this and any followup ideas are welcomed > as I hope to invoke further discussion on decision-supports solutions... > > comments, questions, ideas? > > Thank you, > -Francisco > http://bit.ly/sqlthis | Tsql and More... > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fhtapia at gmail.com Fri May 25 12:50:31 2012 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 25 May 2012 10:50:31 -0700 Subject: [dba-SQLServer] back at it again... In-Reply-To: References: Message-ID: hmm. can't find it on Roger's site... I'm going to this link, maybe there's another site these days: http://www.rogersaccesslibrary.com/forum/other-download-libraries_forums_cat1.html If you like JQuery you should also look at Sencha it has some really slick and "Fast" javascript libraries that make the app just scream on webkit browsers. (android/ios). iOS development has gone well for me... I ended up working on a sink or swim project here for our Control Assembly area... Currently we "are" printing over 300 pages of documents to get the line going per machine we build. The workstations that we have deployed the app at are now able to barcode their production orders and get to their materials list. Once they invoke the flag to deliver the PDFs via our ERP system we'll be able to deliver them from the iPad as well. in our development systems we were able to test this workflow and it was stable and fast. for a jailbroken device this is not true, you can actually just go that route if your friends are cool with jailbreaking. but for a standard iOS device the path to get an app onto a device is to provision the device for development. Thus the $99/fee, for adhoc and Enterprise apps that means that you need to re-sign the app once a year. if the app gets deployed to the appstore, you don't loose out if you decide to cancel your membership, generally apps in the app store get killed if you use a private api and apple finds out, or B, you the developer removes it. that is a feature I like about Android development is the ability to generate apk's and just give them away to anyone forever... I still haven't crossed that bridge to build an Android product... though I have a few co-workers requesting Android Apps -Francisco http://bit.ly/sqlthis | Tsql and More... On Fri, May 25, 2012 at 8:27 AM, David McAfee wrote: > Think of it like a dynamic survey. > > I think Duane Hookem or Darryl Johnson had a sample db on Rogers site (in > Access). > > I'm currently playing with JQuery Mobile and I am thinking of implementing > Phone Gap as a cross platform common language. > > How are things with iOS? > > I had to friends ask me to write apps for them. > I was turned off when I found out that in order to place an app on my or > (their devices), I have to pay the $99 annual developer fee. > If that fee isn't kept current (I get by a bus or something) then the app > dies on their phones o3 or 90 days later?!?!?! > > I could see if this was a market app, but something that I just threw > together for a friend gets killed too? > > Do you know if this is true? This is going to kill it for me. > > While I like a lot of things better about iOS, I do like the fact that I > can make an Android app and give it to a buddy and it is theirs to keep > forever. > > Sorry, for the off topic hijack, > D > > On Fri, May 25, 2012 at 6:53 AM, Francisco Tapia > wrote: > > > so last week I completed my first ever for production mobile application > on > > iOS. It was a great learning opportunity, and I was able to really get > > into the working concepts of Objective C. This little app allows users > to > > barcode their orders, view the materials they need to gather for their > task > > and review their pdf work instructions without needing to resort to > paper, > > fumble through pages to get to their instructions, and lastly they can > > process their completed work from the iPad w/o having to go stand in line > > at the computer workstation to log their work. It was fun, and now that > we > > have the demo units out and we are testing we are looking at other > "mobile" > > opportunities. > > > > The company wants a device agnostic mobile, product (so HTML5). They > have > > an idea concept of a Troubleshooting guide (McAfee, if you're reading > this, > > yes, the idea is back). It's actually a simple concept, You visit the > > site, punch in your Serial Number so that the system can gather > information > > about what you might be having trouble with and then you simply pick and > > choose from the array of questions and answers such as: > > > > SN: 12345 > > > > I am having trouble with my Machine Spindle (because the user punched in > > the SN, the questions would lead him straight to the group of questions > > that match his product, ie: A type Machine with Spindles that are > in-line. > > > > the user is the presented with a group of choices / questions, ie: > > > > The spindle will not turn > > the spindle is noisy > > the spindle turns rough > > the spindle is hot to the touch > > > > > > each choice invokes a group of response until the final answer leads the > > user to a set of procedures. examples would be: > > > > Is the Spindle within Specs? > > > procedure: how to measure spindle temparture. > > > > *yes > > *no > > > > (and so forth) > > > > So my impulse idea is I need a star schema. > > > > I'd need dimension tables For Questions, Answers and Procedures. I think > > the trick is in my Fact table when I'm deciding to present the user with > a > > result like the above... > > > > Question: ---Procedure Link > > Did you Test A (Here is the procedure to test A) > > Answers: > > *Yes > > *No > > > > this is really the first hash at this and any followup ideas are welcomed > > as I hope to invoke further discussion on decision-supports solutions... > > > > comments, questions, ideas? > > > > Thank you, > > -Francisco > > http://bit.ly/sqlthis | Tsql and More... > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jnatola at hotmail.com Fri May 25 14:28:38 2012 From: jnatola at hotmail.com (Jean-Paul N) Date: Fri, 25 May 2012 15:28:38 -0400 Subject: [dba-SQLServer] ) errors In-Reply-To: References: <4FBD21E9.4010900@colbyconsulting.com>, , , , , , , Message-ID: Everything I can find indicates that creating an http endpoint is suppored in sql 2005 yet I still get "This "CREATE ENDPOINT" statement is not supported on this edition of SQL Server." Jean-Paul Natola ---------------------------------------- > From: jnatola at hotmail.com > To: dba-sqlserver at databaseadvisors.com > Date: Thu, 24 May 2012 15:47:54 -0400 > Subject: Re: [dba-SQLServer] ) errors > > > I think you are onto something , removing the comma now returns this error Msg 7878, Level 16, State 1, Line 1 > This "CREATE ENDPOINT" statement is not supported on this edition of SQL Server. > > > > > > > > > > > > > > > > > > > > Jean-Paul Natola > > > > > Date: Thu, 24 May 2012 14:43:14 -0500 > > From: garykjos at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] ) errors > > > > Comma at end of line 11? > > > > On Thu, May 24, 2012 at 2:22 PM, Jean-Paul N wrote: > > > > > > > > > hi all, > > > > > > I'm trying to figure out what sql doesnt like about this parenthesis; LINE 12 > > > > > > CREATE ENDPOINT WebServiceTest > > > AUTHORIZATION [sa] > > > STATE = STARTED > > > AS HTTP > > > ( > > > AUTHENTICATION = (INTEGRATED), > > > PATH = '/MyTestWebservicepath/', > > > PORTS = (CLEAR), > > > CLEAR_PORT = 8045, > > > SITE = '*', > > > > > > ) THIS PAREN THROWS THE ERROR > > > FOR SOAP > > > ( > > > WEBMETHOD 'urn:www.codeproject.com'.'GetProduct' > > > ( > > > NAME = 'Northwind.dbo.GetProduct', > > > SCHEMA = STANDARD, > > > FORMAT = ALL_RESULTS > > > ), > > > WSDL = DEFAULT, > > > BATCHES = DISABLED, > > > SCHEMA = STANDARD, > > > LOGIN_TYPE = WINDOWS, > > > SESSION_TIMEOUT = 100, > > > DATABASE = 'Northwind', > > > NAMESPACE = 'www.codeproject.com', > > > CHARACTER_SET = XML > > > ) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > 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 > > > > _______________________________________________ > 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 Fri May 25 14:51:31 2012 From: garykjos at gmail.com (Gary Kjos) Date: Fri, 25 May 2012 14:51:31 -0500 Subject: [dba-SQLServer] ) errors In-Reply-To: References: <4FBD21E9.4010900@colbyconsulting.com> Message-ID: http://codebetter.com/raymondlewallen/2005/06/24/create-a-web-service-directly-from-sql-server-2005-using-an-http-endpoint/ looks very similar to your code. Perhaps it is what you started with? perhaps you are still missing something prior to that statement? GK On Fri, May 25, 2012 at 2:28 PM, Jean-Paul N wrote: > > > Everything I can find indicates that creating an http endpoint is suppored in sql 2005 > yet I still get "This "CREATE ENDPOINT" statement is not supported on this edition of SQL Server." > > > Jean-Paul Natola > > ---------------------------------------- >> From: jnatola at hotmail.com >> To: dba-sqlserver at databaseadvisors.com >> Date: Thu, 24 May 2012 15:47:54 -0400 >> Subject: Re: [dba-SQLServer] ) errors >> >> >> I think you are onto something , removing the comma now returns this error Msg 7878, Level 16, State 1, Line 1 >> This "CREATE ENDPOINT" statement is not supported on this edition of SQL Server. >> Jean-Paul Natola >> >> >> >> > Date: Thu, 24 May 2012 14:43:14 -0500 >> > From: garykjos at gmail.com >> > To: dba-sqlserver at databaseadvisors.com >> > Subject: Re: [dba-SQLServer] ) errors >> > >> > Comma at end of line 11? >> > >> > On Thu, May 24, 2012 at 2:22 PM, Jean-Paul N wrote: >> > > >> > > >> > > hi all, >> > > >> > > I'm trying to figure out what sql doesnt like about this parenthesis; LINE 12 >> > > >> > > CREATE ENDPOINT WebServiceTest >> > > AUTHORIZATION [sa] >> > > STATE = STARTED >> > > AS HTTP >> > > ( >> > > AUTHENTICATION = (INTEGRATED), >> > > PATH = '/MyTestWebservicepath/', >> > > PORTS = (CLEAR), >> > > CLEAR_PORT = 8045, >> > > SITE = '*', >> > > >> > > ) THIS PAREN THROWS THE ERROR >> > > FOR SOAP >> > > ( >> > > WEBMETHOD 'urn:www.codeproject.com'.'GetProduct' >> > > ( >> > > NAME = 'Northwind.dbo.GetProduct', >> > > SCHEMA = STANDARD, >> > > FORMAT = ALL_RESULTS >> > > ), >> > > WSDL = DEFAULT, >> > > BATCHES = DISABLED, >> > > SCHEMA = STANDARD, >> > > LOGIN_TYPE = WINDOWS, >> > > SESSION_TIMEOUT = 100, >> > > DATABASE = 'Northwind', >> > > NAMESPACE = 'www.codeproject.com', >> > > CHARACTER_SET = XML >> > > ) -- Gary Kjos garykjos at gmail.com From lawhonac at hiwaay.net Fri May 25 17:41:27 2012 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Fri, 25 May 2012 17:41:27 -0500 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem Message-ID: <000501cd3ac7$85891970$909b4c50$@net> I'm working my way through the exercises and examples in "Murach's SQL Server 2008 for Developer's" book when I come to Figure 4-15 (page 151) which has a very interesting example of how you can combine data from the same table using the UNION keyword. (Here's the code for that example.) USE AP GO SELECT InvoiceNumber, VendorName, '33% Payment' AS PaymentType, InvoiceTotal AS [Invoice Total], (InvoiceTotal * 0.333) AS Payment FROM Invoices INNER JOIN Vendors ON Invoices.VendorID = Vendors.VendorID WHERE InvoiceTotal > 10000.00 UNION SELECT InvoiceNumber, VendorName, '50% Payment' AS PaymentType, InvoiceTotal AS [Invoice Total], CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment FROM Invoices INNER JOIN Vendors ON Invoices.VendorID = Vendors.VendorID WHERE InvoiceTotal BETWEEN 500 AND 10000.00 UNION SELECT InvoiceNumber, VendorName, '100% Payment' AS PaymentType, InvoiceTotal AS [Invoice Total], (InvoiceTotal * 1.0) AS Payment FROM Invoices INNER JOIN Vendors ON Invoices.VendorID = Vendors.VendorID WHERE InvoiceTotal < 500.00 ORDER BY PaymentType DESC, VendorName, InvoiceNumber This UNION query calculates a payment based on what range the InvoiceTotal happens to fall in. Here are the fields from the first record of the result set. InvoiceNumber: 509786 Vendorname: Bertelsmann Industry Services, Inc. PaymentType: 50% Payment Invoice Total: 6940.25 Payment: 3470.1250000 In the Invoices (base table) the "InvoiceTotal" field is defined as follows: InvoiceTotal (money, not null) I modified the code (slightly) from what is given in the book. In the section of code that calculates a 50% payment, I used the CONVERT function to try and modify the output display of the "Payment" calculated field. (I wanted the calculated value of 3470.1250000 to display as character string 3,470.13 so that it looks more "money" like.) However, the CONVERT function is not working as I expected. Does anyone have an idea as to why the CONVERT function is not working as expected? TIA, Alan C. Lawhon From stuart at lexacorp.com.pg Fri May 25 18:00:40 2012 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Sat, 26 May 2012 09:00:40 +1000 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: <000501cd3ac7$85891970$909b4c50$@net> References: <000501cd3ac7$85891970$909b4c50$@net> Message-ID: <4FC00F18.328.3241D1A8@stuart.lexacorp.com.pg> Because you have used it incorrectly? To use a expression commonly found in programming forums: "Code Not Shown!" Post the problem line(s) and we are more likely to be able to help. -- Stuart On 25 May 2012 at 17:41, Alan Lawhon wrote: > > I modified the code (slightly) from what is given in the book. In the > section of code that calculates a 50% payment, I used the CONVERT function > to try and modify the output display of the "Payment" calculated field. (I > wanted the calculated value of 3470.1250000 to display as character string > 3,470.13 so that it looks more "money" like.) However, the CONVERT function > is not working as I expected. > > > > Does anyone have an idea as to why the CONVERT function is not working as > expected? > > > > TIA, > > > > Alan C. Lawhon > -- Stuart McLachlan Ph: +675 340 4392 Mob: +675 7100 2028 Web: http://www.lexacorp.com.pg From lawhonac at hiwaay.net Sat May 26 12:50:29 2012 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Sat, 26 May 2012 12:50:29 -0500 Subject: [dba-SQLServer] Kalen Delaney's Dream Message-ID: <000501cd3b68$0a946f70$1fbd4e50$@net> http://en.wikipedia.org/wiki/Kalen_Delaney I wonder if Oracle's Larry Ellison laughed when someone at his company (or maybe Bill Gates) mentioned Kalen's dream to him? (Funny ...) Kalen is well known for her extensive knowledge of what goes on "under the hood" of SQL Server, (i.e. "internals"), and how to use that knowledge to optimize query performance. Alan C. Lawhon From lawhonac at hiwaay.net Sat May 26 13:02:01 2012 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Sat, 26 May 2012 13:02:01 -0500 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: <4FC00F18.328.3241D1A8@stuart.lexacorp.com.pg> References: <000501cd3ac7$85891970$909b4c50$@net> <4FC00F18.328.3241D1A8@stuart.lexacorp.com.pg> Message-ID: <000b01cd3b69$a680dbc0$f3829340$@net> Stuart: I listed the code (verbatim) exactly as given in the book. The only difference (which is obvious) is the section involving the 50 percent calculation where I substituted a CONVERT function to try and change the display of the values in the "Payment" calculated field for the records that fall into the 50 percent payment catagory. When you're displaying monetary values in the result set, it doesn't make a lot of sense for a value such as $123.45 to display as 123.452349, so I was attempting to convert the 123.452349 value to a character string that displays as $123.45. I'm a little confused about data types, but I'll figure this out eventually. 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, May 25, 2012 6:01 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] SQL Server 2008 Display Formatting Problem Because you have used it incorrectly? To use a expression commonly found in programming forums: "Code Not Shown!" Post the problem line(s) and we are more likely to be able to help. -- Stuart On 25 May 2012 at 17:41, Alan Lawhon wrote: > > I modified the code (slightly) from what is given in the book. In the > section of code that calculates a 50% payment, I used the CONVERT > function to try and modify the output display of the "Payment" > calculated field. (I wanted the calculated value of 3470.1250000 to > display as character string > 3,470.13 so that it looks more "money" like.) However, the CONVERT > function is not working as I expected. > > > > Does anyone have an idea as to why the CONVERT function is not working > as expected? > > > > TIA, > > > > Alan C. Lawhon > -- Stuart McLachlan Ph: +675 340 4392 Mob: +675 7100 2028 Web: http://www.lexacorp.com.pg _______________________________________________ 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 May 26 13:47:56 2012 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Sat, 26 May 2012 13:47:56 -0500 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: <000501cd3ac7$85891970$909b4c50$@net> References: <000501cd3ac7$85891970$909b4c50$@net> Message-ID: <000101cd3b70$10930960$31b91c20$@net> I (sort of) figured out the problem. Solely on a hunch, I decided to comment out all of the code except for the block of statements that handle the 50 percent calculation. (The line with the CONVERT function was the line producing the compile error, so it made sense to isolate on that block of code.) I then ran the code with the CONVERT function still in place to calculate (and display) the "Payment" field. The modified code appears as follows: USE AP GO SELECT InvoiceNumber, VendorName, '50% Payment' AS PaymentType, InvoiceTotal AS [Invoice Total], '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment FROM Invoices INNER JOIN Vendors ON Invoices.VendorID = Vendors.VendorID WHERE InvoiceTotal BETWEEN 500 AND 10000.00 ORDER BY PaymentType DESC, VendorName, InvoiceNumber Interestingly, this code executed (no compile error) so the CONVERT function worked although the style parameter didn't produce the exact result that the SQL Server documentation indicates. The: '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment field calculation produced output that looked like $1062.12500 when it should have appeared as: $1,062.13. Maybe I'm a bit confused as to how precision and scale work when dealing with decimal and money data types. It might also be the case that when you have a UNION query, SQL Server doesn't play nice with the CONVERT function. This is nitpicking anyway, so I'm going to let it go and move on to the next topic. Alan C. Lawhon From stuart at lexacorp.com.pg Sat May 26 16:59:28 2012 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Sun, 27 May 2012 07:59:28 +1000 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: <000b01cd3b69$a680dbc0$f3829340$@net> References: <000501cd3ac7$85891970$909b4c50$@net>, <4FC00F18.328.3241D1A8@stuart.lexacorp.com.pg>, <000b01cd3b69$a680dbc0$f3829340$@net> Message-ID: <4FC15240.10180.4A6AF0B@stuart.lexacorp.com.pg> Code still not shown :-) Most of us don't have the book, so we still don't know exactly what you are doing. At least post the line containing the CONVERT function so that we can see how you are using it. On 26 May 2012 at 13:02, Alan Lawhon wrote: > Stuart: > > I listed the code (verbatim) exactly as given in the book. The only > difference (which is obvious) is the section involving the 50 percent > calculation where I substituted a CONVERT function to try and change the > display of the values in the "Payment" calculated field for the records that > fall into the 50 percent payment catagory. When you're displaying monetary > values in the result set, it doesn't make a lot of sense for a value such as > $123.45 to display as 123.452349, so I was attempting to convert the > 123.452349 value to a character string that displays as $123.45. > > I'm a little confused about data types, but I'll figure this out eventually. > > 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, May 25, 2012 6:01 PM > To: Discussion concerning MS SQL Server > Subject: Re: [dba-SQLServer] SQL Server 2008 Display Formatting Problem > > Because you have used it incorrectly? > > To use a expression commonly found in programming forums: > "Code Not Shown!" > > Post the problem line(s) and we are more likely to be able to help. > > -- > Stuart > > On 25 May 2012 at 17:41, Alan Lawhon wrote: > > > > > I modified the code (slightly) from what is given in the book. In the > > section of code that calculates a 50% payment, I used the CONVERT > > function to try and modify the output display of the "Payment" > > calculated field. (I wanted the calculated value of 3470.1250000 to > > display as character string > > 3,470.13 so that it looks more "money" like.) However, the CONVERT > > function is not working as I expected. > > > > > > > > Does anyone have an idea as to why the CONVERT function is not working > > as expected? > > > > > > > > TIA, > > > > > > > > Alan C. Lawhon > > > -- > Stuart McLachlan > > Ph: +675 340 4392 > Mob: +675 7100 2028 > Web: http://www.lexacorp.com.pg > > _______________________________________________ > 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 > > -- Stuart McLachlan Ph: +675 340 4392 Mob: +675 7100 2028 Web: http://www.lexacorp.com.pg From stuart at lexacorp.com.pg Sat May 26 17:13:11 2012 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Sun, 27 May 2012 08:13:11 +1000 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: <000101cd3b70$10930960$31b91c20$@net> References: <000501cd3ac7$85891970$909b4c50$@net>, <000101cd3b70$10930960$31b91c20$@net> Message-ID: <4FC15577.15923.4B33E6E@stuart.lexacorp.com.pg> A lot depends on what type InvoiceTotal is: Decimal, Float, Money, SmallMoney? You will get different results when converting different types to VARCHAR. Based on your output, it looks as though InvoiceTotal is a Float, which "1" will always convert to 8 digits. -- Stuart On 26 May 2012 at 13:47, Alan Lawhon wrote: > I (sort of) figured out the problem. Solely on a hunch, I decided to > comment out all of the code except for the block of statements that handle > the 50 percent calculation. (The line with the CONVERT function was the > line producing the compile error, so it made sense to isolate on that block > of code.) I then ran the code with the CONVERT function still in place to > calculate (and display) the "Payment" field. The modified code appears as > follows: > > USE AP > GO > SELECT InvoiceNumber, VendorName, '50% Payment' AS PaymentType, > InvoiceTotal AS [Invoice Total], > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > FROM Invoices INNER JOIN Vendors > ON Invoices.VendorID = Vendors.VendorID > WHERE InvoiceTotal BETWEEN 500 AND 10000.00 > ORDER BY PaymentType DESC, VendorName, InvoiceNumber > > Interestingly, this code executed (no compile error) so the CONVERT function > worked although the style parameter didn't produce the exact result that > the SQL Server documentation indicates. The: > > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > > field calculation produced output that looked like $1062.12500 when it > should have appeared as: $1,062.13. Maybe I'm a bit confused as to how > precision and scale work when dealing with decimal and money data types. It > might also be the case that when you have a UNION query, SQL Server doesn't > play nice with the CONVERT function. > > This is nitpicking anyway, so I'm going to let it go and move on to the next > topic. > > Alan C. Lawhon > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- Stuart McLachlan Ph: +675 340 4392 Mob: +675 7100 2028 Web: http://www.lexacorp.com.pg From lawhonac at hiwaay.net Sat May 26 17:49:56 2012 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Sat, 26 May 2012 17:49:56 -0500 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: <4FC15577.15923.4B33E6E@stuart.lexacorp.com.pg> References: <000501cd3ac7$85891970$909b4c50$@net>, <000101cd3b70$10930960$31b91c20$@net> <4FC15577.15923.4B33E6E@stuart.lexacorp.com.pg> Message-ID: <000101cd3b91$df029ec0$9d07dc40$@net> Stuart: The following is from my initial post: In the Invoices (base table) the "InvoiceTotal" field is defined as follows: InvoiceTotal (money, not null) 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: Saturday, May 26, 2012 5:13 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] SQL Server 2008 Display Formatting Problem A lot depends on what type InvoiceTotal is: Decimal, Float, Money, SmallMoney? You will get different results when converting different types to VARCHAR. Based on your output, it looks as though InvoiceTotal is a Float, which "1" will always convert to 8 digits. -- Stuart On 26 May 2012 at 13:47, Alan Lawhon wrote: > I (sort of) figured out the problem. Solely on a hunch, I decided to > comment out all of the code except for the block of statements that handle > the 50 percent calculation. (The line with the CONVERT function was the > line producing the compile error, so it made sense to isolate on that block > of code.) I then ran the code with the CONVERT function still in place to > calculate (and display) the "Payment" field. The modified code appears as > follows: > > USE AP > GO > SELECT InvoiceNumber, VendorName, '50% Payment' AS PaymentType, > InvoiceTotal AS [Invoice Total], > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > FROM Invoices INNER JOIN Vendors > ON Invoices.VendorID = Vendors.VendorID > WHERE InvoiceTotal BETWEEN 500 AND 10000.00 > ORDER BY PaymentType DESC, VendorName, InvoiceNumber > > Interestingly, this code executed (no compile error) so the CONVERT function > worked although the style parameter didn't produce the exact result that > the SQL Server documentation indicates. The: > > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > > field calculation produced output that looked like $1062.12500 when it > should have appeared as: $1,062.13. Maybe I'm a bit confused as to how > precision and scale work when dealing with decimal and money data types. It > might also be the case that when you have a UNION query, SQL Server doesn't > play nice with the CONVERT function. > > This is nitpicking anyway, so I'm going to let it go and move on to the next > topic. > > Alan C. Lawhon > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- Stuart McLachlan Ph: +675 340 4392 Mob: +675 7100 2028 Web: http://www.lexacorp.com.pg _______________________________________________ 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 Sat May 26 18:06:53 2012 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Sun, 27 May 2012 09:06:53 +1000 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: <000101cd3b91$df029ec0$9d07dc40$@net> References: <000501cd3ac7$85891970$909b4c50$@net>, <4FC15577.15923.4B33E6E@stuart.lexacorp.com.pg>, <000101cd3b91$df029ec0$9d07dc40$@net> Message-ID: <4FC1620D.5554.4E4688B@stuart.lexacorp.com.pg> I didn't think it through far enough. It is not the datatype of Invoice Total that is important, it is the datatype of (InvoiceTotal * 0.5): http://dba.fyicenter.com/faq/sql_server/Rules_on_Arithmetic_Operations.html When arithmetic operations are performed on expressions of different data types, implicit data type conversion will be performed before the arithmetic operation on the expression with a lower data type rank. Numeric data type ranks are from low to high: TINYINT, SMALLINT, INT, BIGINT, SMALLMONEY, MONEY, DECIMAL, and FLOAT IOW, multiplying InvoiceTotal (Money) by 0.5 (Float) results in an implicit conversion to a Float, hence the "1" converting to 8 digits. -- Stuart On 26 May 2012 at 17:49, Alan Lawhon wrote: > Stuart: > > The following is from my initial post: > > In the Invoices (base table) the "InvoiceTotal" field is defined as follows: > InvoiceTotal (money, not null) > > 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: Saturday, May 26, 2012 5:13 PM > To: Discussion concerning MS SQL Server > Subject: Re: [dba-SQLServer] SQL Server 2008 Display Formatting Problem > > A lot depends on what type InvoiceTotal is: Decimal, Float, Money, > SmallMoney? > You will get different results when converting different types to VARCHAR. > > Based on your output, it looks as though InvoiceTotal is a Float, which "1" > will always convert to 8 digits. > > > -- > Stuart > > On 26 May 2012 at 13:47, Alan Lawhon wrote: > > > I (sort of) figured out the problem. Solely on a hunch, I decided to > > comment out all of the code except for the block of statements that handle > > the 50 percent calculation. (The line with the CONVERT function was the > > line producing the compile error, so it made sense to isolate on that > block > > of code.) I then ran the code with the CONVERT function still in place to > > calculate (and display) the "Payment" field. The modified code appears as > > follows: > > > > USE AP > > GO > > SELECT InvoiceNumber, VendorName, '50% Payment' AS PaymentType, > > InvoiceTotal AS [Invoice Total], > > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > > FROM Invoices INNER JOIN Vendors > > ON Invoices.VendorID = Vendors.VendorID > > WHERE InvoiceTotal BETWEEN 500 AND 10000.00 > > ORDER BY PaymentType DESC, VendorName, InvoiceNumber > > > > Interestingly, this code executed (no compile error) so the CONVERT > function > > worked although the style parameter didn't produce the exact result that > > the SQL Server documentation indicates. The: > > > > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > > > > field calculation produced output that looked like $1062.12500 when it > > should have appeared as: $1,062.13. Maybe I'm a bit confused as to how > > precision and scale work when dealing with decimal and money data types. > It > > might also be the case that when you have a UNION query, SQL Server > doesn't > > play nice with the CONVERT function. > > > > This is nitpicking anyway, so I'm going to let it go and move on to the > next > > topic. > > > > Alan C. Lawhon > > > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > -- > Stuart McLachlan > > Ph: +675 340 4392 > Mob: +675 7100 2028 > Web: http://www.lexacorp.com.pg > > _______________________________________________ > 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 > > -- Stuart McLachlan Ph: +675 340 4392 Mob: +675 7100 2028 Web: http://www.lexacorp.com.pg From lawhonac at hiwaay.net Sun May 27 23:33:50 2012 From: lawhonac at hiwaay.net (Alan Lawhon) Date: Sun, 27 May 2012 23:33:50 -0500 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: <4FC1620D.5554.4E4688B@stuart.lexacorp.com.pg> References: <000501cd3ac7$85891970$909b4c50$@net>, <4FC15577.15923.4B33E6E@stuart.lexacorp.com.pg>, <000101cd3b91$df029ec0$9d07dc40$@net> <4FC1620D.5554.4E4688B@stuart.lexacorp.com.pg> Message-ID: <000101cd3c8b$149e45d0$3ddad170$@net> Stuart: Thanks for the link (and the tip). The following [modified] code block worked nicely. SELECT InvoiceNumber, VendorName, '50% Payment' AS PaymentType, InvoiceTotal AS [Invoice Total], '$' + CONVERT(varchar, (InvoiceTotal * CAST(0.5 As money)), 1) AS Payment FROM Invoices INNER JOIN Vendors ON Invoices.VendorID = Vendors.VendorID WHERE InvoiceTotal BETWEEN 500.00 AND 10000.00 It's neat sticking a CAST function inside a CONVERT function. I wonder if this is the first time such a thing has ever been done? (Probably not!) Ha! Ha! 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: Saturday, May 26, 2012 6:07 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] SQL Server 2008 Display Formatting Problem I didn't think it through far enough. It is not the datatype of Invoice Total that is important, it is the datatype of (InvoiceTotal * 0.5): http://dba.fyicenter.com/faq/sql_server/Rules_on_Arithmetic_Operations.html When arithmetic operations are performed on expressions of different data types, implicit data type conversion will be performed before the arithmetic operation on the expression with a lower data type rank. Numeric data type ranks are from low to high: TINYINT, SMALLINT, INT, BIGINT, SMALLMONEY, MONEY, DECIMAL, and FLOAT IOW, multiplying InvoiceTotal (Money) by 0.5 (Float) results in an implicit conversion to a Float, hence the "1" converting to 8 digits. -- Stuart On 26 May 2012 at 17:49, Alan Lawhon wrote: > Stuart: > > The following is from my initial post: > > In the Invoices (base table) the "InvoiceTotal" field is defined as follows: > InvoiceTotal (money, not null) > > 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: Saturday, May 26, 2012 5:13 PM > To: Discussion concerning MS SQL Server > Subject: Re: [dba-SQLServer] SQL Server 2008 Display Formatting Problem > > A lot depends on what type InvoiceTotal is: Decimal, Float, Money, > SmallMoney? > You will get different results when converting different types to VARCHAR. > > Based on your output, it looks as though InvoiceTotal is a Float, which "1" > will always convert to 8 digits. > > > -- > Stuart > > On 26 May 2012 at 13:47, Alan Lawhon wrote: > > > I (sort of) figured out the problem. Solely on a hunch, I decided to > > comment out all of the code except for the block of statements that handle > > the 50 percent calculation. (The line with the CONVERT function was the > > line producing the compile error, so it made sense to isolate on that > block > > of code.) I then ran the code with the CONVERT function still in place to > > calculate (and display) the "Payment" field. The modified code appears as > > follows: > > > > USE AP > > GO > > SELECT InvoiceNumber, VendorName, '50% Payment' AS PaymentType, > > InvoiceTotal AS [Invoice Total], > > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > > FROM Invoices INNER JOIN Vendors > > ON Invoices.VendorID = Vendors.VendorID > > WHERE InvoiceTotal BETWEEN 500 AND 10000.00 > > ORDER BY PaymentType DESC, VendorName, InvoiceNumber > > > > Interestingly, this code executed (no compile error) so the CONVERT > function > > worked although the style parameter didn't produce the exact result that > > the SQL Server documentation indicates. The: > > > > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > > > > field calculation produced output that looked like $1062.12500 when it > > should have appeared as: $1,062.13. Maybe I'm a bit confused as to how > > precision and scale work when dealing with decimal and money data types. > It > > might also be the case that when you have a UNION query, SQL Server > doesn't > > play nice with the CONVERT function. > > > > This is nitpicking anyway, so I'm going to let it go and move on to the > next > > topic. > > > > Alan C. Lawhon > > > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > -- > Stuart McLachlan > > Ph: +675 340 4392 > Mob: +675 7100 2028 > Web: http://www.lexacorp.com.pg > > _______________________________________________ > 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 > > -- Stuart McLachlan Ph: +675 340 4392 Mob: +675 7100 2028 Web: http://www.lexacorp.com.pg _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From rls at WeBeDb.com Tue May 29 08:41:21 2012 From: rls at WeBeDb.com (Robert Stewart) Date: Tue, 29 May 2012 08:41:21 -0500 Subject: [dba-SQLServer] SQL Server 2008 Display Formatting Problem In-Reply-To: References: Message-ID: <5D6E3CBF-15A0-4838-A6DB-6EDAF6E30824@holly.arvixe.com> Alan, The problem is that all elements of a union query have to be the same data type. You were mixing numeric and character data. You would have to use the convert on all the union sections for the money to not have the error. As to the behavior of convert on money. Did you look at the value type for money? It goes to 4 decimals. So, it is working perfectly correct. You would need to either ROUND or Truncate the last 2 digits of the money amount. Robert At 04:59 PM 5/26/2012, you wrote: >Date: Sat, 26 May 2012 13:47:56 -0500 >From: "Alan Lawhon" >To: "'Discussion concerning MS SQL Server'" > >Subject: Re: [dba-SQLServer] SQL Server 2008 Display Formatting > Problem >Message-ID: <000101cd3b70$10930960$31b91c20$@net> >Content-Type: text/plain; charset="us-ascii" > >I (sort of) figured out the problem. Solely on a hunch, I decided to >comment out all of the code except for the block of statements that handle >the 50 percent calculation. (The line with the CONVERT function was the >line producing the compile error, so it made sense to isolate on that block >of code.) I then ran the code with the CONVERT function still in place to >calculate (and display) the "Payment" field. The modified code appears as >follows: > >USE AP >GO > SELECT InvoiceNumber, VendorName, '50% Payment' AS PaymentType, > InvoiceTotal AS [Invoice Total], > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > FROM Invoices INNER JOIN Vendors > ON Invoices.VendorID = Vendors.VendorID > WHERE InvoiceTotal BETWEEN 500 AND 10000.00 >ORDER BY PaymentType DESC, VendorName, InvoiceNumber > >Interestingly, this code executed (no compile error) so the CONVERT function >worked although the style parameter didn't produce the exact result that >the SQL Server documentation indicates. The: > > '$' + CONVERT(varchar, (InvoiceTotal * 0.5), 1) AS Payment > >field calculation produced output that looked like $1062.12500 when it >should have appeared as: $1,062.13. Maybe I'm a bit confused as to how >precision and scale work when dealing with decimal and money data types. It >might also be the case that when you have a UNION query, SQL Server doesn't >play nice with the CONVERT function. > >This is nitpicking anyway, so I'm going to let it go and move on to the next >topic. > >Alan C. Lawhon > > Robert L. Stewart www.WeBeDb.com www.DBGUIDesign.com www.RLStewartPhotography.com From fhtapia at gmail.com Tue May 29 08:55:04 2012 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 29 May 2012 06:55:04 -0700 Subject: [dba-SQLServer] Is there any chance? In-Reply-To: <4FBABF08.2010708@colbyconsulting.com> References: <4FBABF08.2010708@colbyconsulting.com> Message-ID: John, I know that EXEC @SQL command won't evaluate syntax errors until the statement is called. If you run the pure SQL BULK INSERT [_DataEmailDD].[dbo].[ConsEmai l_AK] FROM '\\Azul\PSM\Data\_DataEmailDD\ConsEmail_AK.CSV' WITH (FORMATFILE= '\\Azul\PSM\data\_DataEmailDD\EmailImpFormat.xml') what is the error message? also, is there any reason for using EXEC over sp_executesql? from what I understand sp_executesql is more efficient, in that if you are making similar calls to the query engine but varying minor values (ala variables) the engine will try to use the previous query plan as much as possible. -Francisco http://bit.ly/sqlthis | Tsql and More... On Mon, May 21, 2012 at 3:17 PM, jwcolby wrote: > I am trying to get Bulk Insert (import) working with CSV files ("," > delimited) using a format file. I have about 60 files with around 250 > million total records that I need to import. Just using the built-in > wizard works but is a royal PITA because I have to modify each and every > time to widen the fields to 250 characters, build each file by hand etc. > > So I have a SP that creates the tables. I then use the following to try > to do the import: > > USE [_DataEmailDD] > GO > /****** Object: StoredProcedure [dbo].[sp_AZIn_BCPInOneFile] Script > Date: 05/21/2012 17:19:43 ******/ > SET ANSI_NULLS ON > GO > SET QUOTED_IDENTIFIER ON > GO > -- ==============================**=============== > -- Author: > -- Create date: > -- Description: > -- ==============================**=============== > ALTER PROCEDURE [dbo].[sp_AZIn_BCPInOneFile] > -- Add the parameters for the stored procedure here > @DBName varchar(50), @TblName varchar(50), > @FilePath varchar(1000), @FileName varchar(255) > > AS > BEGIN > -- SET NOCOUNT ON added to prevent extra result sets from > -- interfering with SELECT statements. > SET NOCOUNT ON; > > -- Insert statements for procedure here > declare @sql varchar(8000) > DECLARE @FileSpec varchar(1000) > > Declare @ErrorDesc varchar(4000) > Declare @ErrorNo int > Declare @RecsAffected int > > set @filespec = @FilePath > set @filespec = @filespec + @FileName > begin try > set @SQL = 'BULK INSERT [' + @DBName + '].[dbo].[' + > @TblName + '] FROM ' + '''' + @filespec + '''' + ' WITH (FORMATFILE= ' + > '''' + '\\Azul\PSM\data\_DataEmailDD\**EmailImpFormat.xml' + '''' + ')' > > print @SQL > exec (@SQL) > select @RecsAffected = @@RowCount > select @ErrorDesc = 'Success' > select @ErrorNo = 0 > return 0 > end try > begin catch > select @ErrorNo = @@Error > select @ErrorDesc = ERROR_MESSAGE() > print 'There was a BCP error IMPORTING data into ' + @DBName > print ERROR_MESSAGE() > return -1 > end catch > -- > > Standard stuff except for the SQL Statement which when printed gives me > the following: > > BULK INSERT [_DataEmailDD].[dbo].[**ConsEmail_AK] FROM > '\\Azul\PSM\Data\_DataEmailDD\**ConsEmail_AK.CSV' WITH (FORMATFILE= > '\\Azul\PSM\data\_DataEmailDD\**EmailImpFormat.xml') > > and execution thereof gives me the infamous (and totally useless) > > There was a BCP error IMPORTING data into _DataEmailDD > Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)". > > It just seems like my chance of making this work is pretty minimal. > > I have spent about 4 hours Googling to even get as far as I am and the > > Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)". > > returns about a million entirely different pages for a million entirely > different problems. It is as if any problem whatsoever returns this > message. > > So, what do you say? Is this a "you gotta be an expert so forget it" > kinda deal? All of the various web pages explaining how to do this make it > sound so easy but of course no one mentions how to troubleshoot the mess. > > -- > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > ______________________________**_________________ > dba-SQLServer mailing list > dba-SQLServer@**databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.**com > >