From jwcolby at colbyconsulting.com Thu Apr 1 08:02:18 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 01 Apr 2010 09:02:18 -0400 Subject: [dba-SQLServer] Reference table in different db Message-ID: <4BB4995A.50107@colbyconsulting.com> Guys, I am building dynamic SQL in a stored procedure. I pass in the name of the database, table etc. This is what I currently do: Declare FieldCursor CURSOR FAST_FORWARD FOR SELECT * FROM tblCriteriaFieldData WHERE maxlength is not Null This is what I need to do: Declare FieldCursor CURSOR FAST_FORWARD FOR SELECT * FROM @SomeDb.tblCriteriaFieldData WHERE maxlength is not Null Where @SomeDB is a passed in database name. Obviously this syntax is not correct. I tried to declare an @SQL statement and then build up the select into that @SQL and then use: Declare FieldCursor CURSOR FAST_FORWARD FOR @SQL but that doesn't work either. So I need to know how to open a cursor for a table in another database where the database name is not hard coded. Any assistance is greatly appreciated. -- John W. Colby www.ColbyConsulting.com From jwcolby at colbyconsulting.com Fri Apr 2 10:21:47 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Fri, 02 Apr 2010 11:21:47 -0400 Subject: [dba-SQLServer] Clustered Index question Message-ID: <4BB60B8B.4080909@colbyconsulting.com> Having a clustered index does not slow down updates IF the updates are not to the key fields, correct? -- John W. Colby www.ColbyConsulting.com From jwcolby at colbyconsulting.com Fri Apr 2 12:36:42 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Fri, 02 Apr 2010 13:36:42 -0400 Subject: [dba-SQLServer] Initial start of remote desktop fails - Windows 2003 Message-ID: <4BB62B2A.4090805@colbyconsulting.com> I use RD to work on the servers in my office from my laptop in my office (entirely within my LAN). When I attempt to connect RD, it fails completely and always if I have not first logged in to the server manually, through the keyboard / mouse connected to that machine. IOW I have to use my KVM switch to physically see the machine, AND log in, THEN RD will work from my laptop. If I use the KVM to go to the physical machine and log out, RD from the laptop will continue to work IF ALREADY CONNECTED, but will fail if I close the RD session and try to RD back in. IOW RD simply cannot connect if there is not already a user logged in. Additionally, once I have done that manual / initial login to the physical machine, RD will fail the first time I try it. I have to try to connect, immediately cancel that attempt, then try it again and then it connects right in. I can close the RD session and start it again, no problem (as long as that other user is still connected). So... has anyone seen this behavior? Has anyone seen a solution to that problem such that RD will work first time / every time, regardless of anything? -- John W. Colby www.ColbyConsulting.com From accessd at shaw.ca Sat Apr 3 03:34:14 2010 From: accessd at shaw.ca (Jim Lawrence) Date: Sat, 3 Apr 2010 01:34:14 -0700 Subject: [dba-SQLServer] Initial start of remote desktop fails - Windows 2003 In-Reply-To: <4BB62B2A.4090805@colbyconsulting.com> References: <4BB62B2A.4090805@colbyconsulting.com> Message-ID: Hi John: I was looking up another issue and ran across this article and thought of your question a few dys ago about your speed or lack of it as your databases get older and slower. This might be caused by fragmentation of the indexes and the following link might help you out: http://sqlserverpedia.com/wiki/Index_Maintenance Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Friday, April 02, 2010 10:37 AM To: Access Developers discussion and problem solving; VBA; Sqlserver-Dba Subject: [dba-SQLServer] Initial start of remote desktop fails - Windows 2003 I use RD to work on the servers in my office from my laptop in my office (entirely within my LAN). When I attempt to connect RD, it fails completely and always if I have not first logged in to the server manually, through the keyboard / mouse connected to that machine. IOW I have to use my KVM switch to physically see the machine, AND log in, THEN RD will work from my laptop. If I use the KVM to go to the physical machine and log out, RD from the laptop will continue to work IF ALREADY CONNECTED, but will fail if I close the RD session and try to RD back in. IOW RD simply cannot connect if there is not already a user logged in. Additionally, once I have done that manual / initial login to the physical machine, RD will fail the first time I try it. I have to try to connect, immediately cancel that attempt, then try it again and then it connects right in. I can close the RD session and start it again, no problem (as long as that other user is still connected). So... has anyone seen this behavior? Has anyone seen a solution to that problem such that RD will work first time / every time, regardless of anything? -- John W. Colby www.ColbyConsulting.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From marklbreen at gmail.com Sat Apr 3 05:36:36 2010 From: marklbreen at gmail.com (Mark Breen) Date: Sat, 3 Apr 2010 11:36:36 +0100 Subject: [dba-SQLServer] Reference table in different db In-Reply-To: <4BB4995A.50107@colbyconsulting.com> References: <4BB4995A.50107@colbyconsulting.com> Message-ID: Hello John, I can only answer half this query. *FIRST HALF* You need to build a string, which you can this execute. For example, you can build delcare @SQLtoExexcute nvarchar(2000) Set @SQLtoExexcute = 'Update Customers Set Limit = 100' Exec (@SQLtoExexcute) -- Check the exact syntax of this. As you can see, I have just dynamically created and ran an sql statement. So here is another Drop usp_UpdateCustomerLimits -- you can change this to check for its existance first if you like Delcare @SQLtoExexcute nvarchar(2000) Set @SQLtoExexcute = 'Create Proc usp_UpdateCustomerLimits as Update Customers Set Limit = 100' Exec (@SQLtoExexcute) -- Check the exact syntax of this. -- Now you have a dynamically created sproc Exec usp_UpdateCustomerLimits so once you have the concept of programatically creating an sql string you have the two options of a) build the string within my sproc and execute it b) actually drop and create a sproc dynamically and run it each time as if it were a static sproc I know that the text in the cursor you want to work with is longer than my examples but it should work the same. *SECOND HALF* I do not know whether you can use just a small piece of what I must outlined above to create the cursor only. IOW, if you can dynamically just build one line which is the like that creates the cursor, it will save you creating the entire sproc, but I cannot say as I have never done that. If you get that bit working, let us know. Is that any help? thanks Mark On 1 April 2010 14:02, jwcolby wrote: > Guys, > > I am building dynamic SQL in a stored procedure. I pass in the name of the > database, table etc. > > This is what I currently do: > > Declare FieldCursor CURSOR FAST_FORWARD FOR > SELECT * FROM tblCriteriaFieldData > WHERE maxlength is not Null > > This is what I need to do: > > Declare FieldCursor CURSOR FAST_FORWARD FOR > SELECT * FROM @SomeDb.tblCriteriaFieldData > WHERE maxlength is not Null > > Where @SomeDB is a passed in database name. Obviously this syntax is not > correct. > > I tried to declare an @SQL statement and then build up the select into that > @SQL and then use: > > Declare FieldCursor CURSOR FAST_FORWARD FOR > @SQL > > but that doesn't work either. > > So I need to know how to open a cursor for a table in another database > where the database name is > not hard coded. > > Any assistance is greatly appreciated. > > -- > John W. Colby > www.ColbyConsulting.com > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From marklbreen at gmail.com Sat Apr 3 06:53:51 2010 From: marklbreen at gmail.com (Mark Breen) Date: Sat, 3 Apr 2010 12:53:51 +0100 Subject: [dba-SQLServer] How to get MS Word mailmerge to open a query with parameters against an linked SQL Table In-Reply-To: References: Message-ID: Hello All, I think that the following works perfectly as a solution for my problem posted below. http://support.microsoft.com/kb/214183 if you need this, review it carefully, as I missed out the critical bit in the Word 2007 section where it refers you to the Options button first. Incidentally, in my Word 2003, I also had to go to Options\general to turn on the DDE access. If tech and sql are seeing this for the first time, it is because I mis typed the email on the first pass, so now you get a solution to a problem you did not have ! :) Thanks Mark On 3 April 2010 11:50, Mark Breen wrote: > Hello All, > > First of all, I hope you are not annoyed by my three cross posts. This > question involves MS Word mailmerges, MS Access and MS SQL Server. > > I have a SQL Server database hosting in a data centre. > I have an Access 2003 db with ODBC inked tables to the SQL Server > I have a query with hard coded Criteria -- eg Where CustId = 100 > I have MS Word Version 2003 with a MailMerge doc Set up and connected to > the Query in MS Access. > The Mailmerge works well with this setup > > When I change the above setup to use parmeters instead of hard coded values > in the criteria of the query, I can successfully run the query from within > access. The params popup and ask for the param value, and then the query > executes and returns records as expected. > > However, the MS Word mailmerge does not work, and the mailmerge doc cannot > connect to the data source. If I try to re-establish the data source > connection, MS Word does not even see the query as a potential data source > within the db. > > If you have any suggestions, I would really appreciate it. > > Thank you, as always for your time, > > Mark > > > From jwcolby at colbyconsulting.com Sat Apr 3 07:16:07 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 03 Apr 2010 08:16:07 -0400 Subject: [dba-SQLServer] Reference table in different db In-Reply-To: References: <4BB4995A.50107@colbyconsulting.com> Message-ID: <4BB73187.4040802@colbyconsulting.com> Mark, I am probably the king of dynamic SQL. I have dozens of stored procedures where I dynamically build SQL to do everything from build tables with varying field names to populating said table, to building indexes, to BCP in / out. In fact it is one of those applications where I am hitting the wall. My client asks for a set of records WHERE (some long list of field compares). That long list of field compares changes from order to order. So I build a table (on-the-fly) where there is a base part (which never changes) and a dynamic part (where the select fields change for each order). The way that I figured out to do this was to build a little table that will hold the names of the fields in my select query (the changing part). I grab the field list and pop it into this little table. I then open that field list and bring it into a cursor. Using the cursor I compare each field name with the list of fields in the base table (some will be the same) and any field not in the base table gets added to the table using a modify table. When I am done iterating the cursor, my base table now has each and every field in the selection query and is ready to accept the data coming from the selection query. I then have to do the same kind of process again to build up an INSERT INTO query which takes the data coming from the query and insert into the order table. So I use a cursor in these two specific places. The cursors are small (1 to 10 field names) and are used to build dynamic SQL to build a custom table and then insert data into that custom table. I THINK I can get around the whole "cursor in another database" issue by selecting the data into a tableset in memory using the WITH syntax. I just haven't gotten around to trying that yet. The bigger picture is that I have built up these stored procedures and they are contained inside of a template database. I copy the template to an order database, then execute the SPs from there. I am trying to move all of those SPs in the template / order db out to a master database that holds all of my SPs. Mostly I have succeeded, but I have a handful of obstinate issues where that SPECIFIC sp has to remain in the template / order database for one reason or another, always revolving around having to execute inside of the db being modified. I'm getting there though. For someone who is not a SQL Server DBA, I am doing all right. John W. Colby www.ColbyConsulting.com Mark Breen wrote: > Hello John, > > I can only answer half this query. From marklbreen at gmail.com Sun Apr 4 02:58:59 2010 From: marklbreen at gmail.com (Mark Breen) Date: Sun, 4 Apr 2010 08:58:59 +0100 Subject: [dba-SQLServer] Reference table in different db In-Reply-To: <4BB73187.4040802@colbyconsulting.com> References: <4BB4995A.50107@colbyconsulting.com> <4BB73187.4040802@colbyconsulting.com> Message-ID: Hello John, [I am probably the king of] Not probably John, you are the KING. after re-reading your original post,I am sorry for waffling on, I was, in fact, not answering your question at all. And as I see now, was telling you stuff that you could already write a book on. While bowing out gracefully, can I just add, - just in case - when you do somedatabase.sometable you need to write it with the scheme as well, so usually, that is either of the following somedatabase..sometable or somedatabase.dbo.sometable of course if you use another schema, you would have to specify that. Can I also mention that you can also link servers, and when you do, then you can write queries such as select * from customers C inner join ServerBig.somedatabase.dbo.someorderstable O on C.Id = O.CustomerId or of course you could do a Insert into ServerBig.somedatabase.dbo.someorderstable ........... Hope to help, sorry for the irrelevant other stuff. And, happy Easter Sunday. Mark On 3 April 2010 13:16, jwcolby wrote: > Mark, > > I am probably the king of dynamic SQL. I have dozens of stored procedures > where I dynamically build > SQL to do everything from build tables with varying field names to > populating said table, to > building indexes, to BCP in / out. > > In fact it is one of those applications where I am hitting the wall. My > client asks for a set of > records WHERE (some long list of field compares). That long list of field > compares changes from > order to order. So I build a table (on-the-fly) where there is a base part > (which never changes) > and a dynamic part (where the select fields change for each order). > > The way that I figured out to do this was to build a little table that will > hold the names of the > fields in my select query (the changing part). I grab the field list and > pop it into this little > table. I then open that field list and bring it into a cursor. Using the > cursor I compare each > field name with the list of fields in the base table (some will be the > same) and any field not in > the base table gets added to the table using a modify table. > > When I am done iterating the cursor, my base table now has each and every > field in the selection > query and is ready to accept the data coming from the selection query. > > I then have to do the same kind of process again to build up an INSERT INTO > query which takes the > data coming from the query and insert into the order table. > > So I use a cursor in these two specific places. The cursors are small (1 > to 10 field names) and are > used to build dynamic SQL to build a custom table and then insert data into > that custom table. > > I THINK I can get around the whole "cursor in another database" issue by > selecting the data into a > tableset in memory using the WITH syntax. I just haven't gotten around to > trying that yet. > > The bigger picture is that I have built up these stored procedures and they > are contained inside of > a template database. I copy the template to an order database, then > execute the SPs from there. I > am trying to move all of those SPs in the template / order db out to a > master database that holds > all of my SPs. Mostly I have succeeded, but I have a handful of obstinate > issues where that > SPECIFIC sp has to remain in the template / order database for one reason > or another, always > revolving around having to execute inside of the db being modified. > > I'm getting there though. For someone who is not a SQL Server DBA, I am > doing all right. > > John W. Colby > www.ColbyConsulting.com > > > Mark Breen wrote: > > Hello John, > > > > I can only answer half this query. > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Thu Apr 8 06:51:07 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 08 Apr 2010 07:51:07 -0400 Subject: [dba-SQLServer] This just in Message-ID: <4BBDC32B.9000109@colbyconsulting.com> One SQL Server system on SSD http://www.sqlservercentral.com/articles/SSD+Disks/69693/ -- John W. Colby www.ColbyConsulting.com From jwcolby at colbyconsulting.com Thu Apr 8 10:29:28 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 08 Apr 2010 11:29:28 -0400 Subject: [dba-SQLServer] MySQL questions Message-ID: <4BBDF658.9000708@colbyconsulting.com> I am trying to get MySQL installed and working and a C# project talking to it. I am moving my billing database to C# as a class project and also because it is VERY long in the tooth and time for an upgrade. Because it is a class project I am trying to get it to play with MySQL because I can carry a small server around on my flash drive and work on it at school as well as anywhere else I have Visual Studio installed. So, I get a copy of XAMPLite which other people in the class are using. It fires up and runs from the thumb drive but... On my dev laptop when I run it and then try to go to localhost, I get Microsoft's IIS default web page, not the XAMPLite server control page like I am supposed to. Obviously XAMPLite expects that its server will be the only one running. So how do I deal with this? Does anyone know how to get the apache server instance that XAMPLite loads to point to something other than localhost? TIA, -- John W. Colby www.ColbyConsulting.com From ha at phulse.com Thu Apr 8 11:07:03 2010 From: ha at phulse.com (Hans-Christian Andersen) Date: Thu, 8 Apr 2010 17:07:03 +0100 Subject: [dba-SQLServer] MySQL questions In-Reply-To: <4BBDF658.9000708@colbyconsulting.com> References: <4BBDF658.9000708@colbyconsulting.com> Message-ID: Sorry if I have misunderstood anything, but would one solution be to change which port to serve apache on? You could change it to '8080' for example. I don't use xampp on Windows, but the directory layout should be similar to Linux/OS X. If you look in c:\[path-to-xampp]/etc/httpd.conf, change the port number on the line that says "Listen 80" and restart. You might need to do the same on your virtual hosts, if that is a concern to you. Changing "NameVirtualHost *:80" and "" to whatever port you decided to use. Either that, or you could turn off IIS. Hans-Christian Software Developer, UK ----------------------------------------------------------------- tel: +44 (0)782 894 5456 e-mail: hans.andersen at phulse.com www: nokenode.com ----------------------------------------------------------------- Unique Gifts, Collectables, Artwork ----------------------------------------------------------------- Come one Come all to www.corinnajasmine.com ----------------------------------------------------------------- On 8 April 2010 16:29, jwcolby wrote: > I am trying to get MySQL installed and working and a C# project talking to > it. I am moving my > billing database to C# as a class project and also because it is VERY long > in the tooth and time for > an upgrade. Because it is a class project I am trying to get it to play > with MySQL because I can > carry a small server around on my flash drive and work on it at school as > well as anywhere else I > have Visual Studio installed. > > So, I get a copy of XAMPLite which other people in the class are using. It > fires up and runs from > the thumb drive but... > > On my dev laptop when I run it and then try to go to localhost, I get > Microsoft's IIS default web > page, not the XAMPLite server control page like I am supposed to. > Obviously XAMPLite expects that > its server will be the only one running. > > So how do I deal with this? Does anyone know how to get the apache server > instance that XAMPLite > loads to point to something other than localhost? > > TIA, > > -- > John W. Colby > www.ColbyConsulting.com > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Thu Apr 8 15:44:13 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 08 Apr 2010 16:44:13 -0400 Subject: [dba-SQLServer] C# Date conversion going in to a stored procedure Message-ID: <4BBE401D.3050308@colbyconsulting.com> I have an issue where I am sending in a date from C# to a stored procedure in SQL Server. I am looking at the data on the C# side, clear down into the parameter object.value and the data is a string which looks like: "12/22/2010 14:23:01". When it gets into the Varchar(100) on the SQL Server side (in the stored procedure) the seconds have been stripped off. I NEED the seconds. It appears that SQL Server is "helpfully" noticing that the string is a date and doing a conversion for me, stripping the seconds in the process. I have passed the date in as a string, as an actual date and so forth and in all cases, SQL Server strips off the seconds. What do I need to do to cause SQL Server to stop "being helpful" and leave my seconds alone? -- John W. Colby www.ColbyConsulting.com From accessd at shaw.ca Fri Apr 9 05:01:31 2010 From: accessd at shaw.ca (Jim Lawrence) Date: Fri, 9 Apr 2010 03:01:31 -0700 Subject: [dba-SQLServer] C# Date conversion going in to a stored procedure In-Reply-To: <4BBE401D.3050308@colbyconsulting.com> References: <4BBE401D.3050308@colbyconsulting.com> Message-ID: <3719A46524154351ADB8BBC165EE2B79@creativesystemdesigns.com> Are you passing the parameter as a sring or a date? I never use dates for obvious reasons. Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby Sent: Thursday, April 08, 2010 1:44 PM To: Access Developers discussion and problem solving; Sqlserver-Dba; VBA Subject: [dba-SQLServer] C# Date conversion going in to a stored procedure I have an issue where I am sending in a date from C# to a stored procedure in SQL Server. I am looking at the data on the C# side, clear down into the parameter object.value and the data is a string which looks like: "12/22/2010 14:23:01". When it gets into the Varchar(100) on the SQL Server side (in the stored procedure) the seconds have been stripped off. I NEED the seconds. It appears that SQL Server is "helpfully" noticing that the string is a date and doing a conversion for me, stripping the seconds in the process. I have passed the date in as a string, as an actual date and so forth and in all cases, SQL Server strips off the seconds. What do I need to do to cause SQL Server to stop "being helpful" and leave my seconds alone? -- John W. Colby www.ColbyConsulting.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From jwcolby at colbyconsulting.com Fri Apr 9 07:29:30 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Fri, 09 Apr 2010 08:29:30 -0400 Subject: [dba-SQLServer] SPAM-LOW: Re: [dba-VB] C# Date conversion going in to a stored procedure In-Reply-To: References: Message-ID: <4BBF1DAA.80806@colbyconsulting.com> I have sent it in as a string (varchar(100), and I have sent it in as a date time. Basically in order to check on the format, I immediately send it right back out as an output parameter coming back from the SP. AFAICT it is converted somewhere in the interface between C# and SQL Server. It is a date in the format MMM DD YYYY hh mm AM/PM as soon as I examine it inside of SQl Server (in the stored procedure). The seconds are gone! Nothing that I have tried inside of the stored procedure allows me to see the seconds, or rather I can format it to display seconds but they are always 00. The second information is lost in the trip over to the stored procedure. This is the C# side where I set up the parameters: sCmdLog.Parameters.Add(new SqlParameter("@DteTimeStart", SqlDbType.DateTime)); sCmdLog.Parameters["@DteTimeStart"].Value = pSPStart;//.ToString("MM/dd/yyyy HH:mm:ss"); sCmdLog.Parameters.Add(new SqlParameter("@DteTimeEnd", SqlDbType.DateTime)); sCmdLog.Parameters["@DteTimeEnd"].Value = pSPEnd;//.ToString("MM/dd/yyyy HH:mm:ss"); This is the SP side: ALTER PROCEDURE [dbo].[_sp_LogProcess] -- Add the parameters for the stored procedure here @DBName varchar(50), @TblName varchar(50), @SPName varchar(50), @Process varchar(50), @Memo varchar(4000), @ErrIntOut int, @ErrStrOut varchar(4000), @RecsAffected int, @DteTimeStart datetime, @DteTimeEnd datetime, @ErrorDesc varchar(4000) output, @ErrorNo int output, @SQLStatement varchar(4000) output The @DteTimeStart and @DteTimeEnd are the variables of interest. The following is what I am using to generate the SQL statement that appends a record into the log table: SELECT @SQL = 'INSERT INTO [_aDataMaster].[dbo].[tblProcessLog] ([PL_DBName] ,[PL_TblName] ,[PL_StoredProcName] ,[PL_Process] ,[PL_Memo] ,[PL_ErrInt] ,[PL_ErrStr] ,[PL_DteProc] ,[PL_RecsAffected] ,[PL_DteTimeStart] ,[PL_DteTimeEnd]) SELECT ''' + @DBName + ''' as PL_DBName, ''' + @TblName + ''' as PL_TblName, ''' + @SPName + ''' AS PL_StoredProcName, ''' + @Process + ''' as PL_Process, ''' + @Memo + ''' as PL_Memo, ' + cast(@ErrIntOut as varchar) + ' as PL_ErrInt, ''' + @ErrStrOut + ''' as PL_ErrStr, ''' + cast(getdate() as varchar) + ''' as PL_DteProc, ''' + CAST(@RecsAffected as varchar) + ''' AS PL_RecsAddected, ''' + cast(@DteTimeStart as varchar) + ''' AS PL_DteTimeStart, ''' + cast(@DteTimeEnd as varchar) + ''' AS PL_DteTimeEnd' The following is the record stored by the process: PL_ID PL_DBName PL_TblName PL_Process PL_Memo PL_ErrInt PL_ErrStr PL_DteProc PL_MS2Process PL_RecsAffected PL_StoredProcName PL_DteTimeStart PL_DteTimeEnd 553 PSM11211_test No TblName specified Accuzip Export 0 Success 2010-04-08 17:24:00.000 NULL 0 _aDataMaster.dbo.sp_AZOut_BCPOutOneFile 2010-04-08 17:24:00.000 2010-04-08 17:24:00.000 I have tried every combination I could think of and it is just stripping the seconds each and every time. I have passed in pure varchar at both ends. I have passed in DateTime at both ends. I have looked at the data in the param.value back in C# and it shows the seconds portion. I look in the SP IMMEDIATELY below the function declaration line and the seconds are gone! I am baffled. I NEED the seconds part. I am trying to time how long my other SPs takes to execute, and the start / end times are what is being passed in to this SP to be logged in the table. The whole logging process is ALMOST useless if I cannot capture the timing data. John W. Colby www.ColbyConsulting.com Gustav Brock wrote: > Hi John > > Why not declare the parameter as Date? That will accept values with seconds and milliseconds. > > /gustav > >>>> jwcolby at colbyconsulting.com 08-04-2010 22:44 >>> > I have an issue where I am sending in a date from C# to a stored procedure in SQL Server. I am > looking at the data on the C# side, clear down into the parameter object.value and the data is a > string which looks like: "12/22/2010 14:23:01". When it gets into the Varchar(100) on the SQL > Server side (in the stored procedure) the seconds have been stripped off. I NEED the seconds. It > appears that SQL Server is "helpfully" noticing that the string is a date and doing a conversion for > me, stripping the seconds in the process. > > I have passed the date in as a string, as an actual date and so forth and in all cases, SQL Server > strips off the seconds. > > What do I need to do to cause SQL Server to stop "being helpful" and leave my seconds alone? > From stuart at lexacorp.com.pg Fri Apr 9 08:09:33 2010 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Fri, 09 Apr 2010 23:09:33 +1000 Subject: [dba-SQLServer] [AccessD] SPAM-LOW: Re: [dba-VB] C# Date conversion going in to a stored procedure In-Reply-To: <4BBF1DAA.80806@colbyconsulting.com> References: , <4BBF1DAA.80806@colbyconsulting.com> Message-ID: <4BBF270D.24554.75EE9A9@stuart.lexacorp.com.pg> Are PL_DteTimeStart PL_DteTimeEnd set up as DateTime or SmallDateTime fields. If the latter, they can only store times to the nearest minute. -- Stuart On 9 Apr 2010 at 8:29, jwcolby wrote: > I have sent it in as a string (varchar(100), and I have sent it in as a date time. Basically in > order to check on the format, I immediately send it right back out as an output parameter coming > back from the SP. AFAICT it is converted somewhere in the interface between C# and SQL Server. It > is a date in the format MMM DD YYYY hh mm AM/PM as soon as I examine it inside of SQl Server (in the > stored procedure). > > The seconds are gone! Nothing that I have tried inside of the stored procedure allows me to see the > seconds, or rather I can format it to display seconds but they are always 00. The second > information is lost in the trip over to the stored procedure. > > This is the C# side where I set up the parameters: > > sCmdLog.Parameters.Add(new SqlParameter("@DteTimeStart", SqlDbType.DateTime)); > sCmdLog.Parameters["@DteTimeStart"].Value = pSPStart;//.ToString("MM/dd/yyyy HH:mm:ss"); > > sCmdLog.Parameters.Add(new SqlParameter("@DteTimeEnd", SqlDbType.DateTime)); > sCmdLog.Parameters["@DteTimeEnd"].Value = pSPEnd;//.ToString("MM/dd/yyyy HH:mm:ss"); > > > This is the SP side: > > ALTER PROCEDURE [dbo].[_sp_LogProcess] > -- Add the parameters for the stored procedure here > @DBName varchar(50), @TblName varchar(50), > @SPName varchar(50), > @Process varchar(50), @Memo varchar(4000), > @ErrIntOut int, @ErrStrOut varchar(4000), > @RecsAffected int, > @DteTimeStart datetime, > @DteTimeEnd datetime, > @ErrorDesc varchar(4000) output, > @ErrorNo int output, > @SQLStatement varchar(4000) output > > The @DteTimeStart and @DteTimeEnd are the variables of interest. > > The following is what I am using to generate the SQL statement that appends a record into the log table: > > SELECT @SQL = 'INSERT INTO [_aDataMaster].[dbo].[tblProcessLog] > ([PL_DBName] > ,[PL_TblName] > ,[PL_StoredProcName] > ,[PL_Process] > ,[PL_Memo] > ,[PL_ErrInt] > ,[PL_ErrStr] > ,[PL_DteProc] > ,[PL_RecsAffected] > ,[PL_DteTimeStart] > ,[PL_DteTimeEnd]) > SELECT ''' > + @DBName + ''' as PL_DBName, ''' > + @TblName + ''' as PL_TblName, ''' > + @SPName + ''' AS PL_StoredProcName, ''' > + @Process + ''' as PL_Process, ''' > + @Memo + ''' as PL_Memo, ' > + cast(@ErrIntOut as varchar) + ' as PL_ErrInt, ''' > + @ErrStrOut + ''' as PL_ErrStr, ''' > + cast(getdate() as varchar) + ''' as PL_DteProc, ''' > + CAST(@RecsAffected as varchar) + ''' AS PL_RecsAddected, ''' > + cast(@DteTimeStart as varchar) + ''' AS PL_DteTimeStart, ''' > + cast(@DteTimeEnd as varchar) + ''' AS PL_DteTimeEnd' > > > > The following is the record stored by the process: > > > PL_ID PL_DBName PL_TblName PL_Process PL_Memo PL_ErrInt PL_ErrStr PL_DteProc PL_MS2Process > PL_RecsAffected PL_StoredProcName PL_DteTimeStart PL_DteTimeEnd > 553 PSM11211_test No TblName specified Accuzip Export 0 Success 2010-04-08 17:24:00.000 NULL 0 > _aDataMaster.dbo.sp_AZOut_BCPOutOneFile 2010-04-08 17:24:00.000 2010-04-08 17:24:00.000 > > I have tried every combination I could think of and it is just stripping the seconds each and every > time. I have passed in pure varchar at both ends. I have passed in DateTime at both ends. I have > looked at the data in the param.value back in C# and it shows the seconds portion. I look in the SP > IMMEDIATELY below the function declaration line and the seconds are gone! > > I am baffled. > > I NEED the seconds part. I am trying to time how long my other SPs takes to execute, and the start > / end times are what is being passed in to this SP to be logged in the table. The whole logging > process is ALMOST useless if I cannot capture the timing data. > > John W. Colby > www.ColbyConsulting.com > > > Gustav Brock wrote: > > Hi John > > > > Why not declare the parameter as Date? That will accept values with seconds and milliseconds. > > > > /gustav > > > >>>> jwcolby at colbyconsulting.com 08-04-2010 22:44 >>> > > I have an issue where I am sending in a date from C# to a stored procedure in SQL Server. I am > > looking at the data on the C# side, clear down into the parameter object.value and the data is a > > string which looks like: "12/22/2010 14:23:01". When it gets into the Varchar(100) on the SQL > > Server side (in the stored procedure) the seconds have been stripped off. I NEED the seconds. It > > appears that SQL Server is "helpfully" noticing that the string is a date and doing a conversion for > > me, stripping the seconds in the process. > > > > I have passed the date in as a string, as an actual date and so forth and in all cases, SQL Server > > strips off the seconds. > > > > What do I need to do to cause SQL Server to stop "being helpful" and leave my seconds alone? > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com From jwcolby at colbyconsulting.com Fri Apr 9 09:07:43 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Fri, 09 Apr 2010 10:07:43 -0400 Subject: [dba-SQLServer] [AccessD] SPAM-LOW: Re: [dba-VB] C# Date conversion going in to a stored procedure In-Reply-To: <4BBF270D.24554.75EE9A9@stuart.lexacorp.com.pg> References: , <4BBF1DAA.80806@colbyconsulting.com> <4BBF270D.24554.75EE9A9@stuart.lexacorp.com.pg> Message-ID: <4BBF34AF.90701@colbyconsulting.com> They are set up as datetime. I actually tried to use DateTime2 as well. All of which got me nowhere. 8( John W. Colby www.ColbyConsulting.com Stuart McLachlan wrote: > Are PL_DteTimeStart PL_DteTimeEnd set up as DateTime or SmallDateTime fields. If the > latter, they can only store times to the nearest minute. > From jwcolby at colbyconsulting.com Sat Apr 10 11:42:47 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 10 Apr 2010 12:42:47 -0400 Subject: [dba-SQLServer] c# - Report server databases Message-ID: <4BC0AA87.2000006@colbyconsulting.com> I am using SMO to get lists of databases, tables in databases etc. I never operate on the system databases so I filter out the system databases using the Database.IsSystemObject property. That brought into focus the ReportServer and ReportServerTempDB databases, which oddly are not inside of the system folder and apparently are not system objects. Other than filtering them out by their name, is there a way to know that they are not user defined databases? -- John W. Colby www.ColbyConsulting.com From jwcolby at colbyconsulting.com Mon Apr 12 11:28:29 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Mon, 12 Apr 2010 12:28:29 -0400 Subject: [dba-SQLServer] Any easy way to do this? Message-ID: <4BC34A2D.5010103@colbyconsulting.com> My client is constantly asking for "table counts" by which I mean filling in a table that looks kind of like a crosstab (but isn't) but for 4 or 5 vertical fields for 4 or 5 horizontal fields. FieldK FieldL FieldX FieldZ FieldA Cnt? Cnt? ? ? FieldB etc etc FieldC FieldD This isn't even a groupby since we are not talking values inside of FieldA, but rather a total count WHERE Field In ('X','Y','Z') and Field K is not null (or something similar). This is just killing me in terms of time to complete this as the only way I am thinking of is to create 16 count queries. Is there a better way? -- John W. Colby www.ColbyConsulting.com From fhtapia at gmail.com Mon Apr 12 16:02:30 2010 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 12 Apr 2010 14:02:30 -0700 Subject: [dba-SQLServer] [AccessD] Any easy way to do this? In-Reply-To: <6D37A7061C3A4F9A857351602847DB26@Server> References: <4BC34A2D.5010103@colbyconsulting.com> <6D37A7061C3A4F9A857351602847DB26@Server> Message-ID: Use the pivot command http://www.databasejournal.com/features/mssql/article.php/3521101/Cross-Tab-reports-in-SQL-Server-2005.htm -Francisco http://sqlthis.blogspot.com | Tsql and More... On Mon, Apr 12, 2010 at 1:49 PM, Max Wanadoo wrote: > Good idea. > > Or, ask the client to write down in plain english what he wants. When he > finds he cannot express what he wants then you say, if you cannot tell me > what you want how can I code it. > > If he can express it in plain english then it is easy to code. I am not > saying effective but possible. If you come across "doubts" refer it back > to > him to re-express what he wants. > > Amazing how many people cannot even write down what they want but they > "expect" the analyist/coder to "read my mind". > > Max > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust > Sent: Monday, April 12, 2010 9:39 PM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] Any easy way to do this? > > John, > > > Is there a better way? > > Shoot the client!! > > I've done stuff somewhat similar to this before using classes ... I think! > I don't really understand what the client wants here. Horizontal fields? > Vertical fields? Huh?? > > Charlotte Foust > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby > Sent: Monday, April 12, 2010 9:28 AM > To: Access Developers discussion and problem solving; Sqlserver-Dba > Subject: [AccessD] Any easy way to do this? > > > My client is constantly asking for "table counts" by which I mean filling > in > a table that looks kind of like a crosstab (but isn't) but for 4 or 5 > vertical fields for 4 or 5 horizontal fields. > > FieldK FieldL FieldX FieldZ > FieldA Cnt? Cnt? ? ? > FieldB etc etc > FieldC > FieldD > > This isn't even a groupby since we are not talking values inside of FieldA, > but rather a total count WHERE Field In ('X','Y','Z') and Field K is not > null (or something similar). > > This is just killing me in terms of time to complete this as the only way I > am thinking of is to create 16 count queries. > > Is there a better way? > > -- > John W. Colby > www.ColbyConsulting.com > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > From dwaters at usinternet.com Tue Apr 13 10:04:06 2010 From: dwaters at usinternet.com (Dan Waters) Date: Tue, 13 Apr 2010 10:04:06 -0500 Subject: [dba-SQLServer] MS 2010 Launch Events Message-ID: <676881D432A6461D860EFCB774A1BA4E@danwaters> MS has released its schedule of launch events in cities throughout the US over the next two months. I go because they hand out free software. I'm expecting to get a copy of VS 2010, Access 2010, Sharepoint 2010, and SQL Server 2008 R2. They don't say that this is what you'll get, but those are the products they are advertising in the launch event. These events fill up, so sign up soon! Click this link and follow the track you want. When you get to the page to request a seat, it will say that you need an invitation code - but then they don't ask for a code. I requested a seat and am now confirmed without that invitation code. Perhaps they figure that if you're looking for this anyway then they want you there. http://www.microsoft.com/business/2010events/ Have Fun! Dan PS - they are also having launch events in major cities elsewhere in the world, but you'll need to find that information somewhere. From dbdoug at gmail.com Tue Apr 13 10:55:52 2010 From: dbdoug at gmail.com (Doug Steele) Date: Tue, 13 Apr 2010 08:55:52 -0700 Subject: [dba-SQLServer] MS 2010 Launch Events In-Reply-To: <676881D432A6461D860EFCB774A1BA4E@danwaters> References: <676881D432A6461D860EFCB774A1BA4E@danwaters> Message-ID: Interesting - the last couple of MS events I went to in Vancouver, Canada, were notable for the lack of freebies (coffee and muffins excepted). At one (paid) event, the only item given out was a SINGLE copy of the web development tools, raffled off by ticket number. Looking at the pricing of VS2010 I am also surprised at how expensive it seems to be. To upgrade VS2008 Pro, for which I believe I paid about $150, now appears to cost $550 including a compulsory 'MSDN Essentials' subscription. Yikes! In contrast, the MS Technet subscription (about $250/year) is a real bargain as it gives me all MS Office, SQL Server, and Windows versions. Doug Steele On Tue, Apr 13, 2010 at 8:04 AM, Dan Waters wrote: > MS has released its schedule of launch events in cities throughout the US > over the next two months. I go because they hand out free software. I'm > expecting to get a copy of VS 2010, Access 2010, Sharepoint 2010, and SQL > Server 2008 R2. They don't say that this is what you'll get, but those are > the products they are advertising in the launch event. These events fill > up, so sign up soon! > > Click this link and follow the track you want. When you get to the page to > request a seat, it will say that you need an invitation code - but then > they > don't ask for a code. I requested a seat and am now confirmed without that > invitation code. Perhaps they figure that if you're looking for this > anyway > then they want you there. > > http://www.microsoft.com/business/2010events/ > > Have Fun! > Dan > > PS - they are also having launch events in major cities elsewhere in the > world, but you'll need to find that information somewhere. > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Wed Apr 14 11:09:51 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 14 Apr 2010 12:09:51 -0400 Subject: [dba-SQLServer] BCP out via cmdshell Message-ID: <4BC5E8CF.4010607@colbyconsulting.com> Can BCP queryout return a "records affected" kind of count to exec master..xp_cmdshell @sql so that I can pass that count out of the stored procedure back up to my C# program? This is one of the very few stored procedures that use XP_CmdShell and so far I do not know how to get results back from XP_CmdShell. -- John W. Colby www.ColbyConsulting.com From jwcolby at colbyconsulting.com Thu Apr 15 09:06:33 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 15 Apr 2010 10:06:33 -0400 Subject: [dba-SQLServer] Visual Studio 2010 Message-ID: <4BC71D69.9020708@colbyconsulting.com> Is VS 2010 ready for prime time? As a student I can get a free copy (it is downloading now) but I always hesitate to embrace rev 1 software of any kind. Are you guys using it yet? I am using 2008 in production right now and really love it. -- John W. Colby www.ColbyConsulting.com From Elizabeth.J.Doering at wellsfargo.com Mon Apr 19 14:12:37 2010 From: Elizabeth.J.Doering at wellsfargo.com (Elizabeth.J.Doering at wellsfargo.com) Date: Mon, 19 Apr 2010 14:12:37 -0500 Subject: [dba-SQLServer] Performance Monitoring Message-ID: <4838EC790FF778449985FC3B8A47F871507BA266D6@MSGCMSV21011.ent.wfb.bank.corp> Does anyone have any great suggestions for favorite performance monitoring tools? Do you roll your own or is there something off the shelf you like? Thanks, Liz This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. From fhtapia at gmail.com Mon Apr 19 15:14:25 2010 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 19 Apr 2010 13:14:25 -0700 Subject: [dba-SQLServer] Performance Monitoring In-Reply-To: <4838EC790FF778449985FC3B8A47F871507BA266D6@MSGCMSV21011.ent.wfb.bank.corp> References: <4838EC790FF778449985FC3B8A47F871507BA266D6@MSGCMSV21011.ent.wfb.bank.corp> Message-ID: I am currently using RedGate's Sql Response it's inexpensive and provides me with the health monitoring tools I need. I used to use Idera's Sql Diagnostic Manager, but it's big slow and costs waaaay too much $$ I've liked sql response as you can configure it to also trace servers that are problematic and you can trace down to problem areas. I recently tried out Ignite's performance intelligence, it's very price, but come in handy if you have a server that is behaving really slow and you haven't been able to determine what the problem was using just a trace (it's nothing special, but it clearly navigates you to problem hardware or software issues) ie, in my situation I had one server that appears to have a low load and I thought I could just add another database, but after using ignite i found that the problem was with my subsystem i/o. Since the server was out of warranty our helpdesk ordered up a new server with many more spindles and of course more ram and cpu and now I house many more databases on this system. so it was kinda cool that I found the information by drilling down. but the reason we haven't bought it is because its very very pricey just like idera where they want over $2k per instance... -Francisco http://sqlthis.blogspot.com | Tsql and More... On Mon, Apr 19, 2010 at 12:12 PM, wrote: > Does anyone have any great suggestions for favorite performance monitoring > tools? Do you roll your own or is there something off the shelf you like? > > > > Thanks, > > Liz > > This message may contain confidential and/or privileged information. If you > are not the addressee or authorized to receive this for the addressee, you > must not use, copy, disclose, or take any action based on this message or > any information herein. If you have received this message in error, please > advise the sender immediately by reply e-mail and delete this message. Thank > you for your cooperation. > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Sat Apr 24 18:32:56 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 24 Apr 2010 19:32:56 -0400 Subject: [dba-SQLServer] Hyper-V vs VMWare Message-ID: <4BD37FA8.8040708@colbyconsulting.com> Is anyone using Hyper-V? Comments, performance, comparisons? -- John W. Colby www.ColbyConsulting.com From jwcolby at colbyconsulting.com Sat Apr 24 21:21:06 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sat, 24 Apr 2010 22:21:06 -0400 Subject: [dba-SQLServer] For the rest of us Message-ID: <4BD3A712.4080006@colbyconsulting.com> http://www.coolcomputing.com/article.php?sid=3861 http://www.newegg.com/Product/Product.aspx?Item=N82E16813131643 http://www.newegg.com/Product/Product.aspx?Item=N82E16819105267 24 cores for $2K plus memory. This might make my SQL Server a tad faster eh? Not that I have $2K laying around. Throw in 64 gigs of ram for around $3K and a Raid 0 Array of SSds to house my read-only databases (another $2K or so) and for the neighborhood of $8K I could get some serious computing done. Not that I have 8K laying around. This is some pretty serious hardware though, and not costing 50K either. -- John W. Colby www.ColbyConsulting.com From marklbreen at gmail.com Sun Apr 25 06:07:39 2010 From: marklbreen at gmail.com (Mark Breen) Date: Sun, 25 Apr 2010 12:07:39 +0100 Subject: [dba-SQLServer] Hyper-V vs VMWare In-Reply-To: <4BD37FA8.8040708@colbyconsulting.com> References: <4BD37FA8.8040708@colbyconsulting.com> Message-ID: Hello john, Using HyperV for a year now and not a single complaint, I have to say that trying to run Win7 and run VS2008 does not get a bare metal experience, but it is absolutely for running servers, and I even use it running Win7 and with PhotoShop. Never managed to get VM ware installed or running, but they only say good things about it HTH Mark On 25 April 2010 00:32, jwcolby wrote: > Is anyone using Hyper-V? Comments, performance, comparisons? > > -- > John W. Colby > www.ColbyConsulting.com > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Sun Apr 25 21:59:31 2010 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sun, 25 Apr 2010 22:59:31 -0400 Subject: [dba-SQLServer] Who needs a Cray Message-ID: <4BD50193.9090603@colbyconsulting.com> 48 cores, 128 gigs ram... http://cgi.ebay.com/NEW-TYAN-AMD-OPTERON-6174-G34-48-CORE-MAGNY-COURS-/270529337772 -- John W. Colby www.ColbyConsulting.com From dwaters at usinternet.com Mon Apr 26 08:17:19 2010 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 26 Apr 2010 08:17:19 -0500 Subject: [dba-SQLServer] Senior Database Administrator Position Open Near Minneapolis Message-ID: <28F74763E7564A60A68CB84EFA40C216@danwaters> I ran across this position opening today. This is for Donaldson Company in Bloomington, MN. They are a 10,000 person company, with approximately 1000 people in Bloomington at the company's headquarters. The position description is quite long - looks like it's focused mostly on Oracle, but SQL Server experience is desirable. http://www.donaldson.com/en/about/employment/index.html Good Luck! Dan