From serbach at new.rr.com Tue Jan 4 06:48:48 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Tue, 4 Jan 2005 06:48:48 -0600 Subject: [dba-SQLServer] Integrated security Message-ID: <20050104064848.855805810.serbach@new.rr.com> Dear Group, Hasn't been much traffic here since 26-Dec it looks like. Here's a poser, though it may not amount to much. I've been working on a .NET project for some time (MUCH longer than anticipated) that uses a SQL Server 2000 back-end. The web host, CrystalTech, only offers two server logins in their "rental" agreement for their SQL Server capability. I wasn't aware of that at the outset; but I've reconciled myself to it. I use SQL Server authentication using my main login and password in the ADO connection string, and a user and password table to authorize further entry into the database I've set up. In ASP.NET the connection string is unavailable to the casual user. It's stored in the Web.config XML file and is not downloadable nor can it be accessed with a browser. However, from my reading on ASP.NET application security, it appears that a sophisticated user/hacker can read the connection string using a memory dump, as I understand it. In version 2.0 of the Microsoft .NET Framework there's supposed to be a new class, System.Security, that will allow me to encrypt the connection string; but right now that string is somewhere in the managed memory heap and doesn't really get erased from there. My question relates to integrated security. Forgive my naivet? on this, but am I correct in assuming that for integrated security to work with SQL Server, I have to log in from MY workstation using MY Windows login, is that right? In other words, integrated security is workstation-based, not username and password based, right? If that's the case, then I've only got two logins of that type with the CrystalTech SQL Server...and I may not even have that. So my only option is to use the SQL Server authentication I've already set up with the lookup of user names and passwords in a table in the databse. Thanks for your thoughts. Regards, Steve Erbach Scientific Marketing Neenah, WI From mikedorism at adelphia.net Tue Jan 4 07:15:43 2005 From: mikedorism at adelphia.net (Mike & Doris Manning) Date: Tue, 4 Jan 2005 08:15:43 -0500 Subject: [dba-SQLServer] Integrated security In-Reply-To: <20050104064848.855805810.serbach@new.rr.com> Message-ID: <000001c4f25f$81d60bc0$0b08a845@hargrove.internal> You are correct. Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Steven W. Erbach Sent: Tuesday, January 04, 2005 7:49 AM To: 'dba-sqlserver at databaseadvisors.com' Subject: [dba-SQLServer] Integrated security Dear Group, Hasn't been much traffic here since 26-Dec it looks like. Here's a poser, though it may not amount to much. I've been working on a .NET project for some time (MUCH longer than anticipated) that uses a SQL Server 2000 back-end. The web host, CrystalTech, only offers two server logins in their "rental" agreement for their SQL Server capability. I wasn't aware of that at the outset; but I've reconciled myself to it. I use SQL Server authentication using my main login and password in the ADO connection string, and a user and password table to authorize further entry into the database I've set up. In ASP.NET the connection string is unavailable to the casual user. It's stored in the Web.config XML file and is not downloadable nor can it be accessed with a browser. However, from my reading on ASP.NET application security, it appears that a sophisticated user/hacker can read the connection string using a memory dump, as I understand it. In version 2.0 of the Microsoft .NET Framework there's supposed to be a new class, System.Security, that will allow me to encrypt the connection string; but right now that string is somewhere in the managed memory heap and doesn't really get erased from there. My question relates to integrated security. Forgive my naivet? on this, but am I correct in assuming that for integrated security to work with SQL Server, I have to log in from MY workstation using MY Windows login, is that right? In other words, integrated security is workstation-based, not username and password based, right? If that's the case, then I've only got two logins of that type with the CrystalTech SQL Server...and I may not even have that. So my only option is to use the SQL Server authentication I've already set up with the lookup of user names and passwords in a table in the databse. Thanks for your thoughts. Regards, Steve Erbach Scientific Marketing Neenah, WI _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From serbach at new.rr.com Tue Jan 4 09:32:47 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Tue, 4 Jan 2005 09:32:47 -0600 Subject: [dba-SQLServer] Integrated security In-Reply-To: <000001c4f25f$81d60bc0$0b08a845@hargrove.internal> References: <20050104064848.855805810.serbach@new.rr.com> <000001c4f25f$81d60bc0$0b08a845@hargrove.internal> Message-ID: <20050104093247.817412081.serbach@new.rr.com> Doris, Well, that was easy! Perhaps the .NET 2.0 will come out soon and I can take advantage of connection string encryption then. Thanks very much. Steve Erbach Neenah, WI > ------------Original Message------------ > From: Mike & Doris Manning > To: dba-sqlserver at databaseadvisors.com > Date: Tue, Jan-4-2005 7:17 AM > Subject: RE: [dba-SQLServer] Integrated security > > You are correct. > > Doris Manning > Database Administrator > Hargrove Inc. > www.hargroveinc.com From mikedorism at adelphia.net Tue Jan 4 10:01:49 2005 From: mikedorism at adelphia.net (Mike & Doris Manning) Date: Tue, 4 Jan 2005 11:01:49 -0500 Subject: [dba-SQLServer] Integrated security In-Reply-To: <20050104093247.817412081.serbach@new.rr.com> Message-ID: <000101c4f276$b51791e0$0b08a845@hargrove.internal> >From what I understand, I is due out around Summer 2005. I'm waiting not so patiently for it my self. Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Steven W. Erbach Sent: Tuesday, January 04, 2005 10:33 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Integrated security Doris, Well, that was easy! Perhaps the .NET 2.0 will come out soon and I can take advantage of connection string encryption then. Thanks very much. Steve Erbach Neenah, WI > ------------Original Message------------ > From: Mike & Doris Manning > To: dba-sqlserver at databaseadvisors.com > Date: Tue, Jan-4-2005 7:17 AM > Subject: RE: [dba-SQLServer] Integrated security > > You are correct. > > Doris Manning > Database Administrator > Hargrove Inc. > www.hargroveinc.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From serbach at new.rr.com Thu Jan 6 04:38:56 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Thu, 6 Jan 2005 04:38:56 -0600 Subject: [dba-SQLServer] Convert from ntext to varchar Message-ID: <20050106043856.2106380249.serbach@new.rr.com> Dear Group, It seems that it might be a good idea to convert the ntext Comment columns I have in a number of tables to varchar, even though the maximum length is much less and there's no Unicode capability. The Comments in these tables aren't going to be book length. I'm having trouble, though converting from ntext to varchar. The existing columns are all ntext 16. I've tried using a stored procedure like this: CREATE PROCEDURE _spTmpConvertKeyStatsComment AS UPDATE tblKeyStats SET NewKeyStatsComment = CAST(KeyStatsComment AS varchar) GO In the tblKeyStats table I added a varchar 16 column named NewKeyStatsComments. As you can see I tried to use the CAST function. When I run this sproc in a SQL script, none of the data is copied into the NewKeyStatsComment column. I will say that some of the original KeyStatsComment values are NULL. Any thoughts? ? Regards, ? Steve Erbach Scientific Marketing Neenah, WI From CMackin at quiznos.com Thu Jan 6 08:59:53 2005 From: CMackin at quiznos.com (Mackin, Christopher) Date: Thu, 6 Jan 2005 07:59:53 -0700 Subject: [dba-SQLServer] Convert from ntext to varchar Message-ID: Try: CAST(KeyStatsComment AS varchar(16)) Not specifying a length for the VarChar field may be causing the problem. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Steven W. Erbach Sent: Thursday, January 06, 2005 3:39 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Convert from ntext to varchar Dear Group, It seems that it might be a good idea to convert the ntext Comment columns I have in a number of tables to varchar, even though the maximum length is much less and there's no Unicode capability. The Comments in these tables aren't going to be book length. I'm having trouble, though converting from ntext to varchar. The existing columns are all ntext 16. I've tried using a stored procedure like this: CREATE PROCEDURE _spTmpConvertKeyStatsComment AS UPDATE tblKeyStats SET NewKeyStatsComment = CAST(KeyStatsComment AS varchar) GO In the tblKeyStats table I added a varchar 16 column named NewKeyStatsComments. As you can see I tried to use the CAST function. When I run this sproc in a SQL script, none of the data is copied into the NewKeyStatsComment column. I will say that some of the original KeyStatsComment values are NULL. Any thoughts? ? Regards, ? Steve Erbach Scientific Marketing Neenah, WI _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From serbach at new.rr.com Thu Jan 6 12:52:56 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Thu, 6 Jan 2005 12:52:56 -0600 Subject: [dba-SQLServer] Convert from ntext to varchar In-Reply-To: References: Message-ID: <20050106125256.1072921112.serbach@new.rr.com> Chris, I was able to modify the SQL statement using your CAST suggestion. However when I executed the sproc, the NewKeyStatsComment field only had 16 characters of data in it. My understanding of the varchar data type is that it's variable in length, like the ntext type. My table definition has ntext(16) for the current KeyStatsComment column. Of course, the comments are longer than 16 characters and they show up just fine in the table. But I've defined the NewKeyStatsComment column as varchar(16). I suppose if I modified the NewKeyStatsComment to varchar(8000) then the entire comment would fit in the field. But doesn't SQL Server then bulk up the table by the 8000 characters per row? Or what? Steve Erbach Neenah, WI > ------------Original Message------------ > From: "Mackin, Christopher" > To: dba-sqlserver at databaseadvisors.com > Date: Thu, Jan-6-2005 9:00 AM > Subject: RE: [dba-SQLServer] Convert from ntext to varchar > > Try: > CAST(KeyStatsComment AS varchar(16)) > > Not specifying a length for the VarChar field may be causing the > problem. > > -Chris Mackin From CMackin at quiznos.com Thu Jan 6 13:22:51 2005 From: CMackin at quiznos.com (Mackin, Christopher) Date: Thu, 6 Jan 2005 12:22:51 -0700 Subject: [dba-SQLServer] Convert from ntext to varchar Message-ID: The real determining factor is the size of the field where it's being stored. I would run something like: SELECT Max(Len(CAST(KeyStatsComment AS VarChar(8000)))) FROM ...... That will give you the Max length of the existing data, then from there you should be able to determine how many characters you need in the field in the table. I think you may be confusing VarChar and Char, VarChar is variable length and stores only what it has, Char is fixed length and stores the full amount of characters. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Steven W. Erbach Sent: Thursday, January 06, 2005 11:53 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Convert from ntext to varchar Chris, I was able to modify the SQL statement using your CAST suggestion. However when I executed the sproc, the NewKeyStatsComment field only had 16 characters of data in it. My understanding of the varchar data type is that it's variable in length, like the ntext type. My table definition has ntext(16) for the current KeyStatsComment column. Of course, the comments are longer than 16 characters and they show up just fine in the table. But I've defined the NewKeyStatsComment column as varchar(16). I suppose if I modified the NewKeyStatsComment to varchar(8000) then the entire comment would fit in the field. But doesn't SQL Server then bulk up the table by the 8000 characters per row? Or what? Steve Erbach Neenah, WI > ------------Original Message------------ > From: "Mackin, Christopher" > To: dba-sqlserver at databaseadvisors.com > Date: Thu, Jan-6-2005 9:00 AM > Subject: RE: [dba-SQLServer] Convert from ntext to varchar > > Try: > CAST(KeyStatsComment AS varchar(16)) > > Not specifying a length for the VarChar field may be causing the > problem. > > -Chris Mackin _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From mikedorism at adelphia.net Thu Jan 6 13:26:35 2005 From: mikedorism at adelphia.net (Mike & Doris Manning) Date: Thu, 6 Jan 2005 14:26:35 -0500 Subject: [dba-SQLServer] Convert from ntext to varchar In-Reply-To: <20050106125256.1072921112.serbach@new.rr.com> Message-ID: <000001c4f425$a4c22250$0b08a845@hargrove.internal> The answer to your bulk up question is "NO". If you were using CHAR datatype it would because SQL would pad the field with enough spaces to make 8000 characters. With VARCHAR, that does not happen. Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Steven W. Erbach Sent: Thursday, January 06, 2005 1:53 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Convert from ntext to varchar Chris, I was able to modify the SQL statement using your CAST suggestion. However when I executed the sproc, the NewKeyStatsComment field only had 16 characters of data in it. My understanding of the varchar data type is that it's variable in length, like the ntext type. My table definition has ntext(16) for the current KeyStatsComment column. Of course, the comments are longer than 16 characters and they show up just fine in the table. But I've defined the NewKeyStatsComment column as varchar(16). I suppose if I modified the NewKeyStatsComment to varchar(8000) then the entire comment would fit in the field. But doesn't SQL Server then bulk up the table by the 8000 characters per row? Or what? Steve Erbach Neenah, WI > ------------Original Message------------ > From: "Mackin, Christopher" > To: dba-sqlserver at databaseadvisors.com > Date: Thu, Jan-6-2005 9:00 AM > Subject: RE: [dba-SQLServer] Convert from ntext to varchar > > Try: > CAST(KeyStatsComment AS varchar(16)) > > Not specifying a length for the VarChar field may be causing the > problem. > > -Chris Mackin _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From serbach at new.rr.com Thu Jan 6 13:38:59 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Thu, 6 Jan 2005 13:38:59 -0600 Subject: [dba-SQLServer] Convert from ntext to varchar In-Reply-To: References: Message-ID: <20050106133859.839012668.serbach@new.rr.com> Chris, Thanks for the quick response. I don't think I've misunderstood the nature of varchar vs. char types. I *AM* confused by the necessity of giving a "length" for a varchar or ntext field. Here's why. I restructured my table and changed the NewKeyStatsComment field to varchar 8000. I went to my web host's nifty SQL Server status page and saw the size of the table before I made the restructure and after. I then changed the sproc so that the CAST statement used varchar(8000). That did the trick as far as copying the entire ntext comment column to the NewKeyStatsComment varchar column. Then I went back to the SQL Server status page and saw that the table's data had only increased in size by 56 KB. The confusing part for me is that an ntext field, which has a variable-length up to a max of about a billion characters, requires a number for the LENGTH...but you can stuff as much as you want into the field without worry. However, if you try to transfer the data from an ntext(16) field to a varchar(16) field, the varchar field winds up with only 16 characters. Why is there a requirement for a LENGTH in the data definition for a varchar field or ntext field at all? By the way, after I changed the structure to varchar(8000), I tried the sproc using just "varchar" in the CAST function. The NewKeyStatsComment field then wound up with 30 characters from the old comment field?! What's up with that? Then I changed the sproc to "varchar(8000)" and got the full comment. Thanks for your help. I'm going to leave the length of the varchar field at 8000. Steve Erbach Neenah, WI > ------------Original Message------------ > From: "Mackin, Christopher" > To: dba-sqlserver at databaseadvisors.com > Date: Thu, Jan-6-2005 1:23 PM > Subject: RE: [dba-SQLServer] Convert from ntext to varchar > > The real determining factor is the size of the field where it's being > stored. I would run something like: > > SELECT Max(Len(CAST(KeyStatsComment AS VarChar(8000)))) FROM ...... > > That will give you the Max length of the existing data, then from there > you should be able to determine how many characters you need in the > field in the table. > > I think you may be confusing VarChar and Char, VarChar is variable > length and stores only what it has, Char is fixed length and stores the > full amount of characters. > > -Chris Mackin > From serbach at new.rr.com Thu Jan 6 13:42:01 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Thu, 6 Jan 2005 13:42:01 -0600 Subject: [dba-SQLServer] Convert from ntext to varchar In-Reply-To: <000001c4f425$a4c22250$0b08a845@hargrove.internal> References: <20050106125256.1072921112.serbach@new.rr.com> <000001c4f425$a4c22250$0b08a845@hargrove.internal> Message-ID: <20050106134201.359120472.serbach@new.rr.com> Doris, Thank you very much. Any idea why a varchar or an ntext field requires a LENGTH? Inquiring minds... Steve Erbach Neenah, WI > ------------Original Message------------ > From: Mike & Doris Manning > To: dba-sqlserver at databaseadvisors.com > Date: Thu, Jan-6-2005 1:27 PM > Subject: RE: [dba-SQLServer] Convert from ntext to varchar > > The answer to your bulk up question is "NO". If you were using CHAR > datatype it would because SQL would pad the field with enough spaces to > make > 8000 characters. With VARCHAR, that does not happen. > > Doris Manning > Database Administrator > Hargrove Inc. > www.hargroveinc.com From CMackin at quiznos.com Thu Jan 6 13:45:08 2005 From: CMackin at quiznos.com (Mackin, Christopher) Date: Thu, 6 Jan 2005 12:45:08 -0700 Subject: [dba-SQLServer] Convert from ntext to varchar Message-ID: The Ntext or Text in SQL is similar to a Memo field in access and I don't really know exactly what the 16 indicates in the field, but for Char, VarChar, NChar and NVarChar the number after it is the length of data allowed in the field, same as a text field in Access/Jet. As for the 30 being allowed, I've seen similar results (with a different length passed on) when not specifying the length of a VarChar field, I'm not sure what sets the default and make it a point to always specify a length when dealing with those data types. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Steven W. Erbach Sent: Thursday, January 06, 2005 12:39 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Convert from ntext to varchar Chris, Thanks for the quick response. I don't think I've misunderstood the nature of varchar vs. char types. I *AM* confused by the necessity of giving a "length" for a varchar or ntext field. Here's why. I restructured my table and changed the NewKeyStatsComment field to varchar 8000. I went to my web host's nifty SQL Server status page and saw the size of the table before I made the restructure and after. I then changed the sproc so that the CAST statement used varchar(8000). That did the trick as far as copying the entire ntext comment column to the NewKeyStatsComment varchar column. Then I went back to the SQL Server status page and saw that the table's data had only increased in size by 56 KB. The confusing part for me is that an ntext field, which has a variable-length up to a max of about a billion characters, requires a number for the LENGTH...but you can stuff as much as you want into the field without worry. However, if you try to transfer the data from an ntext(16) field to a varchar(16) field, the varchar field winds up with only 16 characters. Why is there a requirement for a LENGTH in the data definition for a varchar field or ntext field at all? By the way, after I changed the structure to varchar(8000), I tried the sproc using just "varchar" in the CAST function. The NewKeyStatsComment field then wound up with 30 characters from the old comment field?! What's up with that? Then I changed the sproc to "varchar(8000)" and got the full comment. Thanks for your help. I'm going to leave the length of the varchar field at 8000. Steve Erbach Neenah, WI > ------------Original Message------------ > From: "Mackin, Christopher" > To: dba-sqlserver at databaseadvisors.com > Date: Thu, Jan-6-2005 1:23 PM > Subject: RE: [dba-SQLServer] Convert from ntext to varchar > > The real determining factor is the size of the field where it's being > stored. I would run something like: > > SELECT Max(Len(CAST(KeyStatsComment AS VarChar(8000)))) FROM ...... > > That will give you the Max length of the existing data, then from there > you should be able to determine how many characters you need in the > field in the table. > > I think you may be confusing VarChar and Char, VarChar is variable > length and stores only what it has, Char is fixed length and stores the > full amount of characters. > > -Chris Mackin > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From serbach at new.rr.com Thu Jan 6 14:19:01 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Thu, 6 Jan 2005 14:19:01 -0600 Subject: [dba-SQLServer] Convert from ntext to varchar In-Reply-To: References: Message-ID: <20050106141901.1431629898.serbach@new.rr.com> Chris, The fog lifts! Giving a length to a variable-length field does not plump up the database to accommodate that field length as it does for a fixed-length field; but the table will allow up to that many characters to be entered. Got it! Thanks. Steve Erbach Neenah, WI > ------------Original Message------------ > From: "Mackin, Christopher" > To: dba-sqlserver at databaseadvisors.com > Date: Thu, Jan-6-2005 1:46 PM > Subject: RE: [dba-SQLServer] Convert from ntext to varchar > > The Ntext or Text in SQL is similar to a Memo field in access and I > don't really know exactly what the 16 indicates in the field, but for > Char, VarChar, NChar and NVarChar the number after it is the length of data > allowed in the field, same as a text field in Access/Jet. > > As for the 30 being allowed, I've seen similar results (with a > different length passed on) when not specifying the length of a VarChar field, > I'm not sure what sets the default and make it a point to always > specify a length when dealing with those data types. > > -Chris Mackin From ggonzalez at cccis.com Fri Jan 7 16:02:04 2005 From: ggonzalez at cccis.com (ggonzalez at cccis.com) Date: Fri, 7 Jan 2005 16:02:04 -0600 Subject: [dba-SQLServer] Gumaro Gonzalez is out of the office. Message-ID: I will be out of the office starting 01/07/2005 and will not return until 01/17/2005. I will respond to your message when I return. From serbach at new.rr.com Wed Jan 12 07:50:35 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Wed, 12 Jan 2005 07:50:35 -0600 Subject: [dba-SQLServer] Nulls in sprocs Message-ID: <20050112075035.880274972.serbach@new.rr.com> Dear Group, I've run into a problem with UPDATE stored procedures that puzzles me. I have an sproc that looks like this: CREATE PROCEDURE spUpdPosition (@DeptID int, @Position nvarchar(50), @Analyst1 int, @Analyst2 int, @Description varchar(8000), @CreatedBy nvarchar(15), @UpdatedBy nvarchar(15), @DateUpdated datetime, @PositionID int) AS UPDATE tblPositionData SET DeptID = @DeptID, Position = @Position, Analyst1 = @Analyst1, Analyst2 = @Analyst2, Description = @Description, CreatedBy = @CreatedBy, UpdatedBy = @UpdatedBy, DateUpdated = @DateUpdated WHERE (PositionID = @PositionID) GO The PositionID is the key field, and it has the Identity property set to yes. My problem is this: if one of the fields to be updated is NULL, it seems that the sproc won't execute. I say "seems" because I get no indication back from SQL Server as to WHY the sproc failed. If there's a value for every field then it works fine, so I concluded that the problems arise from NULL values being written to the table. Can anyone tell me how to modify the sproc to account for possible NULL values in any of the fields? The only fields that have been defined as disallowing NULLs are the PositionID itself (automatically generated) and the DeptID, the foreign key. Regards, ? Steve Erbach Scientific Marketing Neenah, WI From mikedorism at adelphia.net Wed Jan 12 09:57:42 2005 From: mikedorism at adelphia.net (Mike & Doris Manning) Date: Wed, 12 Jan 2005 10:57:42 -0500 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: <20050112075035.880274972.serbach@new.rr.com> Message-ID: <000301c4f8bf$76cd3b20$0b08a845@hargrove.internal> You don't say what you are using for an FE but I know both Access and VB expect every parameter to be accounted for. Try setting default values. Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Steven W. Erbach Sent: Wednesday, January 12, 2005 8:51 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Nulls in sprocs Dear Group, I've run into a problem with UPDATE stored procedures that puzzles me. I have an sproc that looks like this: CREATE PROCEDURE spUpdPosition (@DeptID int, @Position nvarchar(50), @Analyst1 int, @Analyst2 int, @Description varchar(8000), @CreatedBy nvarchar(15), @UpdatedBy nvarchar(15), @DateUpdated datetime, @PositionID int) AS UPDATE tblPositionData SET DeptID = @DeptID, Position = @Position, Analyst1 = @Analyst1, Analyst2 = @Analyst2, Description = @Description, CreatedBy = @CreatedBy, UpdatedBy = @UpdatedBy, DateUpdated = @DateUpdated WHERE (PositionID = @PositionID) GO The PositionID is the key field, and it has the Identity property set to yes. My problem is this: if one of the fields to be updated is NULL, it seems that the sproc won't execute. I say "seems" because I get no indication back from SQL Server as to WHY the sproc failed. If there's a value for every field then it works fine, so I concluded that the problems arise from NULL values being written to the table. Can anyone tell me how to modify the sproc to account for possible NULL values in any of the fields? The only fields that have been defined as disallowing NULLs are the PositionID itself (automatically generated) and the DeptID, the foreign key. Regards, ? Steve Erbach Scientific Marketing Neenah, WI _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From serbach at new.rr.com Wed Jan 12 10:28:12 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Wed, 12 Jan 2005 10:28:12 -0600 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: <000301c4f8bf$76cd3b20$0b08a845@hargrove.internal> References: <20050112075035.880274972.serbach@new.rr.com> <000301c4f8bf$76cd3b20$0b08a845@hargrove.internal> Message-ID: <20050112102812.1185074831.serbach@new.rr.com> Doris, Thanks for the reply. I'm using VB.NET and ASP.NET and ADO.NET and #$!@#%**#@&!?!.NET for my front end. I tried using the sproc in an ADO.NET Transaction to allow Commit/Rollback. That's what I ultimately want to do. For now I'm using the VB.NET ExecuteNonQuery() method just to get the data in the table updated. My actual MAIN concern is with a couple of fields I have in another database that hold 1 for yes and 0 for no. These are radio button values. But if the answer is not known I'd like the value in the table to remain NULL. Of course, once a value IS selected, I don't have to worry about NULLs anymore because you can't set a radio button group back to nothing without code. I just thought of something: what if I constructed the sproc in my VB.NET code and simply skipped past the NULLs so that I don't have to worry about trying to update a field with a NULL value? Since the sproc begins with 'CREATE PROCEDURE sprocname' all I'd have to do would be to create a temporary file name, perhaps, to which to save the "constructed" sproc, execute the Transaction set like I want to, and then delete the temporary sproc after completion. What about that? Steve Erbach Neenah, WI > ------------Original Message------------ > From: Mike & Doris Manning > To: dba-sqlserver at databaseadvisors.com > Date: Wed, Jan-12-2005 9:58 AM > Subject: RE: [dba-SQLServer] Nulls in sprocs > > You don't say what you are using for an FE but I know both Access and > VB > expect every parameter to be accounted for. Try setting default > values. > > Doris Manning > Database Administrator > Hargrove Inc. > www.hargroveinc.com > From dmcafee at pacbell.net Wed Jan 12 11:26:45 2005 From: dmcafee at pacbell.net (dmcafee at pacbell.net) Date: Wed, 12 Jan 2005 09:26:45 -0800 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: <20050112075035.880274972.serbach@new.rr.com> Message-ID: Have you tried executing a similar example in QA (Query Analyzer)? Something like: EXEC spUpdPosition NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, SomeValidTestIDHere QA, should return the appropriate error. Have you also looked at the table design in EM or the column view in the object browser of QA? They will both show you whether or not Nulls are allowed for each field. You can also have the sproc return an error to the FE. Also, in your last post, you mentioned creating the sproc dynamically in the FE and executing the SQL string. This is generally thought of as a no-no (a security hole) HTH David McAfee -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Steven W. Erbach Sent: Wednesday, January 12, 2005 5:51 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Nulls in sprocs Dear Group, I've run into a problem with UPDATE stored procedures that puzzles me. I have an sproc that looks like this: CREATE PROCEDURE spUpdPosition (@DeptID int, @Position nvarchar(50), @Analyst1 int, @Analyst2 int, @Description varchar(8000), @CreatedBy nvarchar(15), @UpdatedBy nvarchar(15), @DateUpdated datetime, @PositionID int) AS UPDATE tblPositionData SET DeptID = @DeptID, Position = @Position, Analyst1 = @Analyst1, Analyst2 = @Analyst2, Description = @Description, CreatedBy = @CreatedBy, UpdatedBy = @UpdatedBy, DateUpdated = @DateUpdated WHERE (PositionID = @PositionID) GO The PositionID is the key field, and it has the Identity property set to yes. My problem is this: if one of the fields to be updated is NULL, it seems that the sproc won't execute. I say "seems" because I get no indication back from SQL Server as to WHY the sproc failed. If there's a value for every field then it works fine, so I concluded that the problems arise from NULL values being written to the table. Can anyone tell me how to modify the sproc to account for possible NULL values in any of the fields? The only fields that have been defined as disallowing NULLs are the PositionID itself (automatically generated) and the DeptID, the foreign key. Regards, Steve Erbach Scientific Marketing Neenah, WI _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From rl_stewart at highstream.net Wed Jan 12 12:36:55 2005 From: rl_stewart at highstream.net (Robert L. Stewart) Date: Wed, 12 Jan 2005 12:36:55 -0600 Subject: [dba-SQLServer] Re: Nulls in sprocs In-Reply-To: <200501121800.j0CI0el27687@databaseadvisors.com> Message-ID: <5.1.0.14.2.20050112123456.013e1ae0@pop3.highstream.net> Steve, Try building the insert statement in SQL instead of using a stored procedure. When building it, you can leave out the ones that are null. If you want to keep doing it as a stored procedure, pass null as the actual value. It does not do that automatically in .Net. Robert At 12:00 PM 1/12/2005 -0600, you wrote: >Date: Wed, 12 Jan 2005 10:28:12 -0600 >From: "Steven W. Erbach" >Subject: RE: [dba-SQLServer] Nulls in sprocs >To: dba-sqlserver at databaseadvisors.com >Message-ID: <20050112102812.1185074831.serbach at new.rr.com> >Content-Type: text/plain; charset=utf-8 > >Doris, > >Thanks for the reply. I'm using VB.NET and ASP.NET and ADO.NET and >#$!@#%**#@&!?!.NET for my front end. I tried using the sproc in an ADO.NET >Transaction to allow Commit/Rollback. That's what I ultimately want to do. >For now I'm using the VB.NET ExecuteNonQuery() method just to get the data >in the table updated. > >My actual MAIN concern is with a couple of fields I have in another >database that hold 1 for yes and 0 for no. These are radio button values. >But if the answer is not known I'd like the value in the table to remain >NULL. Of course, once a value IS selected, I don't have to worry about >NULLs anymore because you can't set a radio button group back to nothing >without code. > >I just thought of something: what if I constructed the sproc in my VB.NET >code and simply skipped past the NULLs so that I don't have to worry about >trying to update a field with a NULL value? Since the sproc begins with >'CREATE PROCEDURE sprocname' all I'd have to do would be to create a >temporary file name, perhaps, to which to save the "constructed" sproc, >execute the Transaction set like I want to, and then delete the temporary >sproc after completion. What about that? > >Steve Erbach >Neenah, WI From serbach at new.rr.com Wed Jan 12 15:01:04 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Wed, 12 Jan 2005 15:01:04 -0600 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: References: <20050112075035.880274972.serbach@new.rr.com> Message-ID: <20050112150104.860977127.serbach@new.rr.com> David, Thanks very much for the pointers. Yes, I can see where creating a temporary sproc could be a security problem. I'll try your other recommendations. Steve Erbach Neenah, WI > ------------Original Message------------ > From: dmcafee at pacbell.net > To: dba-sqlserver at databaseadvisors.com > Date: Wed, Jan-12-2005 11:26 AM > Subject: RE: [dba-SQLServer] Nulls in sprocs > > Have you tried executing a similar example in QA (Query Analyzer)? > > Something like: > > EXEC spUpdPosition NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, > SomeValidTestIDHere > > QA, should return the appropriate error. > > Have you also looked at the table design in EM or the column view in > the object browser of QA? They will both show you whether or not Nulls > are allowed for each field. > > You can also have the sproc return an error to the FE. > > Also, in your last post, you mentioned creating the sproc dynamically > in the FE and executing the SQL string. This is generally thought of as > a no-no (a security hole) > > HTH > David McAfee From serbach at new.rr.com Wed Jan 12 15:01:59 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Wed, 12 Jan 2005 15:01:59 -0600 Subject: [dba-SQLServer] Re: Nulls in sprocs In-Reply-To: <5.1.0.14.2.20050112123456.013e1ae0@pop3.highstream.net> References: <200501121800.j0CI0el27687@databaseadvisors.com> <5.1.0.14.2.20050112123456.013e1ae0@pop3.highstream.net> Message-ID: <20050112150159.308243794.serbach@new.rr.com> Robert, Thank you very much. I shall try that. Steve Erbach Neenah, WI > ------------Original Message------------ > From: "Robert L. Stewart" > To: dba-sqlserver at databaseadvisors.com > Cc: serbach at new.rr.com > Date: Wed, Jan-12-2005 12:37 PM > Subject: [dba-SQLServer] Re: Nulls in sprocs > > Steve, > > Try building the insert statement in SQL instead of using a stored > procedure. When building it, you can leave out the ones that are null. > > If you want to keep doing it as a stored procedure, pass null as the > actual > value. It does not do that automatically in .Net. > > Robert > From serbach at new.rr.com Wed Jan 12 19:18:48 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Wed, 12 Jan 2005 19:18:48 -0600 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: References: <20050112075035.880274972.serbach@new.rr.com> Message-ID: <20050112191848.1158667014.serbach@new.rr.com> David, OK, I tried the QA and inserted NULL in a couple spots, and the query ran all right. At first, though, I had trouble because I thought that I had to use the CONVERT function to change a date string to a datetime: CONVERT(datetime, "1/12/2005", 101) I ran the Parse Query (Ctrl-F5) on this and got the error: Incorrect syntax near the keyword 'CONVERT'. So, what the heck, I replaced the function with the date in quotation marks and, voila! She works! So what's the deal with CONVERT? I thought that SQL Server REQUIRED the use of CONVERT for queries. Steve Erbach Neenah, WI > ------------Original Message------------ > From: dmcafee at pacbell.net > To: dba-sqlserver at databaseadvisors.com > Date: Wed, Jan-12-2005 11:26 AM > Subject: RE: [dba-SQLServer] Nulls in sprocs > > Have you tried executing a similar example in QA (Query Analyzer)? > > Something like: > > EXEC spUpdPosition NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, > SomeValidTestIDHere > > QA, should return the appropriate error. > > Have you also looked at the table design in EM or the column view in > the object browser of QA? They will both show you whether or not Nulls > are allowed for each field. > > You can also have the sproc return an error to the FE. > > Also, in your last post, you mentioned creating the sproc dynamically > in the FE and executing the SQL string. This is generally thought of as > a no-no (a security hole) > > HTH > David McAfee > From dmcafee at pacbell.net Wed Jan 12 22:14:41 2005 From: dmcafee at pacbell.net (dmcafee at pacbell.net) Date: Wed, 12 Jan 2005 20:14:41 -0800 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: <20050112191848.1158667014.serbach@new.rr.com> Message-ID: Are you sure the error was with the word convert? Try changing the quotes around the date to single quotes :) Also, unless you are specifically changing the display format of a given date, I prefer to use CAST over CONVERT. Its less text to type :) CAST('1/12/2005' AS DATETIME) HTH David McAfee -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Steven W. Erbach Sent: Wednesday, January 12, 2005 5:19 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Nulls in sprocs David, OK, I tried the QA and inserted NULL in a couple spots, and the query ran all right. At first, though, I had trouble because I thought that I had to use the CONVERT function to change a date string to a datetime: CONVERT(datetime, "1/12/2005", 101) I ran the Parse Query (Ctrl-F5) on this and got the error: Incorrect syntax near the keyword 'CONVERT'. So, what the heck, I replaced the function with the date in quotation marks and, voila! She works! So what's the deal with CONVERT? I thought that SQL Server REQUIRED the use of CONVERT for queries. Steve Erbach Neenah, WI > ------------Original Message------------ > From: dmcafee at pacbell.net > To: dba-sqlserver at databaseadvisors.com > Date: Wed, Jan-12-2005 11:26 AM > Subject: RE: [dba-SQLServer] Nulls in sprocs > > Have you tried executing a similar example in QA (Query Analyzer)? > > Something like: > > EXEC spUpdPosition NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, > SomeValidTestIDHere > > QA, should return the appropriate error. > > Have you also looked at the table design in EM or the column view in > the object browser of QA? They will both show you whether or not Nulls > are allowed for each field. > > You can also have the sproc return an error to the FE. > > Also, in your last post, you mentioned creating the sproc dynamically > in the FE and executing the SQL string. This is generally thought of as > a no-no (a security hole) > > HTH > David McAfee > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From HARVEYF1 at WESTAT.com Wed Jan 12 22:24:01 2005 From: HARVEYF1 at WESTAT.com (Francis Harvey) Date: Wed, 12 Jan 2005 23:24:01 -0500 Subject: [dba-SQLServer] Nulls in sprocs Message-ID: <446DDE75CFC7E1438061462F85557B0F0481EC1F@remail2.westat.com> Steve, Yes, CONVERT is recommended. The problem is illustrated with your 1/12/2005 date which could be interpreted as January 12th, 2005 or December 1st, 2005. I assume you are already aware of this since you chose that for your example date. However, SQL Server will also make obvious data type conversions for you which is my typical approach towards dealing with this problem given my US-centric environment. I can't really guess how you got your exact syntax error message without the rest of the query, so I'll just point out that string literals should be in single quotes unless you have set the QUOTED_IDENTIFIER option to OFF. Maybe this can explain the change in behavior. Francis R Harvey III WB 303, (301)294-3952 harveyf1 at westat.com > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf > Of Steven W. Erbach > Sent: Wednesday, January 12, 2005 8:19 PM > To: dba-sqlserver at databaseadvisors.com > Subject: RE: [dba-SQLServer] Nulls in sprocs > > > David, > > OK, I tried the QA and inserted NULL in a couple spots, and > the query ran all right. At first, though, I had trouble > because I thought that I had to use the CONVERT function to > change a date string to a datetime: > > CONVERT(datetime, "1/12/2005", 101) > > I ran the Parse Query (Ctrl-F5) on this and got the error: > > Incorrect syntax near the keyword 'CONVERT'. > > So, what the heck, I replaced the function with the date in > quotation marks and, voila! She works! > > So what's the deal with CONVERT? I thought that SQL Server > REQUIRED the use of CONVERT for queries. > > Steve Erbach > Neenah, WI > > > ------------Original Message------------ > > From: dmcafee at pacbell.net > > To: dba-sqlserver at databaseadvisors.com > > Date: Wed, Jan-12-2005 11:26 AM > > Subject: RE: [dba-SQLServer] Nulls in sprocs > > > > Have you tried executing a similar example in QA (Query Analyzer)? > > > > Something like: > > > > EXEC spUpdPosition NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, > > SomeValidTestIDHere > > > > QA, should return the appropriate error. > > > > Have you also looked at the table design in EM or the > column view in > > the object browser of QA? They will both show you whether > or not Nulls > > are allowed for each field. > > > > You can also have the sproc return an error to the FE. > > > > Also, in your last post, you mentioned creating the sproc > dynamically > > in the FE and executing the SQL string. This is generally > thought of as > > a no-no (a security hole) > > > > HTH > > David McAfee > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From paul.hartland at fsmail.net Thu Jan 13 03:45:23 2005 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Thu, 13 Jan 2005 10:45:23 +0100 (CET) Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: <19021830.1105609523459.JavaMail.www@wwinf3001> To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From serbach at new.rr.com Thu Jan 13 06:04:42 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Thu, 13 Jan 2005 06:04:42 -0600 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: References: <20050112191848.1158667014.serbach@new.rr.com> Message-ID: <20050113060442.1790426076.serbach@new.rr.com> David, As to being sure that the error had to do with CONVERT, I'm pretty sure it did because when I replaced CONVERT(datetime, "1/12/2005", 101) with "1/12/2005" the UPDATE query execute just fine. Here's my EXEC statement using CAST: EXEC spUpdPosition 115, "This is the Position", 6, NULL, "This is the Description", "Bob", "Frank", CAST('1/12/2005' AS datetime), 660 I get the error: Incorrect syntax near '1/12/2005'. Beats my pair of jacks. Here was what worked in QA: EXEC spUpdPosition 115, "This is the Position", 6, NULL, "This is the Description", "Bob", "Frank", "1/12/2005", 660 Here, again, is my sproc: CREATE PROCEDURE spUpdPosition (@DeptID int, @Position nvarchar(50), @Analyst1 int, @Analyst2 int, @Description varchar(8000), @CreatedBy nvarchar(15), @UpdatedBy nvarchar(15), @DateUpdated datetime, @PositionID int) AS UPDATE tblPositionData SET DeptID = @DeptID, Position = @Position, Analyst1 = @Analyst1, Analyst2 = @Analyst2, Description = @Description, CreatedBy = @CreatedBy, UpdatedBy = @UpdatedBy, DateUpdated = @DateUpdated WHERE (PositionID = @PositionID) GO So, at least in QA, using a date string worked fine. As you can see in the text of the sproc, the DateUpdated field is of type DateTime. I'm still trying to figure out what's going wrong in my VB.NET code. ADO.NET has an Update method that I use in my VB.NET code in the Transaction. I want to be able to rollback if the commit doesn't work. Where I'm having trouble is just at the point where the Update query is supposed to execute on the server. The .NET Update method is supposed to return the number of rows updated. Every time I get 0 rows. So when the Commit takes place it, of course, succeeds because there are no rows affected. As far as allowing NULLs in any of the fields in the table, the only fields that are defined as NOT allowing NULLs are the PositionID (an Identity field, and the key) and the DeptID. I'll keep messing with it. Thanks for keeping up with me on this. Steve Erbach Neenah, WI > ------------Original Message------------ > From: dmcafee at pacbell.net > To: dba-sqlserver at databaseadvisors.com > Date: Wed, Jan-12-2005 10:15 PM > Subject: RE: [dba-SQLServer] Nulls in sprocs > > Are you sure the error was with the word convert? Try changing the > quotes around the date to single quotes :) > > Also, unless you are specifically changing the display format of a > given date, I prefer to use CAST over CONVERT. > Its less text to type :) > > CAST('1/12/2005' AS DATETIME) > > HTH > > David McAfee From serbach at new.rr.com Thu Jan 13 06:08:13 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Thu, 13 Jan 2005 06:08:13 -0600 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: <446DDE75CFC7E1438061462F85557B0F0481EC1F@remail2.westat.com> References: <446DDE75CFC7E1438061462F85557B0F0481EC1F@remail2.westat.com> Message-ID: <20050113060813.382794110.serbach@new.rr.com> Francis, Hmmm, I'm just wondering what the deal is with QA and the fact that it allowed me to use a date string in quotes instead of CAST or CONVERT. "1/12/2005" was rendered in the table as a proper American-style date. When I used this EXEC command: EXEC spUpdPosition 115, "This is the Position", 6, NULL, "This is the Description", "Bob", "Frank", CAST('1/12/2005' AS datetime), 660 I got the error: Incorrect syntax near '1/12/2005'. The sproc looks like this: CREATE PROCEDURE spUpdPosition (@DeptID int, @Position nvarchar(50), @Analyst1 int, @Analyst2 int, @Description varchar(8000), @CreatedBy nvarchar(15), @UpdatedBy nvarchar(15), @DateUpdated datetime, @PositionID int) AS UPDATE tblPositionData SET DeptID = @DeptID, Position = @Position, Analyst1 = @Analyst1, Analyst2 = @Analyst2, Description = @Description, CreatedBy = @CreatedBy, UpdatedBy = @UpdatedBy, DateUpdated = @DateUpdated WHERE (PositionID = @PositionID) GO The DateUpdated is a DateTime field, so I can't figure out why the CAST would fail in QA, while feeding the sproc a string for the date would work. Steve Erbach Neenah, WI > ------------Original Message------------ > From: Francis Harvey > To: "'dba-sqlserver at databaseadvisors.com'" > Date: Wed, Jan-12-2005 10:26 PM > Subject: RE: [dba-SQLServer] Nulls in sprocs > > Steve, > > Yes, CONVERT is recommended. The problem is illustrated with your > 1/12/2005 > date which could be interpreted as January 12th, 2005 or December 1st, > 2005. > I assume you are already aware of this since you chose that for your > example > date. However, SQL Server will also make obvious data type conversions > for > you which is my typical approach towards dealing with this problem > given my > US-centric environment. > > I can't really guess how you got your exact syntax error message > without the > rest of the query, so I'll just point out that string literals should > be in > single quotes unless you have set the QUOTED_IDENTIFIER option to OFF. > Maybe > this can explain the change in behavior. > > Francis R Harvey III > WB 303, (301)294-3952 > harveyf1 at westat.com From serbach at new.rr.com Thu Jan 13 06:41:58 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Thu, 13 Jan 2005 06:41:58 -0600 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: <20050112075035.880274972.serbach@new.rr.com> References: <20050112075035.880274972.serbach@new.rr.com> Message-ID: <20050113064158.558287013.serbach@new.rr.com> Dear Group, I may have figured something out with respect to this NULL business. It might have been a red herring. What I was trying to do was use a procedure in one of the O'Reilly .NET books that showed how to use a Transaction to commit and rollback a parameterized sproc. I followed the example using my own data and sproc as closely as I could, but the Update method that executed the sproc always returned 0 as the number of rows updated. I figured that it was because some of the values for the sproc parameters were NULL. Then I got a curveball thrown at me when I used QA to EXEC my sproc with literal values for the parameters. I found that I could simply type in a date as a string enclosed in quotes in the EXEC and the sproc would do it's thing just fine. Now I see in another book (The Murach ADO.NET book) that a Transaction can be wrapped around the ExecuteNonQuery method besides the Update method. So, instead of having to involve a SqlDataAdapter object and executing its Update method, I can simplify matters a bit and construct the UPDATE query in code, use the ExecuteNonQuery method of the SqlCommand object, and THEN attempt the Commit. I haven't actually modified my code to do this, but that's what I'm about to do now. Thanks for your help, David and Doris and Francis. I understand more about NULLs in sprocs now...though I'm baffled by this CAST/CONVERT business in QA. Steve Erbach Neenah, WI > ------------Original Message------------ > From: "Steven W. Erbach" > To: dba-sqlserver at databaseadvisors.com > Date: Wed, Jan-12-2005 7:50 AM > Subject: [dba-SQLServer] Nulls in sprocs > > Dear Group, > > I've run into a problem with UPDATE stored procedures that puzzles me. From CMackin at quiznos.com Thu Jan 13 08:40:21 2005 From: CMackin at quiznos.com (Mackin, Christopher) Date: Thu, 13 Jan 2005 07:40:21 -0700 Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From paul.hartland at fsmail.net Thu Jan 13 08:41:27 2005 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Thu, 13 Jan 2005 15:41:27 +0100 (CET) Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: <30322982.1105627287561.JavaMail.www@wwinf3003> Didn't think you could use the case statement in Views ? Message date : Jan 13 2005, 02:40 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] SQL Views Code For IIF Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From CMackin at quiznos.com Thu Jan 13 08:43:28 2005 From: CMackin at quiznos.com (Mackin, Christopher) Date: Thu, 13 Jan 2005 07:43:28 -0700 Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: You can, but you just can't see them graphically once you do it, but they're perfectly fine in Views. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 7:41 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: [dba-SQLServer] SQL Views Code For IIF Didn't think you could use the case statement in Views ? Message date : Jan 13 2005, 02:40 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] SQL Views Code For IIF Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From Susan.Klos at fldoe.org Thu Jan 13 09:01:15 2005 From: Susan.Klos at fldoe.org (Klos, Susan) Date: Thu, 13 Jan 2005 10:01:15 -0500 Subject: [dba-SQLServer] Percent Rank Function in SQL Message-ID: <01B619CB8F6C8C478EDAC39191AEC51E04151247@doesefpeml02.eus.fldoe.int> I need to use a Percent Rank function to determine which students are in the lowest 25% of a school. We sort then rank the prior year developmental scale score by previous year's grade level. Any ties need to be ranked down. Then we flag the students whose rank is 25.44 or below as in the lowest 25%. We do this for each grade level of the school (grade 3 - 10). If there are less than 30 students in the lowest 25% of the school then we need to resort all of the rankings in the school and flag the lowest 30 students. This is a separate calculation and only really needs to be done if the lowest 25% does not contain enough students. I hope this explanation is good enough to get someone to put me on the track of finding a Percent rank function. Thanks for all your help. Susan Klos Senior Database Analyst Evaluation and Reporting Florida Department of Education 850-245-0708 sc 205-0708 From paul.hartland at fsmail.net Thu Jan 13 09:36:00 2005 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Thu, 13 Jan 2005 16:36:00 +0100 (CET) Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: <5811920.1105630560037.JavaMail.www@wwinf3101> Just tried the following code and got an error CASE is not supported any idea's why ? SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, CASE lblStaffingCode WHEN 'Manager' THEN COUNT([PayrollNo]) WHEN 'Supervisor' THEN COUNT([PayrollNo]) WHEN 'Pharm Super' THEN COUNT([PayrollNo]) WHEN 'Water Super' THEN COUNT([PayrollNo]) WHEN 'Wilk Manager' THEN COUNT([PayrollNo]) END AS StaffMan CASE lblStaffingCode WHEN 'Counter' THEN COUNT([PayrollNo]) WHEN 'Checker' THEN COUNT([PayrollNo]) WHEN 'Control' THEN COUNT([PayrollNo]) WHEN 'Planner' THEN COUNT([PayrollNo]) WHEN 'Dispensary' THEN COUNT([PayrollNo]) WHEN 'Pharmacy' THEN COUNT([PayrollNo]) WHEN 'Planner/Counter' THEN COUNT([PayrollNo]) WHEN 'MB Driver Only' THEN COUNT([PayrollNo]) WHEN 'Traveller' THEN COUNT([PayrollNo]) WHEN 'Trainer' THEN COUNT([PayrollNo]) WHEN 'Planner/Checker' THEN COUNT([PayrollNo]) WHEN 'Site Visitor' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) WHEN 'Pharm Traveller' THEN COUNT([PayrollNo]) WHEN 'Wilk Estimator' THEN COUNT([PayrollNo]) WHEN 'Wilk Planner' THEN COUNT([PayrollNo]) WHEN 'Wilk Checker' THEN COUNT([PayrollNo]) WHEN 'Wool Core Team' THEN COUNT([PayrollNo]) WHEN 'Water NSA' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) END AS StaffOther WHERE (((tblAvailabilityAll.JobDate) >= GETDATE() - 30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) IS NOT NULL)) Message date : Jan 13 2005, 02:44 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: [dba-SQLServer] SQL Views Code For IIF You can, but you just can't see them graphically once you do it, but they're perfectly fine in Views. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 7:41 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: [dba-SQLServer] SQL Views Code For IIF Didn't think you could use the case statement in Views ? Message date : Jan 13 2005, 02:40 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] SQL Views Code For IIF Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From CMackin at quiznos.com Thu Jan 13 09:43:08 2005 From: CMackin at quiznos.com (Mackin, Christopher) Date: Thu, 13 Jan 2005 08:43:08 -0700 Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: What is the exact error message? When it says it's not supported it may be saying that it cna't be viewed graphically in Enterprise Manager. Are you writing this in an .adp, Enterpriose Manager, Query Analyzer or other? -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 8:36 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: RE: [dba-SQLServer] SQL Views Code For IIF Just tried the following code and got an error CASE is not supported any idea's why ? SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, CASE lblStaffingCode WHEN 'Manager' THEN COUNT([PayrollNo]) WHEN 'Supervisor' THEN COUNT([PayrollNo]) WHEN 'Pharm Super' THEN COUNT([PayrollNo]) WHEN 'Water Super' THEN COUNT([PayrollNo]) WHEN 'Wilk Manager' THEN COUNT([PayrollNo]) END AS StaffMan CASE lblStaffingCode WHEN 'Counter' THEN COUNT([PayrollNo]) WHEN 'Checker' THEN COUNT([PayrollNo]) WHEN 'Control' THEN COUNT([PayrollNo]) WHEN 'Planner' THEN COUNT([PayrollNo]) WHEN 'Dispensary' THEN COUNT([PayrollNo]) WHEN 'Pharmacy' THEN COUNT([PayrollNo]) WHEN 'Planner/Counter' THEN COUNT([PayrollNo]) WHEN 'MB Driver Only' THEN COUNT([PayrollNo]) WHEN 'Traveller' THEN COUNT([PayrollNo]) WHEN 'Trainer' THEN COUNT([PayrollNo]) WHEN 'Planner/Checker' THEN COUNT([PayrollNo]) WHEN 'Site Visitor' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) WHEN 'Pharm Traveller' THEN COUNT([PayrollNo]) WHEN 'Wilk Estimator' THEN COUNT([PayrollNo]) WHEN 'Wilk Planner' THEN COUNT([PayrollNo]) WHEN 'Wilk Checker' THEN COUNT([PayrollNo]) WHEN 'Wool Core Team' THEN COUNT([PayrollNo]) WHEN 'Water NSA' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) END AS StaffOther WHERE (((tblAvailabilityAll.JobDate) >= GETDATE() - 30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) IS NOT NULL)) Message date : Jan 13 2005, 02:44 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: [dba-SQLServer] SQL Views Code For IIF You can, but you just can't see them graphically once you do it, but they're perfectly fine in Views. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 7:41 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: [dba-SQLServer] SQL Views Code For IIF Didn't think you could use the case statement in Views ? Message date : Jan 13 2005, 02:40 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] SQL Views Code For IIF Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From paul.hartland at fsmail.net Thu Jan 13 09:47:57 2005 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Thu, 13 Jan 2005 16:47:57 +0100 (CET) Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: <17475003.1105631277746.JavaMail.www@wwinf3101> Using Enterprise Manager - Create New View: The following errors were encountered while parsing the contents of the SQL pane CASE is not supported and just have an OK and HELP button Message date : Jan 13 2005, 03:43 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: RE: [dba-SQLServer] SQL Views Code For IIF What is the exact error message? When it says it's not supported it may be saying that it cna't be viewed graphically in Enterprise Manager. Are you writing this in an .adp, Enterpriose Manager, Query Analyzer or other? -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 8:36 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: RE: [dba-SQLServer] SQL Views Code For IIF Just tried the following code and got an error CASE is not supported any idea's why ? SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, CASE lblStaffingCode WHEN 'Manager' THEN COUNT([PayrollNo]) WHEN 'Supervisor' THEN COUNT([PayrollNo]) WHEN 'Pharm Super' THEN COUNT([PayrollNo]) WHEN 'Water Super' THEN COUNT([PayrollNo]) WHEN 'Wilk Manager' THEN COUNT([PayrollNo]) END AS StaffMan CASE lblStaffingCode WHEN 'Counter' THEN COUNT([PayrollNo]) WHEN 'Checker' THEN COUNT([PayrollNo]) WHEN 'Control' THEN COUNT([PayrollNo]) WHEN 'Planner' THEN COUNT([PayrollNo]) WHEN 'Dispensary' THEN COUNT([PayrollNo]) WHEN 'Pharmacy' THEN COUNT([PayrollNo]) WHEN 'Planner/Counter' THEN COUNT([PayrollNo]) WHEN 'MB Driver Only' THEN COUNT([PayrollNo]) WHEN 'Traveller' THEN COUNT([PayrollNo]) WHEN 'Trainer' THEN COUNT([PayrollNo]) WHEN 'Planner/Checker' THEN COUNT([PayrollNo]) WHEN 'Site Visitor' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) WHEN 'Pharm Traveller' THEN COUNT([PayrollNo]) WHEN 'Wilk Estimator' THEN COUNT([PayrollNo]) WHEN 'Wilk Planner' THEN COUNT([PayrollNo]) WHEN 'Wilk Checker' THEN COUNT([PayrollNo]) WHEN 'Wool Core Team' THEN COUNT([PayrollNo]) WHEN 'Water NSA' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) END AS StaffOther WHERE (((tblAvailabilityAll.JobDate) >= GETDATE() - 30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) IS NOT NULL)) Message date : Jan 13 2005, 02:44 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: [dba-SQLServer] SQL Views Code For IIF You can, but you just can't see them graphically once you do it, but they're perfectly fine in Views. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 7:41 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: [dba-SQLServer] SQL Views Code For IIF Didn't think you could use the case statement in Views ? Message date : Jan 13 2005, 02:40 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] SQL Views Code For IIF Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From jeffrey.demulling at usbank.com Thu Jan 13 09:51:20 2005 From: jeffrey.demulling at usbank.com (jeffrey.demulling at usbank.com) Date: Thu, 13 Jan 2005 09:51:20 -0600 Subject: [dba-SQLServer] SQL Views Code For IIF In-Reply-To: <5811920.1105630560037.JavaMail.www@wwinf3101> Message-ID: Add a comma after "END AS StaffMan" paul.hartland at fsm ail.net Sent by: To dba-sqlserver-bou dba-sqlserver at databaseadvisors.com nces at databaseadvi cc sors.com Subject Re: RE: RE: [dba-SQLServer] SQL 01/13/2005 09:36 Views Code For IIF AM Please respond to dba-sqlserver at dat abaseadvisors.com Just tried the following code and got an error CASE is not supported any idea's why ? SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, CASE lblStaffingCode WHEN 'Manager' THEN COUNT([PayrollNo]) WHEN 'Supervisor' THEN COUNT([PayrollNo]) WHEN 'Pharm Super' THEN COUNT([PayrollNo]) WHEN 'Water Super' THEN COUNT([PayrollNo]) WHEN 'Wilk Manager' THEN COUNT([PayrollNo]) END AS StaffMan CASE lblStaffingCode WHEN 'Counter' THEN COUNT([PayrollNo]) WHEN 'Checker' THEN COUNT([PayrollNo]) WHEN 'Control' THEN COUNT([PayrollNo]) WHEN 'Planner' THEN COUNT([PayrollNo]) WHEN 'Dispensary' THEN COUNT([PayrollNo]) WHEN 'Pharmacy' THEN COUNT([PayrollNo]) WHEN 'Planner/Counter' THEN COUNT([PayrollNo]) WHEN 'MB Driver Only' THEN COUNT([PayrollNo]) WHEN 'Traveller' THEN COUNT([PayrollNo]) WHEN 'Trainer' THEN COUNT([PayrollNo]) WHEN 'Planner/Checker' THEN COUNT([PayrollNo]) WHEN 'Site Visitor' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) WHEN 'Pharm Traveller' THEN COUNT([PayrollNo]) WHEN 'Wilk Estimator' THEN COUNT([PayrollNo]) WHEN 'Wilk Planner' THEN COUNT([PayrollNo]) WHEN 'Wilk Checker' THEN COUNT([PayrollNo]) WHEN 'Wool Core Team' THEN COUNT([PayrollNo]) WHEN 'Water NSA' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) END AS StaffOther WHERE (((tblAvailabilityAll.JobDate) >= GETDATE() - 30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) IS NOT NULL)) Message date : Jan 13 2005, 02:44 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: [dba-SQLServer] SQL Views Code For IIF You can, but you just can't see them graphically once you do it, but they're perfectly fine in Views. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 7:41 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: [dba-SQLServer] SQL Views Code For IIF Didn't think you could use the case statement in Views ? Message date : Jan 13 2005, 02:40 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] SQL Views Code For IIF Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com ------------------------------------------------------------------------------ Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation. ============================================================================== From CMackin at quiznos.com Thu Jan 13 09:51:21 2005 From: CMackin at quiznos.com (Mackin, Christopher) Date: Thu, 13 Jan 2005 08:51:21 -0700 Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: EM will always say that it's not supported, but that just means you can't view it graphically, drop the same code into Query Analyzer and run it with CREATE VIEW dbo.MyViewName AS on top of the current SQL and you should be fine. Clicking OK in EM should also make the table disappear graphically, but should still work fine. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 8:48 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: RE: RE: [dba-SQLServer] SQL Views Code For IIF Using Enterprise Manager - Create New View: The following errors were encountered while parsing the contents of the SQL pane CASE is not supported and just have an OK and HELP button Message date : Jan 13 2005, 03:43 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: RE: [dba-SQLServer] SQL Views Code For IIF What is the exact error message? When it says it's not supported it may be saying that it cna't be viewed graphically in Enterprise Manager. Are you writing this in an .adp, Enterpriose Manager, Query Analyzer or other? -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 8:36 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: RE: [dba-SQLServer] SQL Views Code For IIF Just tried the following code and got an error CASE is not supported any idea's why ? SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, CASE lblStaffingCode WHEN 'Manager' THEN COUNT([PayrollNo]) WHEN 'Supervisor' THEN COUNT([PayrollNo]) WHEN 'Pharm Super' THEN COUNT([PayrollNo]) WHEN 'Water Super' THEN COUNT([PayrollNo]) WHEN 'Wilk Manager' THEN COUNT([PayrollNo]) END AS StaffMan CASE lblStaffingCode WHEN 'Counter' THEN COUNT([PayrollNo]) WHEN 'Checker' THEN COUNT([PayrollNo]) WHEN 'Control' THEN COUNT([PayrollNo]) WHEN 'Planner' THEN COUNT([PayrollNo]) WHEN 'Dispensary' THEN COUNT([PayrollNo]) WHEN 'Pharmacy' THEN COUNT([PayrollNo]) WHEN 'Planner/Counter' THEN COUNT([PayrollNo]) WHEN 'MB Driver Only' THEN COUNT([PayrollNo]) WHEN 'Traveller' THEN COUNT([PayrollNo]) WHEN 'Trainer' THEN COUNT([PayrollNo]) WHEN 'Planner/Checker' THEN COUNT([PayrollNo]) WHEN 'Site Visitor' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) WHEN 'Pharm Traveller' THEN COUNT([PayrollNo]) WHEN 'Wilk Estimator' THEN COUNT([PayrollNo]) WHEN 'Wilk Planner' THEN COUNT([PayrollNo]) WHEN 'Wilk Checker' THEN COUNT([PayrollNo]) WHEN 'Wool Core Team' THEN COUNT([PayrollNo]) WHEN 'Water NSA' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) END AS StaffOther WHERE (((tblAvailabilityAll.JobDate) >= GETDATE() - 30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) IS NOT NULL)) Message date : Jan 13 2005, 02:44 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: [dba-SQLServer] SQL Views Code For IIF You can, but you just can't see them graphically once you do it, but they're perfectly fine in Views. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 7:41 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: [dba-SQLServer] SQL Views Code For IIF Didn't think you could use the case statement in Views ? Message date : Jan 13 2005, 02:40 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] SQL Views Code For IIF Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From paul.hartland at fsmail.net Thu Jan 13 09:56:09 2005 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Thu, 13 Jan 2005 16:56:09 +0100 (CET) Subject: [dba-SQLServer] SQL Views Code For IIF Message-ID: <15013753.1105631769303.JavaMail.www@wwinf3101> Seems to be doing something now, the Server is churning away, just got to adjust my timeout by the looks of it. Thanks a lot for all your help, hopefully I can repay the favour sometime Paul Message date : Jan 13 2005, 03:54 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: RE: RE: [dba-SQLServer] SQL Views Code For IIF EM will always say that it's not supported, but that just means you can't view it graphically, drop the same code into Query Analyzer and run it with CREATE VIEW dbo.MyViewName AS on top of the current SQL and you should be fine. Clicking OK in EM should also make the table disappear graphically, but should still work fine. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 8:48 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: RE: RE: [dba-SQLServer] SQL Views Code For IIF Using Enterprise Manager - Create New View: The following errors were encountered while parsing the contents of the SQL pane CASE is not supported and just have an OK and HELP button Message date : Jan 13 2005, 03:43 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: RE: [dba-SQLServer] SQL Views Code For IIF What is the exact error message? When it says it's not supported it may be saying that it cna't be viewed graphically in Enterprise Manager. Are you writing this in an .adp, Enterpriose Manager, Query Analyzer or other? -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 8:36 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: RE: [dba-SQLServer] SQL Views Code For IIF Just tried the following code and got an error CASE is not supported any idea's why ? SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, CASE lblStaffingCode WHEN 'Manager' THEN COUNT([PayrollNo]) WHEN 'Supervisor' THEN COUNT([PayrollNo]) WHEN 'Pharm Super' THEN COUNT([PayrollNo]) WHEN 'Water Super' THEN COUNT([PayrollNo]) WHEN 'Wilk Manager' THEN COUNT([PayrollNo]) END AS StaffMan CASE lblStaffingCode WHEN 'Counter' THEN COUNT([PayrollNo]) WHEN 'Checker' THEN COUNT([PayrollNo]) WHEN 'Control' THEN COUNT([PayrollNo]) WHEN 'Planner' THEN COUNT([PayrollNo]) WHEN 'Dispensary' THEN COUNT([PayrollNo]) WHEN 'Pharmacy' THEN COUNT([PayrollNo]) WHEN 'Planner/Counter' THEN COUNT([PayrollNo]) WHEN 'MB Driver Only' THEN COUNT([PayrollNo]) WHEN 'Traveller' THEN COUNT([PayrollNo]) WHEN 'Trainer' THEN COUNT([PayrollNo]) WHEN 'Planner/Checker' THEN COUNT([PayrollNo]) WHEN 'Site Visitor' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) WHEN 'Pharm Traveller' THEN COUNT([PayrollNo]) WHEN 'Wilk Estimator' THEN COUNT([PayrollNo]) WHEN 'Wilk Planner' THEN COUNT([PayrollNo]) WHEN 'Wilk Checker' THEN COUNT([PayrollNo]) WHEN 'Wool Core Team' THEN COUNT([PayrollNo]) WHEN 'Water NSA' THEN COUNT([PayrollNo]) WHEN 'Pharm Counter' THEN COUNT([PayrollNo]) END AS StaffOther WHERE (((tblAvailabilityAll.JobDate) >= GETDATE() - 30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) IS NOT NULL)) Message date : Jan 13 2005, 02:44 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: RE: [dba-SQLServer] SQL Views Code For IIF You can, but you just can't see them graphically once you do it, but they're perfectly fine in Views. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 7:41 AM To: dba-sqlserver at databaseadvisors.com Subject: Re: RE: [dba-SQLServer] SQL Views Code For IIF Didn't think you could use the case statement in Views ? Message date : Jan 13 2005, 02:40 PM >From : "Mackin, Christopher" To : dba-sqlserver at databaseadvisors.com Copy to : Subject : RE: [dba-SQLServer] SQL Views Code For IIF Lok up the CASE statement for T-SQL, it provides the IIF functionality. -Chris Mackin -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of paul.hartland at fsmail.net Sent: Thursday, January 13, 2005 2:45 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] SQL Views Code For IIF To all, I have the following code in an Access database: SELECT tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode, IIf([lblStaffingCode]="Manager" Or [lblStaffingCode]="Supervisor",Count([PayrollNo]),0) AS StaffMan, IIf([lblStaffingCode]<>"Manager" And [lblStaffingCode]<>"Supervisor",Count([PayrollNo]),0) AS StaffOther FROM tblAvailabilityAll WHERE (((tblAvailabilityAll.JobDate)>=Date()-30)) GROUP BY tblAvailabilityAll.JobNo, tblAvailabilityAll.lblStaffingCode HAVING (((tblAvailabilityAll.JobNo) Is Not Null)) How can I put this into a view in SQL Server 7.0, The only thing I'm sure of is changing the Date()-30 to GETDATE()-30 and changing the " (double quotes) to ' (single quotes) Thanks for any help in advance Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm _______________________________________________ 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 -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From dmcafee at pacbell.net Fri Jan 14 00:55:06 2005 From: dmcafee at pacbell.net (dmcafee at pacbell.net) Date: Thu, 13 Jan 2005 22:55:06 -0800 Subject: [dba-SQLServer] Nulls in sprocs In-Reply-To: <20050113060813.382794110.serbach@new.rr.com> Message-ID: It failed in QA (in you first example) because QA doesn't recognize a string enclosed in double quote as text. QA expects single quotes. IF you are passing a text file from VB, VBA, C# or C++ then you must enclose the text in a double quote (unless you are creating the SQL statement in the FE (which technically is a no no, security wise) I tried this in QA: DECLARE @SomeDate AS DATETIME DECLARE @SomeText AS VARCHAR(50) SET @SomeText = '1/12/2005' SET @SomeDate = CAST('1/12/2005' AS datetime) SELECT @someText, @SomeDate, CAST('1/12/2005' AS datetime), CAST(@SomeText AS DATETIME), CONVERT(DATETIME, @SomeText, 101) and this was my reult: 1/12/2005 2005-01-12 00:00:00.000 2005-01-12 00:00:00.000 2005-01-12 00:00:00.000 2005-01-12 00:00:00.000 -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Steven W. Erbach Sent: Thursday, January 13, 2005 4:08 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Nulls in sprocs Francis, Hmmm, I'm just wondering what the deal is with QA and the fact that it allowed me to use a date string in quotes instead of CAST or CONVERT. "1/12/2005" was rendered in the table as a proper American-style date. When I used this EXEC command: EXEC spUpdPosition 115, "This is the Position", 6, NULL, "This is the Description", "Bob", "Frank", CAST('1/12/2005' AS datetime), 660 I got the error: Incorrect syntax near '1/12/2005'. The sproc looks like this: CREATE PROCEDURE spUpdPosition (@DeptID int, @Position nvarchar(50), @Analyst1 int, @Analyst2 int, @Description varchar(8000), @CreatedBy nvarchar(15), @UpdatedBy nvarchar(15), @DateUpdated datetime, @PositionID int) AS UPDATE tblPositionData SET DeptID = @DeptID, Position = @Position, Analyst1 = @Analyst1, Analyst2 = @Analyst2, Description = @Description, CreatedBy = @CreatedBy, UpdatedBy = @UpdatedBy, DateUpdated = @DateUpdated WHERE (PositionID = @PositionID) GO The DateUpdated is a DateTime field, so I can't figure out why the CAST would fail in QA, while feeding the sproc a string for the date would work. Steve Erbach Neenah, WI > ------------Original Message------------ > From: Francis Harvey > To: "'dba-sqlserver at databaseadvisors.com'" > Date: Wed, Jan-12-2005 10:26 PM > Subject: RE: [dba-SQLServer] Nulls in sprocs > > Steve, > > Yes, CONVERT is recommended. The problem is illustrated with your > 1/12/2005 > date which could be interpreted as January 12th, 2005 or December 1st, > 2005. > I assume you are already aware of this since you chose that for your > example > date. However, SQL Server will also make obvious data type conversions > for > you which is my typical approach towards dealing with this problem > given my > US-centric environment. > > I can't really guess how you got your exact syntax error message > without the > rest of the query, so I'll just point out that string literals should > be in > single quotes unless you have set the QUOTED_IDENTIFIER option to OFF. > Maybe > this can explain the change in behavior. > > Francis R Harvey III > WB 303, (301)294-3952 > harveyf1 at westat.com From paul.hartland at fsmail.net Fri Jan 14 04:20:25 2005 From: paul.hartland at fsmail.net (paul.hartland at fsmail.net) Date: Fri, 14 Jan 2005 11:20:25 +0100 (CET) Subject: [dba-SQLServer] SQL Server Function Equivalent To DLookUp Message-ID: <26378872.1105698025508.JavaMail.www@wwinf3001> To all, Can anyone tell me if there is a SQL Server function that is equivalent to the Microsoft Access DLookUp function ? Thanks in advance for any help Paul Hartland -- Whatever you Wanadoo: http://www.wanadoo.co.uk/time/ This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm From fhtapia at gmail.com Fri Jan 14 10:13:01 2005 From: fhtapia at gmail.com (Francisco Tapia) Date: Fri, 14 Jan 2005 08:13:01 -0800 Subject: [dba-SQLServer] SQL Server Function Equivalent To DLookUp In-Reply-To: <26378872.1105698025508.JavaMail.www@wwinf3001> References: <26378872.1105698025508.JavaMail.www@wwinf3001> Message-ID: No, you can write either a subquery or a user defined function in order to get the same functionality. here is an example of a text returning function, the following function gives the diffrence between two datetime entries yielding days, hours and minutes in the difference. CREATE FUNCTION udfDiffBetweenDates( @StartDT DATETIME, @EndDT DATETIME) RETURNS VARCHAR(30) AS BEGIN DECLARE @intMin Int, @intHrs Int, @intDys Int, @TotalMin Int, @strOUTPUT Varchar(30) SET @TotalMin = ABS(DATEDIFF(mi, @StartDT, @EndDT)) SET @intDys = @TotalMin / (24*60) SET @intHrs = (@TotalMin-(@intDys*24*60)) / 60 SET @intMin = @TotalMin-((@intDys*24*60)+(@intHrs*60)) If @StartDT <= @EndDT Begin SET @strOUTPUT = CAST(@intDys as varchar(5)) + 'Days, ' + CAST(@intHrs as varchar(2)) + 'Hours, ' + cast( @intMin as varchar(2)) + 'Minutes' End Else Begin SET @strOUTPUT = '-(' + cast( @intDys as varchar(5)) + 'Days, ' + cast( @intHrs as varchar(2)) + 'Hours, ' + cast( @intMin as varchar(2)) + 'Minutes' + ')' End RETURN @strOUTPUT END On Fri, 14 Jan 2005 11:20:25 +0100 (CET), paul.hartland at fsmail.net wrote: > To all, > > Can anyone tell me if there is a SQL Server function that is equivalent to the Microsoft Access DLookUp function ? > > Thanks in advance for any help > > Paul Hartland > > -- > > Whatever you Wanadoo: > http://www.wanadoo.co.uk/time/ > > This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco http://pcthis.blogspot.com | PC news with out the jargon! From chizotz at mchsi.com Fri Jan 14 12:18:01 2005 From: chizotz at mchsi.com (chizotz at mchsi.com) Date: Fri, 14 Jan 2005 18:18:01 +0000 Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) Message-ID: <011420051818.15968.4c8d@mchsi.com> Apologies if this is completely OT. I've been told that as a company we would like to start moving to ASP.NET applications rather than Windows Forms applications. Windows forms apps I know, and have been doing for years. I have never done anything with ASP. The IT department is being incredibly difficult about helping me get started. This is political, they resent an "outsider" (i.e. a developer not in their department) being able to do, well, anything. I'm not stupid, but I am almost completely ignorant when it comes to ASP.NET. IT told me that I could publish my test projects to http://intranet/artestweb and use my network login. When I start up Visual Studio and try to start a C# ASP.NET Web Application, it tells me that the path \\intranet\wwwroot$\artestweb\rallen\WebApplication1 either does not exist or that I do not have access. When I ask IT about this, their response is "I took a look at the folder and there is no directory rallen. Check to see if you have a local version." They are being deliberately difficult. I have no idea how to create the directory, where it is on our file system, anything. Trying to create a local project, i.e. on the filesystem of my work station results in an error that says that the file path and URL do not map to the same server location. I simply don't understand (yet) what I need to do. Earlier in this mess, they asked if I had made a DNS. Well, yes, I have a DNS that supposedly connects to the Intranet database, but it, too, does not like my username/password. If someone could explain what I should be looking for, or what I should ask, or anything at all that would let me deal with this situation from a position of just a little more strength, I would surely appreciate it. Thanks, Ron From ebarro at afsweb.com Fri Jan 14 12:54:05 2005 From: ebarro at afsweb.com (Eric Barro) Date: Fri, 14 Jan 2005 10:54:05 -0800 Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) In-Reply-To: <011420051818.15968.4c8d@mchsi.com> Message-ID: Ron, Visual Studio uses FrontPage server extensions to publish to a web site. This means that your local wwwroot folder needs to match up with the remote wwwroot folder or else you won't be able to publish your app to the remote web server using VS.NET. Instead you will have to settle for the old FTP approach using an FTP client. Basically when you use VS.NET you just need to point the project to a local folder on your machine. It will of course expect you to be running a web server on your local machine since it will take care of creating the virtual folder on the web server root folder. For example: app name = MyApp This translates to the physical location (assuming you have IIS defaults) = C:\INETPUB\WWWROOT\MYAPP\ Your project files will then be saved to this physical location. The DLL for the web app will be in C:\INETPUB\WWWROOT\MYAPP\BIN\ VS.NET will try to publish your app to the remote web server by first trying to create a virtual folder called MyApp on the web server root. If it can't do that then you will need to use manual FTP methods to publish it to F:\INETPUB\WWWROOT\MYAPP\ (assuming that F:\INETPUB\WWWROOT\ *is* the remote web server root). When you publish your app you just need to copy over the ASPX page and the DLL to the MYAPP and MYAPP\BIN folder respectively. The .NET framework will recognize a compiled version (DLL) of your app and run it accordingly. Hope this helps. Eric -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of chizotz at mchsi.com Sent: Friday, January 14, 2005 10:18 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) Apologies if this is completely OT. I've been told that as a company we would like to start moving to ASP.NET applications rather than Windows Forms applications. Windows forms apps I know, and have been doing for years. I have never done anything with ASP. The IT department is being incredibly difficult about helping me get started. This is political, they resent an "outsider" (i.e. a developer not in their department) being able to do, well, anything. I'm not stupid, but I am almost completely ignorant when it comes to ASP.NET. IT told me that I could publish my test projects to http://intranet/artestweb and use my network login. When I start up Visual Studio and try to start a C# ASP.NET Web Application, it tells me that the path \\intranet\wwwroot$\artestweb\rallen\WebApplication1 either does not exist or that I do not have access. When I ask IT about this, their response is "I took a look at the folder and there is no directory rallen. Check to see if you have a local version." They are being deliberately difficult. I have no idea how to create the directory, where it is on our file system, anything. Trying to create a local project, i.e. on the filesystem of my work station results in an error that says that the file path and URL do not map to the same server location. I simply don't understand (yet) what I need to do. Earlier in this mess, they asked if I had made a DNS. Well, yes, I have a DNS that supposedly connects to the Intranet database, but it, too, does not like my username/password. If someone could explain what I should be looking for, or what I should ask, or anything at all that would let me deal with this situation from a position of just a little more strength, I would surely appreciate it. Thanks, Ron _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com ---------------------------------------------------------------- The information contained in this e-mail message and any file, document, previous e-mail message and/or attachment transmitted herewith is confidential and may be legally privileged. It is intended solely for the private use of the addressee and must not be disclosed to or used by anyone other than the addressee. If you receive this transmission by error, please immediately notify the sender by reply e-mail and destroy the original transmission and its attachments without reading or saving it in any manner. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of any of the information contained in or attached to this transmission is STRICTLY PROHIBITED. E-mail transmission cannot be guaranteed to be secure or error free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of email transmission. Users and employees of the e-mail system are expressly required not to make defamatory statements and not to infringe or authorize any infringement of copyright or any other legal right by email communications. Any such communication is contrary to company policy. The company will not accept any liability in respect of such communication. From martyconnelly at shaw.ca Fri Jan 14 13:04:39 2005 From: martyconnelly at shaw.ca (MartyConnelly) Date: Fri, 14 Jan 2005 11:04:39 -0800 Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) References: <011420051818.15968.4c8d@mchsi.com> Message-ID: <41E817C7.3000703@shaw.ca> Here are a slew of asp and asp.net advice mailing lists. Also look through blogs. http://aspadvice.com/ Tell them your client and server configuation ie. framework, iis version and os. If you are running remotely you may need IIS installed on your machine to support ADSI This was an old problem maybe fixed and no longer valid. Install IIS first then ASP framework this caused problems a few years back maybe fixed. If you are just starting out here are some templates and wizards. The new version of ASP.NET Web Matrix wizard http://www.asp.net/Default.aspx?tabindex=0&tabid=1 how to use web matrix http://doc.advisor.com/Articles.nsf/nl/13647 Jump Start Your Web Site Development with the ASP.NET Starter Kits http://msdn.microsoft.com/msdnmag/issues/03/08/StarterKits/default.aspx chizotz at mchsi.com wrote: >Apologies if this is completely OT. > >I've been told that as a company we would like to start moving to ASP.NET >applications rather than Windows Forms applications. Windows forms apps I >know, and have been doing for years. I have never done anything with ASP. The >IT department is being incredibly difficult about helping me get started. This >is political, they resent an "outsider" (i.e. a developer not in their >department) being able to do, well, anything. > >I'm not stupid, but I am almost completely ignorant when it comes to ASP.NET. > >IT told me that I could publish my test projects to http://intranet/artestweb >and use my network login. When I start up Visual Studio and try to start a C# >ASP.NET Web Application, it tells me that the path >\\intranet\wwwroot$\artestweb\rallen\WebApplication1 either does not exist or >that I do not have access. When I ask IT about this, their response is "I took >a look at the folder and there is no directory rallen. Check to see if you >have a local version." > >They are being deliberately difficult. I have no idea how to create the >directory, where it is on our file system, anything. Trying to create a local >project, i.e. on the filesystem of my work station results in an error that >says that the file path and URL do not map to the same server location. I >simply don't understand (yet) what I need to do. Earlier in this mess, they >asked if I had made a DNS. Well, yes, I have a DNS that supposedly connects to >the Intranet database, but it, too, does not like my username/password. > >If someone could explain what I should be looking for, or what I should ask, >or anything at all that would let me deal with this situation from a position >of just a little more strength, I would surely appreciate it. > >Thanks, > >Ron > > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > > > -- Marty Connelly Victoria, B.C. Canada From martyconnelly at shaw.ca Fri Jan 14 13:11:01 2005 From: martyconnelly at shaw.ca (MartyConnelly) Date: Fri, 14 Jan 2005 11:11:01 -0800 Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) References: Message-ID: <41E81945.8030801@shaw.ca> There is an mskb on this PRB: Remote ASP.NET Projects Require IIS on the Client Computer or FrontPage Server Extensions on the Server Computer http://www.kbalertz.com/kb_320451.aspx Eric Barro wrote: >Ron, > >Visual Studio uses FrontPage server extensions to publish to a web site. This means that your local wwwroot folder needs to match up with the remote wwwroot folder or else you won't be able to publish your app to the remote web server using VS.NET. Instead you will have to settle for the old FTP approach using an FTP client. > >Basically when you use VS.NET you just need to point the project to a local folder on your machine. It will of course expect you to be running a web server on your local machine since it will take care of creating the virtual folder on the web server root folder. > >For example: app name = MyApp > >This translates to the physical location (assuming you have IIS defaults) = C:\INETPUB\WWWROOT\MYAPP\ > >Your project files will then be saved to this physical location. The DLL for the web app will be in C:\INETPUB\WWWROOT\MYAPP\BIN\ > >VS.NET will try to publish your app to the remote web server by first trying to create a virtual folder called MyApp on the web server root. If it can't do that then you will need to use manual FTP methods to publish it to F:\INETPUB\WWWROOT\MYAPP\ (assuming that F:\INETPUB\WWWROOT\ *is* the remote web server root). > >When you publish your app you just need to copy over the ASPX page and the DLL to the MYAPP and MYAPP\BIN folder respectively. The .NET framework will recognize a compiled version (DLL) of your app and run it accordingly. > >Hope this helps. > >Eric > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of >chizotz at mchsi.com >Sent: Friday, January 14, 2005 10:18 AM >To: dba-sqlserver at databaseadvisors.com >Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) > > >Apologies if this is completely OT. > >I've been told that as a company we would like to start moving to ASP.NET >applications rather than Windows Forms applications. Windows forms apps I >know, and have been doing for years. I have never done anything with ASP. The >IT department is being incredibly difficult about helping me get started. This >is political, they resent an "outsider" (i.e. a developer not in their >department) being able to do, well, anything. > >I'm not stupid, but I am almost completely ignorant when it comes to ASP.NET. > >IT told me that I could publish my test projects to http://intranet/artestweb >and use my network login. When I start up Visual Studio and try to start a C# >ASP.NET Web Application, it tells me that the path >\\intranet\wwwroot$\artestweb\rallen\WebApplication1 either does not exist or >that I do not have access. When I ask IT about this, their response is "I took >a look at the folder and there is no directory rallen. Check to see if you >have a local version." > >They are being deliberately difficult. I have no idea how to create the >directory, where it is on our file system, anything. Trying to create a local >project, i.e. on the filesystem of my work station results in an error that >says that the file path and URL do not map to the same server location. I >simply don't understand (yet) what I need to do. Earlier in this mess, they >asked if I had made a DNS. Well, yes, I have a DNS that supposedly connects to >the Intranet database, but it, too, does not like my username/password. > >If someone could explain what I should be looking for, or what I should ask, >or anything at all that would let me deal with this situation from a position >of just a little more strength, I would surely appreciate it. > >Thanks, > >Ron > > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > > > ---------------------------------------------------------------- >The information contained in this e-mail message and any file, document, previous e-mail message and/or attachment transmitted >herewith is confidential and may be legally privileged. It is intended solely for the private use of the addressee and must not be >disclosed to or used by anyone other than the addressee. If you receive this transmission by error, please immediately notify the >sender by reply e-mail and destroy the original transmission and its attachments without reading or saving it in any manner. If you >are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that any >disclosure, copying, distribution or use of any of the information contained in or attached to this transmission is STRICTLY >PROHIBITED. E-mail transmission cannot be guaranteed to be secure or error free as information could be intercepted, corrupted, >lost, destroyed, arrive late or incomplete, or contain viruses. >The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of >email transmission. Users and employees of the e-mail system are expressly required not to make defamatory statements and not >to infringe or authorize any infringement of copyright or any other legal right by email communications. Any such communication is >contrary to company policy. The company will not accept any liability in respect of such communication. > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > > > -- Marty Connelly Victoria, B.C. Canada From chizotz at mchsi.com Fri Jan 14 13:22:46 2005 From: chizotz at mchsi.com (chizotz at mchsi.com) Date: Fri, 14 Jan 2005 19:22:46 +0000 Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) Message-ID: <011420051922.3667.7b01@mchsi.com> Thanks Marty, I'll look at the links you sent. And I'll be looking for ASP specific mailing lists too. Ron > Here are a slew of asp and asp.net advice mailing lists. Also look > through blogs. > http://aspadvice.com/ > Tell them your client and server configuation ie. framework, iis version > and os. > > If you are running remotely you may need IIS installed on your machine > to support ADSI > This was an old problem maybe fixed and no longer valid. > Install IIS first then ASP framework this caused problems a few years > back maybe fixed. > > > If you are just starting out here are some templates and wizards. > The new version of ASP.NET Web Matrix wizard > http://www.asp.net/Default.aspx?tabindex=0&tabid=1 > how to use web matrix > http://doc.advisor.com/Articles.nsf/nl/13647 > Jump Start Your Web Site Development with the ASP.NET Starter Kits > http://msdn.microsoft.com/msdnmag/issues/03/08/StarterKits/default.aspx > > chizotz at mchsi.com wrote: > > >Apologies if this is completely OT. > > > >I've been told that as a company we would like to start moving to ASP.NET > >applications rather than Windows Forms applications. Windows forms apps I > >know, and have been doing for years. I have never done anything with ASP. The > >IT department is being incredibly difficult about helping me get started. This > >is political, they resent an "outsider" (i.e. a developer not in their > >department) being able to do, well, anything. > > > >I'm not stupid, but I am almost completely ignorant when it comes to ASP.NET. > > > >IT told me that I could publish my test projects to http://intranet/artestweb > >and use my network login. When I start up Visual Studio and try to start a C# > >ASP.NET Web Application, it tells me that the path > >\\intranet\wwwroot$\artestweb\rallen\WebApplication1 either does not exist or > >that I do not have access. When I ask IT about this, their response is "I took > >a look at the folder and there is no directory rallen. Check to see if you > >have a local version." > > > >They are being deliberately difficult. I have no idea how to create the > >directory, where it is on our file system, anything. Trying to create a local > >project, i.e. on the filesystem of my work station results in an error that > >says that the file path and URL do not map to the same server location. I > >simply don't understand (yet) what I need to do. Earlier in this mess, they > >asked if I had made a DNS. Well, yes, I have a DNS that supposedly connects to > >the Intranet database, but it, too, does not like my username/password. > > > >If someone could explain what I should be looking for, or what I should ask, > >or anything at all that would let me deal with this situation from a position > >of just a little more strength, I would surely appreciate it. > > > >Thanks, > > > >Ron > > > > > > > > > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > > > > > > > > -- > Marty Connelly > Victoria, B.C. > Canada > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From serbach at new.rr.com Fri Jan 14 16:15:20 2005 From: serbach at new.rr.com (Steven W. Erbach) Date: Fri, 14 Jan 2005 16:15:20 -0600 Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) In-Reply-To: <011420051818.15968.4c8d@mchsi.com> References: <011420051818.15968.4c8d@mchsi.com> Message-ID: <20050114161520.1164571752.serbach@new.rr.com> Ron, I feel your pain. The IT departments have learned over the years of PC domination that they'd better hold their cards closer to the vest. I can't answer your questions directly, but maybe my indirect answers will be of help and the folks that know more than me can make it more official-sounding. I'm writing an ASP.NET application using a SQL Server 2000 back end. I've installed the .NET Framework and IIS on my system along with all the other .NET stuff (about 1.5 GB of it!) that came with Visual Studio .NET 2003. When I'm developing the application on my workstation I can, of course, test and debug it using the full-bore SQL Server connection. My client uses CrystalTech as his web host and SQL Server host and it works out well. But when I publish the application to the target web site, I just use WS_FTP Pro and copy it to a folder off of his root directory. I KNOW that the path isn't the same as the one on my PC; but that doesn't seem to affect the application. As I say, I've just copied the files and Front Page folders to the application directory. Then I used the CrystalTech IIS management tool to designate that folder as an Application Starting Point, they call it. I believe that's a virtual directory. The path for the app on my system is C:\Inetpub\wwwroot\Myapp\Myapp. On the CrystalTech site it's D:\inetpub\Userweb\Myapp. I hope that helps. And good luck moving to ASP.NET. I think that the more you've worked with creating your own classes the better off you'll be. Of course, SQL Server stuff is de rigeur. There's lots to learn about the way ASP.NET handles web pages and "state" and server memory. Steve Erbach Neenah, WI > ------------Original Message------------ > From: chizotz at mchsi.com > To: dba-sqlserver at databaseadvisors.com > Date: Fri, Jan-14-2005 3:51 PM > Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) > > Apologies if this is completely OT. > > I've been told that as a company we would like to start moving to > ASP.NET > applications rather than Windows Forms applications. Windows forms apps > I > know, and have been doing for years. I have never done anything with > ASP. The > IT department is being incredibly difficult about helping me get > started. This > is political, they resent an "outsider" (i.e. a developer not in their > department) being able to do, well, anything. > > I'm not stupid, but I am almost completely ignorant when it comes to > ASP.NET. > > IT told me that I could publish my test projects to > http://intranet/artestweb > and use my network login. When I start up Visual Studio and try to > start a C# > ASP.NET Web Application, it tells me that the path > \\intranet\wwwroot$\artestweb\rallen\WebApplication1 either does not > exist or > that I do not have access. When I ask IT about this, their response is > "I took > a look at the folder and there is no directory rallen. Check to see if > you > have a local version." > > They are being deliberately difficult. I have no idea how to create the > > directory, where it is on our file system, anything. Trying to create a > local > project, i.e. on the filesystem of my work station results in an error > that > says that the file path and URL do not map to the same server location. > I > simply don't understand (yet) what I need to do. Earlier in this mess, > they > asked if I had made a DNS. Well, yes, I have a DNS that supposedly > connects to > the Intranet database, but it, too, does not like my username/password. > > If someone could explain what I should be looking for, or what I should > ask, > or anything at all that would let me deal with this situation from a > position > of just a little more strength, I would surely appreciate it. > > Thanks, > > Ron From chizotz at mchsi.com Sun Jan 16 23:17:58 2005 From: chizotz at mchsi.com (Ron Allen) Date: Sun, 16 Jan 2005 23:17:58 -0600 Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) In-Reply-To: References: <011420051818.15968.4c8d@mchsi.com> Message-ID: <977891691.20050116231758@mchsi.com> Hello Eric, That is helpful, thanks for the reply. Ron Friday, January 14, 2005, 12:54:05 PM, you wrote: EB> Ron, EB> Visual Studio uses FrontPage server extensions to publish to EB> a web site. This means that your local wwwroot folder needs to EB> match up with the remote wwwroot folder or else you won't be able EB> to publish your app to the remote web server using VS.NET. Instead EB> you will have to settle for the old FTP approach using an FTP EB> client. From chizotz at mchsi.com Sun Jan 16 23:19:23 2005 From: chizotz at mchsi.com (Ron Allen) Date: Sun, 16 Jan 2005 23:19:23 -0600 Subject: [dba-SQLServer] Starting an ASP.NET Project (may be OT) In-Reply-To: <20050114161520.1164571752.serbach@new.rr.com> References: <011420051818.15968.4c8d@mchsi.com> <20050114161520.1164571752.serbach@new.rr.com> Message-ID: <1008586529.20050116231923@mchsi.com> Hello Steven, Yep, it's a pain. I appreciate the reply. I'm still working on it, and I know I have a long way to go with it. Ron Friday, January 14, 2005, 4:15:20 PM, you wrote: SWE> Ron, I feel your pain. The IT departments have learned over the SWE> years of PC domination that they'd better hold their cards closer SWE> to the vest. From jeffrey.demulling at usbank.com Wed Jan 19 15:00:01 2005 From: jeffrey.demulling at usbank.com (jeffrey.demulling at usbank.com) Date: Wed, 19 Jan 2005 15:00:01 -0600 Subject: [dba-SQLServer] SQL "CROSS TAB" Message-ID: Using the sql below I need to create a "cross tab" that looks like this: Office ;TR Category ;0-30;31-60;61;90;91+ Office1;Category1;0;0;1;5 Office1;Category3;1;0;4;0 Office2;Category5;7;0;6;10 Any and all help would be appreciated as I am at a complete loss. Thank you in advance. SELECT tblRegions.Name AS RegionName, tblOffices.Name AS OfficeName, tblNames_1.Name AS [AM Name], tblNames_2.Name AS [NS Name], tblNames.Name AS [ASU Name], tblProductTypes.Name AS ProductCodeName, tblProductTypes.[TR Category], [Aging Category - CDR Setup Status] = CASE WHEN [tblDeals].[Deal Status] <> 3 THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Done] IS NOT NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NOT NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN CASE WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<31 THEN '0-30' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<61 THEN '31-60' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<91 THEN '61-90' Else '91+' End End End End End FROM tblDeals LEFT JOIN tblNames ON tblDeals.[Account Set Up Person Key] = tblNames.Number LEFT JOIN tblNames AS tblNames_1 ON tblDeals.[Relationship Specialist Key] = tblNames_1.Number LEFT JOIN tblNames AS tblNames_2 ON tblDeals.[Negotiation Specialist Key] = tblNames_2.Number LEFT JOIN tblProductTypes ON tblDeals.[Product Code] = tblProductTypes.Number LEFT JOIN tblOffices ON tblDeals.Office = tblOffices.Number LEFT JOIN tblRegions ON tblOffices.Region = tblRegions.Number WHERE CASE WHEN [tblDeals].[Deal Status] <> 3 THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Done] IS NOT NULL THEN 'Complete' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN 'Due Date Not Set' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NOT NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN CASE WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<61 THEN 'Open' Else 'Past Due' End End End End End IN ('Open', 'Past Due') ------------------------------------------------------------------------------ Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation. ============================================================================== From jeffrey.demulling at usbank.com Thu Jan 20 08:43:59 2005 From: jeffrey.demulling at usbank.com (jeffrey.demulling at usbank.com) Date: Thu, 20 Jan 2005 08:43:59 -0600 Subject: [dba-SQLServer] SQL "CROSS TAB" - Solved In-Reply-To: Message-ID: I figured it out last night at home. Here is my solution SELECT tempReport1.*, (tempReport1.[0-31]+ tempReport1.[31-60] + tempReport1.[61-90]+ tempReport1.[91+]) AS RowTotal FROM(SELECT tempReport.OfficeName, tempReport.[TR Category], SUM(CASE [Aging Category - CDR Setup Status] WHEN '0-30' THEN CountofAging ELSE 0 END) AS '0-31', SUM(CASE [Aging Category - CDR Setup Status] WHEN '31-60' THEN CountofAging ELSE 0 END) AS '31-60', SUM(CASE [Aging Category - CDR Setup Status] WHEN '61-90' THEN CountofAging ELSE 0 END) AS '61-90', SUM(CASE [Aging Category - CDR Setup Status] WHEN '91+' THEN CountofAging ELSE 0 END) AS '91+' FROM (SELECT tblOffices.Name AS OfficeName, tblProductTypes.[TR Category], [Aging Category - CDR Setup Status] = CASE WHEN [tblDeals].[Deal Status] <> 3 THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Done] IS NOT NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NOT NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN CASE WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<31 THEN '0-30' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<61 THEN '31-60' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<91 THEN '61-90' Else '91+' End End End End End, COUNT(CASE WHEN [tblDeals].[Deal Status] <> 3 THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Done] IS NOT NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NOT NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN CASE WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<31 THEN '0-30' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<61 THEN '31-60' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<91 THEN '61-90' Else '91+' End End End End End) AS CountofAging FROM tblDeals LEFT JOIN tblProductTypes ON tblDeals.[Product Code] = tblProductTypes.Number LEFT JOIN tblOffices ON tblDeals.Office = tblOffices.Number WHERE CASE WHEN [tblDeals].[Deal Status] <> 3 THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Done] IS NOT NULL THEN 'Complete' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN 'Due Date Not Set' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NOT NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN CASE WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<61 THEN 'Open' Else 'Past Due' End End End End End IN ('Open', 'Past Due') GROUP BY tblOffices.Name, tblProductTypes.[TR Category], CASE WHEN [tblDeals].[Deal Status] <> 3 THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Done] IS NOT NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NOT NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN CASE WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<31 THEN '0-30' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<61 THEN '31-60' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<91 THEN '61-90' Else '91+' End End End End End ) AS tempReport GROUP BY tempReport.OfficeName, tempReport.[TR Category]) as tempReport1 jeffrey.demulling @usbank.com Sent by: To dba-sqlserver-bou dba-sqlserver at databaseadvisors.com nces at databaseadvi cc sors.com Subject [dba-SQLServer] SQL "CROSS TAB" 01/19/2005 03:00 PM Please respond to dba-sqlserver at dat abaseadvisors.com Using the sql below I need to create a "cross tab" that looks like this: Office ;TR Category ;0-30;31-60;61;90;91+ Office1;Category1;0;0;1;5 Office1;Category3;1;0;4;0 Office2;Category5;7;0;6;10 Any and all help would be appreciated as I am at a complete loss. Thank you in advance. SELECT tblRegions.Name AS RegionName, tblOffices.Name AS OfficeName, tblNames_1.Name AS [AM Name], tblNames_2.Name AS [NS Name], tblNames.Name AS [ASU Name], tblProductTypes.Name AS ProductCodeName, tblProductTypes.[TR Category], [Aging Category - CDR Setup Status] = CASE WHEN [tblDeals].[Deal Status] <> 3 THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Done] IS NOT NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NOT NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN CASE WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<31 THEN '0-30' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<61 THEN '31-60' WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<91 THEN '61-90' Else '91+' End End End End End FROM tblDeals LEFT JOIN tblNames ON tblDeals.[Account Set Up Person Key] = tblNames.Number LEFT JOIN tblNames AS tblNames_1 ON tblDeals.[Relationship Specialist Key] = tblNames_1.Number LEFT JOIN tblNames AS tblNames_2 ON tblDeals.[Negotiation Specialist Key] = tblNames_2.Number LEFT JOIN tblProductTypes ON tblDeals.[Product Code] = tblProductTypes.Number LEFT JOIN tblOffices ON tblDeals.Office = tblOffices.Number LEFT JOIN tblRegions ON tblOffices.Region = tblRegions.Number WHERE CASE WHEN [tblDeals].[Deal Status] <> 3 THEN 'N/A' Else CASE WHEN [tblDeals].[CDR Setup Done] IS NOT NULL THEN 'Complete' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN 'Due Date Not Set' Else CASE WHEN [tblDeals].[CDR Setup Due] IS NOT NULL AND [tblDeals].[CDR Setup Done] IS NULL THEN CASE WHEN DATEDIFF(DAY,[tblDeals].[Actual Close Date], GETDATE())<61 THEN 'Open' Else 'Past Due' End End End End End IN ('Open', 'Past Due') ------------------------------------------------------------------------------ Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation. ============================================================================== _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com ------------------------------------------------------------------------------ Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation. ============================================================================== ------------------------------------------------------------------------------ Electronic Privacy Notice. This e-mail, and any attachments, contains information that is, or may be, covered by electronic communications privacy laws, and is also confidential and proprietary in nature. If you are not the intended recipient, please be advised that you are legally prohibited from retaining, using, copying, distributing, or otherwise disclosing this information in any manner. Instead, please reply to the sender that you have received this communication in error, and then immediately delete it. Thank you in advance for your cooperation. ============================================================================== From Clay.Passick at minneapolis.edu Thu Jan 20 14:24:24 2005 From: Clay.Passick at minneapolis.edu (Clay Passick) Date: Thu, 20 Jan 2005 14:24:24 -0600 Subject: [dba-SQLServer] unnormalize data Message-ID: Is there a way in SQL 2000 to unormalize data that exist. I have done this in MS Access but never with SQL. The fields are in the same table. I have used views to some extent but my experience with sprocs is rather limited. The data is being viewed on the web. The following is a quick example of what I would like to do. >From this: Objective Task A 1 A 2 B 1 B 2 B 3 To this: Objective Task A 1 2 or 1,2 B 1 2 3 or 1,2,3 TIA Clay From dmcafee at pacbell.net Thu Jan 20 17:08:11 2005 From: dmcafee at pacbell.net (dmcafee at pacbell.net) Date: Thu, 20 Jan 2005 15:08:11 -0800 Subject: [dba-SQLServer] unnormalize data In-Reply-To: Message-ID: This just kicked my butt yesterday:) I needed to sum up some adjustments and concatenate the reasons. This procedure using a loop and table variable work faster than a cursor (which is another way you could do this). Substitute my "AdjReason" with your "Task" my "MachineType" with your "Objective" my #tblTempMach with your table name Hope this helps. David DECLARE @RowCnt AS INT DECLARE @MaxRows AS INT DECLARE @AdjR AS VARCHAR(1000) SET @AdjR = '' SET @RowCnt = 1 --Initialize a table variable, basically SQL's version of an Array DECLARE @Temp Table (RowNum INT IDENTITY (1,1) PRIMARY KEY NOT NULL, Model VARCHAR(20) NULL, Notes VARCHAR(1000) NULL) --Insert records into the table variable by selecting them from some location INSERT INTO @Temp (Model) SELECT DISTINCT MachineType FROM #tblTempMach WHERE AdjReason IS NOT NULL --Count the number of rows so we no how many times we need to loop SELECT @MaxRows = COUNT(*) FROM @Temp WHILE @RowCnt <= @MaxRows BEGIN SELECT @AdjR = AdjReason + ', ' + @AdjR --This is the concatention FROM #tblTempMach INNER JOIN @Temp ON #tblTempMach.MachineType = Model WHERE AdjReason IS NOT NULL AND #tblTempMach.MachineType = model UPDATE @Temp SET Notes = @AdjR SET @AdjR ='' SET @RowCnt = @RowCnt + 1 END UPDATE @Temp SET Notes = LEFT(Notes, LEN(Notes)-1) SET NOCOUNT OFF --Select it all out at the end SELECT * FROM @Temp -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Clay Passick Sent: Thursday, January 20, 2005 12:24 PM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] unnormalize data Is there a way in SQL 2000 to unormalize data that exist. I have done this in MS Access but never with SQL. The fields are in the same table. I have used views to some extent but my experience with sprocs is rather limited. The data is being viewed on the web. The following is a quick example of what I would like to do. >From this: Objective Task A 1 A 2 B 1 B 2 B 3 To this: Objective Task A 1 2 or 1,2 B 1 2 3 or 1,2,3 TIA Clay From jwcolby at colbyconsulting.com Thu Jan 20 19:45:17 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Thu, 20 Jan 2005 20:45:17 -0500 Subject: [dba-SQLServer] Keys and indexes in MySQL Message-ID: <001801c4ff5a$df39c060$677aa8c0@ColbyM6805> Can anyone tell me if creating an index on a field in MySQL causes it to be a "key" in their documentation or by their definition? It seems unlikely but given the nebulous definition of a key to start with, who knows? John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ From jwcolby at colbyconsulting.com Fri Jan 21 23:31:45 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Sat, 22 Jan 2005 00:31:45 -0500 Subject: [dba-SQLServer] Adding indexes on fields In-Reply-To: <41C1F428.6010407@shaw.ca> Message-ID: <006b01c50043$a96255d0$677aa8c0@ColbyM6805> Does anyone know whether it is faster to add many indexes to a table all at once or each index one at a time? I have tables where I need to index every field. I am looking at writing TSQL code to add indexes and just need to know if I can do all the fields simultaneously, and if so is it slower or faster than doing so one at a time. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ From accessd at shaw.ca Sat Jan 22 00:31:12 2005 From: accessd at shaw.ca (Jim Lawrence) Date: Fri, 21 Jan 2005 22:31:12 -0800 Subject: [dba-SQLServer] Adding indexes on fields In-Reply-To: <006b01c50043$a96255d0$677aa8c0@ColbyM6805> Message-ID: <0IAP00JAKGQUWT@l-daemon> Hi John: That of course depends on how must data you are working with.... How many GBs... I do not think there is any faster way but if faced with the problem of a huge DB, I would set them all a once, after checking to see if there was plenty of hard drive space, set them all and go to bed... and everything will be done by the morning, next or some other. I recently heard of some MS fellow who was working on some gargantuan multi-partitioned OLAP SQL farm and adding the indexing took five days. So anything under that is just bonus. My two cents worth Jim -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of John W. Colby Sent: Friday, January 21, 2005 9:32 PM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Adding indexes on fields Does anyone know whether it is faster to add many indexes to a table all at once or each index one at a time? I have tables where I need to index every field. I am looking at writing TSQL code to add indexes and just need to know if I can do all the fields simultaneously, and if so is it slower or faster than doing so one at a time. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From tuxedo_man at hotmail.com Sat Jan 22 01:41:40 2005 From: tuxedo_man at hotmail.com (Billy Pang) Date: Sat, 22 Jan 2005 07:41:40 +0000 Subject: [dba-SQLServer] Adding indexes on fields In-Reply-To: <006b01c50043$a96255d0$677aa8c0@ColbyM6805> Message-ID: Not sure what you mean by adding indexes one at a time or all at once. Do you mean doing the index creation on same table using one connection or multiple connection simultaneously? >From: "John W. Colby" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: [dba-SQLServer] Adding indexes on fields >Date: Sat, 22 Jan 2005 00:31:45 -0500 > >Does anyone know whether it is faster to add many indexes to a table all at >once or each index one at a time? > >I have tables where I need to index every field. I am looking at writing >TSQL code to add indexes and just need to know if I can do all the fields >simultaneously, and if so is it slower or faster than doing so one at a >time. > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > > >_______________________________________________ >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 Jan 23 12:22:09 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Sun, 23 Jan 2005 13:22:09 -0500 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: Message-ID: <000f01c50178$73940170$677aa8c0@ColbyM6805> I believe I have seen references to placing indexes in a specific file for SQL Server in order to speed up the database. Does anyone know how this might be accomplished (if possible)? For my nVLDB I now have 685 gb of data in 4 files, each file on a dedicated hard drive, i.e. nothing on that drive except that one database file. I also have a dedicated drive for the log file. I am reaching the point where I need to add a couple of more drives (and files) because I will run out of room in a few weeks. It seems like now might be the time to figure out the index file thing if it is possible. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ From jwcolby at colbyconsulting.com Sun Jan 23 12:47:45 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Sun, 23 Jan 2005 13:47:45 -0500 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: <000f01c50178$73940170$677aa8c0@ColbyM6805> Message-ID: <001001c5017c$07591be0$677aa8c0@ColbyM6805> On the same note, is it possible to cause specific tables to be placed in specific files? I started this database with two 250g hard drives for the data and one 250g hard drive for the log file. As I ran short of room in the data files (hard drives) I added a new drive and another file, then a fourth drive and file. I have at this time 4 data drives each with a single data file, and a log drive with a log file. Each of these drives has nothing but the SQL Server file on it. I started out with the "big table" of 64 million records, 650 fields. Since the business requires using almost every field in where clauses, I added a PK field that is an Int - Identity - Increment 1. I then started creating smaller tables with anywhere from a handful to several dozen fields of related data. I copied the PK and these fields (data) from the Big Table into the smaller tables, then set indexes on each field. This work is not complete yet, but I have almost finished creating tables to hold all the sets of related data. Just as an aside, it takes a few hours to pull the PK and data out of BigTable and drop it into the smaller table. I can run many of these at the same time (do several of the smaller tables at the same time). Setting up the indexes takes a few minutes to create the indexes in design view, then a LONG time (many hours) for SQL Server to actually build the indexes. The more fields I index at once the longer it takes of course. I can just imagine what the data looks like inside the four data files though. I was thinking that if I could "copy" a specific table from the database into a new file, that the copy might "defrag" that table (get all the data and indexes for it in one place and contiguous). Additionally it would be good from a performance perspective to get each of these smaller tables into a single drive (file) so that later when I started joining the tables for analysis (where clauses) I would spread the i/o over more drives. Any thoughts on this stuff? Is it possible to determine placement of tables within a multi-file database? Ditto indexes? John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of John W. Colby Sent: Sunday, January 23, 2005 1:22 PM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Placing indexes in a specific file I believe I have seen references to placing indexes in a specific file for SQL Server in order to speed up the database. Does anyone know how this might be accomplished (if possible)? For my nVLDB I now have 685 gb of data in 4 files, each file on a dedicated hard drive, i.e. nothing on that drive except that one database file. I also have a dedicated drive for the log file. I am reaching the point where I need to add a couple of more drives (and files) because I will run out of room in a few weeks. It seems like now might be the time to figure out the index file thing if it is possible. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From tuxedo_man at hotmail.com Sun Jan 23 13:56:35 2005 From: tuxedo_man at hotmail.com (Billy Pang) Date: Sun, 23 Jan 2005 19:56:35 +0000 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: <001001c5017c$07591be0$677aa8c0@ColbyM6805> Message-ID: Hi John: To improve disk I/O performance, place data of table and its indexes in separate data files (because less contention for disk resources given the way data is accessed on disk). The syntax for creating index on specific filegroup is: "BOL Syntax" CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) [ WITH < index_option > [ ,...n] ] [ ON filegroup ] For example: create index ix_myindex on products(product_name) on secondary_file_group; To store the table in a specific data file, use the ON filegroup at the end of CREATE TABLE statement or create a clustered index of that table in the target filegroup. The data of a table resides in the same filegroup as its clustered index. Note: each db has default filegroup. If you don't specify specific filegroup when you create index/table, then that is where the index/table will reside. Always create your clustered index first before creating your nonclustered indexes of a table. This is because physical key in nonclusterd indexes is composed of the clustered index key. If you create nonclustered index first, and then clustered index, the db will need to rebuild existing nonclusterd indexes of that table (argh!). Sometimes an existing index on a table helps speed up creation of other indexes on the table. HTH Billy >From: "John W. Colby" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file >Date: Sun, 23 Jan 2005 13:47:45 -0500 > >On the same note, is it possible to cause specific tables to be placed in >specific files? I started this database with two 250g hard drives for the >data and one 250g hard drive for the log file. As I ran short of room in >the data files (hard drives) I added a new drive and another file, then a >fourth drive and file. I have at this time 4 data drives each with a >single >data file, and a log drive with a log file. Each of these drives has >nothing but the SQL Server file on it. > >I started out with the "big table" of 64 million records, 650 fields. >Since >the business requires using almost every field in where clauses, I added a >PK field that is an Int - Identity - Increment 1. I then started creating >smaller tables with anywhere from a handful to several dozen fields of >related data. I copied the PK and these fields (data) from the Big Table >into the smaller tables, then set indexes on each field. This work is not >complete yet, but I have almost finished creating tables to hold all the >sets of related data. Just as an aside, it takes a few hours to pull the >PK >and data out of >BigTable and drop it into the smaller table. I can run many of these at >the >same time (do several of the smaller tables at the same time). Setting up >the indexes takes a few minutes to create the indexes in design view, then >a >LONG time (many hours) for SQL Server to actually build the indexes. The >more fields I index at once the longer it takes of course. > >I can just imagine what the data looks like inside the four data files >though. I was thinking that if I could "copy" a specific table from the >database into a new file, that the copy might "defrag" that table (get all >the data and indexes for it in one place and contiguous). > >Additionally it would be good from a performance perspective to get each of >these smaller tables into a single drive (file) so that later when I >started >joining the tables for analysis (where clauses) I would spread the i/o over >more drives. > >Any thoughts on this stuff? Is it possible to determine placement of >tables >within a multi-file database? Ditto indexes? > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of John W. >Colby >Sent: Sunday, January 23, 2005 1:22 PM >To: dba-sqlserver at databaseadvisors.com >Subject: [dba-SQLServer] Placing indexes in a specific file > > >I believe I have seen references to placing indexes in a specific file for >SQL Server in order to speed up the database. Does anyone know how this >might be accomplished (if possible)? For my nVLDB I now have 685 gb of >data >in 4 files, each file on a dedicated hard drive, i.e. nothing on that drive >except that one database file. I also have a dedicated drive for the log >file. I am reaching the point where I need to add a couple of more drives >(and files) because I will run out of room in a few weeks. It seems like >now might be the time to figure out the index file thing if it is possible. > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > > > >_______________________________________________ >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 tuxedo_man at hotmail.com Sun Jan 23 14:00:03 2005 From: tuxedo_man at hotmail.com (Billy Pang) Date: Sun, 23 Jan 2005 20:00:03 +0000 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: Message-ID: ooops.. typo in last email... instead of "BOL syntax", it should have read "BNF Syntax from BOL"? >From: "Billy Pang" >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file >Date: Sun, 23 Jan 2005 19:56:35 +0000 > >Hi John: > >To improve disk I/O performance, place data of table and its indexes in >separate data files (because less contention for disk resources given the >way data is accessed on disk). > >The syntax for creating index on specific filegroup is: > >"BOL Syntax" >CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name > ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) >[ WITH < index_option > [ ,...n] ] >[ ON filegroup ] > >For example: >create index ix_myindex on products(product_name) on secondary_file_group; > >To store the table in a specific data file, use the ON filegroup at the end >of CREATE TABLE statement or create a clustered index of that table in the >target filegroup. The data of a table resides in the same filegroup as its >clustered index. > >Note: each db has default filegroup. If you don't specify specific >filegroup when you create index/table, then that is where the index/table >will reside. > >Always create your clustered index first before creating your nonclustered >indexes of a table. This is because physical key in nonclusterd indexes is >composed of the clustered index key. If you create nonclustered index >first, and then clustered index, the db will need to rebuild existing >nonclusterd indexes of that table (argh!). > >Sometimes an existing index on a table helps speed up creation of other >indexes on the table. > >HTH > >Billy > >>From: "John W. Colby" >>Reply-To: dba-sqlserver at databaseadvisors.com >>To: dba-sqlserver at databaseadvisors.com >>Subject: RE: [dba-SQLServer] Placing indexes in a specific file >>Date: Sun, 23 Jan 2005 13:47:45 -0500 >> >>On the same note, is it possible to cause specific tables to be placed in >>specific files? I started this database with two 250g hard drives for the >>data and one 250g hard drive for the log file. As I ran short of room in >>the data files (hard drives) I added a new drive and another file, then a >>fourth drive and file. I have at this time 4 data drives each with a >>single >>data file, and a log drive with a log file. Each of these drives has >>nothing but the SQL Server file on it. >> >>I started out with the "big table" of 64 million records, 650 fields. >>Since >>the business requires using almost every field in where clauses, I added a >>PK field that is an Int - Identity - Increment 1. I then started creating >>smaller tables with anywhere from a handful to several dozen fields of >>related data. I copied the PK and these fields (data) from the Big Table >>into the smaller tables, then set indexes on each field. This work is not >>complete yet, but I have almost finished creating tables to hold all the >>sets of related data. Just as an aside, it takes a few hours to pull the >>PK >>and data out of >>BigTable and drop it into the smaller table. I can run many of these at >>the >>same time (do several of the smaller tables at the same time). Setting up >>the indexes takes a few minutes to create the indexes in design view, then >>a >>LONG time (many hours) for SQL Server to actually build the indexes. The >>more fields I index at once the longer it takes of course. >> >>I can just imagine what the data looks like inside the four data files >>though. I was thinking that if I could "copy" a specific table from the >>database into a new file, that the copy might "defrag" that table (get all >>the data and indexes for it in one place and contiguous). >> >>Additionally it would be good from a performance perspective to get each >>of >>these smaller tables into a single drive (file) so that later when I >>started >>joining the tables for analysis (where clauses) I would spread the i/o >>over >>more drives. >> >>Any thoughts on this stuff? Is it possible to determine placement of >>tables >>within a multi-file database? Ditto indexes? >> >>John W. Colby >>www.ColbyConsulting.com >> >>Contribute your unused CPU cycles to a good cause: >>http://folding.stanford.edu/ >> >>-----Original Message----- >>From: dba-sqlserver-bounces at databaseadvisors.com >>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of John W. >>Colby >>Sent: Sunday, January 23, 2005 1:22 PM >>To: dba-sqlserver at databaseadvisors.com >>Subject: [dba-SQLServer] Placing indexes in a specific file >> >> >>I believe I have seen references to placing indexes in a specific file for >>SQL Server in order to speed up the database. Does anyone know how this >>might be accomplished (if possible)? For my nVLDB I now have 685 gb of >>data >>in 4 files, each file on a dedicated hard drive, i.e. nothing on that >>drive >>except that one database file. I also have a dedicated drive for the log >>file. I am reaching the point where I need to add a couple of more drives >>(and files) because I will run out of room in a few weeks. It seems like >>now might be the time to figure out the index file thing if it is >>possible. >> >>John W. Colby >>www.ColbyConsulting.com >> >>Contribute your unused CPU cycles to a good cause: >>http://folding.stanford.edu/ >> >> >> >>_______________________________________________ >>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 jwcolby at colbyconsulting.com Sun Jan 23 14:49:17 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Sun, 23 Jan 2005 15:49:17 -0500 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: Message-ID: <001201c5018d$05ce9b90$677aa8c0@ColbyM6805> Billy, Thanks for the response. Unfortunately I have already created most of the tables, and in fact already moved the data into most of the tables. I created the tables by simply opening the big table in design view, selecting the fields I wanted in the smaller table, copying the fields to the paste buffer, creating a new table and pasting the fields in to the new table and saved. I then opened QA, did a "Script object to new window as SELECT" , then "Script object to new window as INSERT", cut the select statement and pasted it into the VALUES clause of the insert, and finally ran the insert statement. Quick and easy. The data gets moved from the BigTable to the new table in a couple of hours (depending on how many I run simultaneously). I then go in to each small table and build the indexes manually. Close and save the table and the tables are built. As you can see I never used a SQL statement for any of this. It is very fast to do it manually, and that process of building the smaller tables is almost complete. I do still have to index about half of the smaller tables, but because of the data in them I don't create clustered indexes. Thus I need to know if I can take an existing table and move it to a specific file. I suppose I could a INSERT INTO NEWSmallTable SELECT * FROM SmallTable ON NEWFileGroup? That would copy the existing small tables I have created to the new file? I must admit that I am confused about the concept of FileGroup. AFAICT all of the files I currently have are in one file group. Thus using an On FILEGROUP would only get it into the set of 4 files, not into a specific file of that file group. Do I need to create a new file on a new drive, make it a new file group?, Then a new file on a second disk, making it a different filegroup? Repeat until all files are in a different filegroup? This all seems terribly cumbersome. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang Sent: Sunday, January 23, 2005 2:57 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Placing indexes in a specific file Hi John: To improve disk I/O performance, place data of table and its indexes in separate data files (because less contention for disk resources given the way data is accessed on disk). The syntax for creating index on specific filegroup is: "BOL Syntax" CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) [ WITH < index_option > [ ,...n] ] [ ON filegroup ] For example: create index ix_myindex on products(product_name) on secondary_file_group; To store the table in a specific data file, use the ON filegroup at the end of CREATE TABLE statement or create a clustered index of that table in the target filegroup. The data of a table resides in the same filegroup as its clustered index. Note: each db has default filegroup. If you don't specify specific filegroup when you create index/table, then that is where the index/table will reside. Always create your clustered index first before creating your nonclustered indexes of a table. This is because physical key in nonclusterd indexes is composed of the clustered index key. If you create nonclustered index first, and then clustered index, the db will need to rebuild existing nonclusterd indexes of that table (argh!). Sometimes an existing index on a table helps speed up creation of other indexes on the table. HTH Billy >From: "John W. Colby" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file >Date: Sun, 23 Jan 2005 13:47:45 -0500 > >On the same note, is it possible to cause specific tables to be placed >in specific files? From tuxedo_man at hotmail.com Sun Jan 23 15:50:43 2005 From: tuxedo_man at hotmail.com (Billy Pang) Date: Sun, 23 Jan 2005 21:50:43 +0000 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: <001201c5018d$05ce9b90$677aa8c0@ColbyM6805> Message-ID: Hi John: To move a table from one filegroup to another, from EM, go into design view of the table, bring up properties. on the first tab ("tables"), the third last dropdown list is table filegroup. You can use this dropdown list to move table from one filegroup to another. When you move tables from one filegroup to another, this is what EM does is recreate a temporarily copy of the table in the target filegroup, copy over data, drop old table and rename new one. You can also move indexes from one filegroup to another via same way (ie. table properties, indexes/keys, index filegroup dropdown list). Filegroups is just a way of organizing your data files. Filegroups consist of physical data files. AFAIK, I don't think it is possible to put data of a table in a specific physical data file (you can only put table into file group. sql server does the rest). For performance reasons, in a single filegroup, it is recommended that your physical data files are spread out over multiple disks. That way all disks can work simultaneously at once to get your data for a single table. Not sure what is the question "Do I need to create a new file on a new drive, make it a new file group?, Then a new file on a second disk, making it a different filegroup? Repeat until all files are in a different filegroup? This all seems terribly cumbersome." I believe that you can add more new data files (on a new disk) to an existing filegroup if you run out of space on the disks on the existing data files. I don't remember how SQL Server allocates the data to the physical data files. (ie. if filegroup has multiple data files, when you insert a record into table within that filegroup, which data file is the record physically stored in?). I don't have my sql server book with me so maybe somebody else knows. HTH Billy >From: "John W. Colby" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file >Date: Sun, 23 Jan 2005 15:49:17 -0500 > >Billy, > >Thanks for the response. Unfortunately I have already created most of the >tables, and in fact already moved the data into most of the tables. I >created the tables by simply opening the big table in design view, >selecting >the fields I wanted in the smaller table, copying the fields to the paste >buffer, creating a new table and pasting the fields in to the new table and >saved. I then opened QA, did a "Script object to new window as SELECT" >, then "Script object to new window as INSERT", cut the select statement >and >pasted it into the VALUES clause of the insert, and finally ran the insert >statement. Quick and easy. The data gets moved from the BigTable to the >new table in a couple of hours (depending on how many I run >simultaneously). >I then go in to each small table and build the indexes manually. Close and >save the table and the tables are built. > >As you can see I never used a SQL statement for any of this. It is very >fast to do it manually, and that process of building the smaller tables is >almost complete. I do still have to index about half of the smaller >tables, >but because of the data in them I don't create clustered indexes. > >Thus I need to know if I can take an existing table and move it to a >specific file. I suppose I could a INSERT INTO NEWSmallTable SELECT * FROM >SmallTable ON NEWFileGroup? That would copy the existing small tables I >have created to the new file? > >I must admit that I am confused about the concept of FileGroup. AFAICT all >of the files I currently have are in one file group. Thus using an On >FILEGROUP would only get it into the set of 4 files, not into a specific >file of that file group. > >Do I need to create a new file on a new drive, make it a new file group?, >Then a new file on a second disk, making it a different filegroup? Repeat >until all files are in a different filegroup? This all seems terribly >cumbersome. > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang >Sent: Sunday, January 23, 2005 2:57 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > > >Hi John: > >To improve disk I/O performance, place data of table and its indexes in >separate data files (because less contention for disk resources given the >way data is accessed on disk). > >The syntax for creating index on specific filegroup is: > >"BOL Syntax" >CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name > ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) >[ WITH < index_option > [ ,...n] ] >[ ON filegroup ] > >For example: >create index ix_myindex on products(product_name) on secondary_file_group; > >To store the table in a specific data file, use the ON filegroup at the end >of CREATE TABLE statement or create a clustered index of that table in the >target filegroup. The data of a table resides in the same filegroup as its >clustered index. > >Note: each db has default filegroup. If you don't specify specific >filegroup when you create index/table, then that is where the index/table >will reside. > >Always create your clustered index first before creating your nonclustered >indexes of a table. This is because physical key in nonclusterd indexes is >composed of the clustered index key. If you create nonclustered index >first, and then clustered index, the db will need to rebuild existing >nonclusterd indexes of that table (argh!). > >Sometimes an existing index on a table helps speed up creation of other >indexes on the table. > >HTH > >Billy > > >From: "John W. Colby" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > >Date: Sun, 23 Jan 2005 13:47:45 -0500 > > > >On the same note, is it possible to cause specific tables to be placed > >in specific files? > > >_______________________________________________ >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 Jan 23 17:06:49 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Sun, 23 Jan 2005 18:06:49 -0500 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: Message-ID: <001301c501a0$38441bf0$677aa8c0@ColbyM6805> Can a database be spread over more than one filegroup? If so, then I create a file group that is just a single file, i.e. filegroup1 is datafile1, filegroup2 is datafile2 etc. Then I can intentionally move a table to a specific filegroup and get it in a specific file (disk) John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang Sent: Sunday, January 23, 2005 4:51 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Placing indexes in a specific file Hi John: To move a table from one filegroup to another, from EM, go into design view of the table, bring up properties. on the first tab ("tables"), the third last dropdown list is table filegroup. You can use this dropdown list to move table from one filegroup to another. When you move tables from one filegroup to another, this is what EM does is recreate a temporarily copy of the table in the target filegroup, copy over data, drop old table and rename new one. You can also move indexes from one filegroup to another via same way (ie. table properties, indexes/keys, index filegroup dropdown list). Filegroups is just a way of organizing your data files. Filegroups consist of physical data files. AFAIK, I don't think it is possible to put data of a table in a specific physical data file (you can only put table into file group. sql server does the rest). For performance reasons, in a single filegroup, it is recommended that your physical data files are spread out over multiple disks. That way all disks can work simultaneously at once to get your data for a single table. Not sure what is the question "Do I need to create a new file on a new drive, make it a new file group?, Then a new file on a second disk, making it a different filegroup? Repeat until all files are in a different filegroup? This all seems terribly cumbersome." I believe that you can add more new data files (on a new disk) to an existing filegroup if you run out of space on the disks on the existing data files. I don't remember how SQL Server allocates the data to the physical data files. (ie. if filegroup has multiple data files, when you insert a record into table within that filegroup, which data file is the record physically stored in?). I don't have my sql server book with me so maybe somebody else knows. HTH Billy >From: "John W. Colby" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file >Date: Sun, 23 Jan 2005 15:49:17 -0500 > >Billy, > >Thanks for the response. Unfortunately I have already created most of >the tables, and in fact already moved the data into most of the tables. >I created the tables by simply opening the big table in design view, >selecting the fields I wanted in the smaller table, copying the fields >to the paste buffer, creating a new table and pasting the fields in to >the new table and saved. I then opened QA, did a "Script object to new >window as SELECT" , then "Script object to new window as INSERT", cut >the select statement and >pasted it into the VALUES clause of the insert, and finally ran the insert >statement. Quick and easy. The data gets moved from the BigTable to the >new table in a couple of hours (depending on how many I run >simultaneously). >I then go in to each small table and build the indexes manually. Close and >save the table and the tables are built. > >As you can see I never used a SQL statement for any of this. It is >very fast to do it manually, and that process of building the smaller >tables is almost complete. I do still have to index about half of the >smaller tables, but because of the data in them I don't create >clustered indexes. > >Thus I need to know if I can take an existing table and move it to a >specific file. I suppose I could a INSERT INTO NEWSmallTable SELECT * >FROM SmallTable ON NEWFileGroup? That would copy the existing small >tables I have created to the new file? > >I must admit that I am confused about the concept of FileGroup. AFAICT >all of the files I currently have are in one file group. Thus using an >On FILEGROUP would only get it into the set of 4 files, not into a >specific file of that file group. > >Do I need to create a new file on a new drive, make it a new file >group?, Then a new file on a second disk, making it a different >filegroup? Repeat until all files are in a different filegroup? This >all seems terribly cumbersome. > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy >Pang >Sent: Sunday, January 23, 2005 2:57 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > > >Hi John: > >To improve disk I/O performance, place data of table and its indexes in >separate data files (because less contention for disk resources given >the way data is accessed on disk). > >The syntax for creating index on specific filegroup is: > >"BOL Syntax" >CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name > ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) >[ WITH < index_option > [ ,...n] ] >[ ON filegroup ] > >For example: >create index ix_myindex on products(product_name) on >secondary_file_group; > >To store the table in a specific data file, use the ON filegroup at the >end of CREATE TABLE statement or create a clustered index of that table >in the target filegroup. The data of a table resides in the same >filegroup as its clustered index. > >Note: each db has default filegroup. If you don't specify specific >filegroup when you create index/table, then that is where the >index/table will reside. > >Always create your clustered index first before creating your >nonclustered indexes of a table. This is because physical key in >nonclusterd indexes is composed of the clustered index key. If you >create nonclustered index first, and then clustered index, the db will >need to rebuild existing nonclusterd indexes of that table (argh!). > >Sometimes an existing index on a table helps speed up creation of other >indexes on the table. > >HTH > >Billy > > >From: "John W. Colby" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > >Date: Sun, 23 Jan 2005 13:47:45 -0500 > > > >On the same note, is it possible to cause specific tables to be > >placed in specific files? > > >_______________________________________________ >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 michael at ddisolutions.com.au Sun Jan 23 18:24:51 2005 From: michael at ddisolutions.com.au (Michael Maddison) Date: Mon, 24 Jan 2005 11:24:51 +1100 Subject: [dba-SQLServer] Placing indexes in a specific file Message-ID: <59A61174B1F5B54B97FD4ADDE71E7D0107C714@ddi-01.DDI.local> John, I've got a PPT presentation from Unisys that talks about filegroups and a lot of other interesting tidbits to do with how best to set up the physical database. If you like I can send it direct to jwcolby at colbyconsulting.com? cheers Michael M Can a database be spread over more than one filegroup? If so, then I create a file group that is just a single file, i.e. filegroup1 is datafile1, filegroup2 is datafile2 etc. Then I can intentionally move a table to a specific filegroup and get it in a specific file (disk) John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang Sent: Sunday, January 23, 2005 4:51 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Placing indexes in a specific file Hi John: To move a table from one filegroup to another, from EM, go into design view of the table, bring up properties. on the first tab ("tables"), the third last dropdown list is table filegroup. You can use this dropdown list to move table from one filegroup to another. When you move tables from one filegroup to another, this is what EM does is recreate a temporarily copy of the table in the target filegroup, copy over data, drop old table and rename new one. You can also move indexes from one filegroup to another via same way (ie. table properties, indexes/keys, index filegroup dropdown list). Filegroups is just a way of organizing your data files. Filegroups consist of physical data files. AFAIK, I don't think it is possible to put data of a table in a specific physical data file (you can only put table into file group. sql server does the rest). For performance reasons, in a single filegroup, it is recommended that your physical data files are spread out over multiple disks. That way all disks can work simultaneously at once to get your data for a single table. Not sure what is the question "Do I need to create a new file on a new drive, make it a new file group?, Then a new file on a second disk, making it a different filegroup? Repeat until all files are in a different filegroup? This all seems terribly cumbersome." I believe that you can add more new data files (on a new disk) to an existing filegroup if you run out of space on the disks on the existing data files. I don't remember how SQL Server allocates the data to the physical data files. (ie. if filegroup has multiple data files, when you insert a record into table within that filegroup, which data file is the record physically stored in?). I don't have my sql server book with me so maybe somebody else knows. HTH Billy >From: "John W. Colby" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file >Date: Sun, 23 Jan 2005 15:49:17 -0500 > >Billy, > >Thanks for the response. Unfortunately I have already created most of >the tables, and in fact already moved the data into most of the tables. >I created the tables by simply opening the big table in design view, >selecting the fields I wanted in the smaller table, copying the fields >to the paste buffer, creating a new table and pasting the fields in to >the new table and saved. I then opened QA, did a "Script object to new >window as SELECT" , then "Script object to new window as INSERT", cut >the select statement and pasted it into the VALUES clause of the >insert, and finally ran the insert statement. Quick and easy. The >data gets moved from the BigTable to the new table in a couple of hours >(depending on how many I run simultaneously). >I then go in to each small table and build the indexes manually. Close >and save the table and the tables are built. > >As you can see I never used a SQL statement for any of this. It is >very fast to do it manually, and that process of building the smaller >tables is almost complete. I do still have to index about half of the >smaller tables, but because of the data in them I don't create >clustered indexes. > >Thus I need to know if I can take an existing table and move it to a >specific file. I suppose I could a INSERT INTO NEWSmallTable SELECT * >FROM SmallTable ON NEWFileGroup? That would copy the existing small >tables I have created to the new file? > >I must admit that I am confused about the concept of FileGroup. AFAICT >all of the files I currently have are in one file group. Thus using an >On FILEGROUP would only get it into the set of 4 files, not into a >specific file of that file group. > >Do I need to create a new file on a new drive, make it a new file >group?, Then a new file on a second disk, making it a different >filegroup? Repeat until all files are in a different filegroup? This >all seems terribly cumbersome. > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy >Pang >Sent: Sunday, January 23, 2005 2:57 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > > >Hi John: > >To improve disk I/O performance, place data of table and its indexes in >separate data files (because less contention for disk resources given >the way data is accessed on disk). > >The syntax for creating index on specific filegroup is: > >"BOL Syntax" >CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name > ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) [ WITH < >index_option > [ ,...n] ] [ ON filegroup ] > >For example: >create index ix_myindex on products(product_name) on >secondary_file_group; > >To store the table in a specific data file, use the ON filegroup at the >end of CREATE TABLE statement or create a clustered index of that table >in the target filegroup. The data of a table resides in the same >filegroup as its clustered index. > >Note: each db has default filegroup. If you don't specify specific >filegroup when you create index/table, then that is where the >index/table will reside. > >Always create your clustered index first before creating your >nonclustered indexes of a table. This is because physical key in >nonclusterd indexes is composed of the clustered index key. If you >create nonclustered index first, and then clustered index, the db will >need to rebuild existing nonclusterd indexes of that table (argh!). > >Sometimes an existing index on a table helps speed up creation of other >indexes on the table. > >HTH > >Billy > > >From: "John W. Colby" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > >Date: Sun, 23 Jan 2005 13:47:45 -0500 > > > >On the same note, is it possible to cause specific tables to be > >placed in specific files? > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From jwcolby at colbyconsulting.com Sun Jan 23 20:32:15 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Sun, 23 Jan 2005 21:32:15 -0500 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: <59A61174B1F5B54B97FD4ADDE71E7D0107C714@ddi-01.DDI.local> Message-ID: <001401c501bc$eac0a3e0$677aa8c0@ColbyM6805> Yes please. Thanks, John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Michael Maddison Sent: Sunday, January 23, 2005 7:25 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Placing indexes in a specific file John, I've got a PPT presentation from Unisys that talks about filegroups and a lot of other interesting tidbits to do with how best to set up the physical database. If you like I can send it direct to jwcolby at colbyconsulting.com? cheers Michael M Can a database be spread over more than one filegroup? If so, then I create a file group that is just a single file, i.e. filegroup1 is datafile1, filegroup2 is datafile2 etc. Then I can intentionally move a table to a specific filegroup and get it in a specific file (disk) John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang Sent: Sunday, January 23, 2005 4:51 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Placing indexes in a specific file Hi John: To move a table from one filegroup to another, from EM, go into design view of the table, bring up properties. on the first tab ("tables"), the third last dropdown list is table filegroup. You can use this dropdown list to move table from one filegroup to another. When you move tables from one filegroup to another, this is what EM does is recreate a temporarily copy of the table in the target filegroup, copy over data, drop old table and rename new one. You can also move indexes from one filegroup to another via same way (ie. table properties, indexes/keys, index filegroup dropdown list). Filegroups is just a way of organizing your data files. Filegroups consist of physical data files. AFAIK, I don't think it is possible to put data of a table in a specific physical data file (you can only put table into file group. sql server does the rest). For performance reasons, in a single filegroup, it is recommended that your physical data files are spread out over multiple disks. That way all disks can work simultaneously at once to get your data for a single table. Not sure what is the question "Do I need to create a new file on a new drive, make it a new file group?, Then a new file on a second disk, making it a different filegroup? Repeat until all files are in a different filegroup? This all seems terribly cumbersome." I believe that you can add more new data files (on a new disk) to an existing filegroup if you run out of space on the disks on the existing data files. I don't remember how SQL Server allocates the data to the physical data files. (ie. if filegroup has multiple data files, when you insert a record into table within that filegroup, which data file is the record physically stored in?). I don't have my sql server book with me so maybe somebody else knows. HTH Billy >From: "John W. Colby" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file >Date: Sun, 23 Jan 2005 15:49:17 -0500 > >Billy, > >Thanks for the response. Unfortunately I have already created most of >the tables, and in fact already moved the data into most of the tables. >I created the tables by simply opening the big table in design view, >selecting the fields I wanted in the smaller table, copying the fields >to the paste buffer, creating a new table and pasting the fields in to >the new table and saved. I then opened QA, did a "Script object to new >window as SELECT" , then "Script object to new window as INSERT", cut >the select statement and pasted it into the VALUES clause of the >insert, and finally ran the insert statement. Quick and easy. The >data gets moved from the BigTable to the new table in a couple of hours >(depending on how many I run simultaneously). >I then go in to each small table and build the indexes manually. Close >and save the table and the tables are built. > >As you can see I never used a SQL statement for any of this. It is >very fast to do it manually, and that process of building the smaller >tables is almost complete. I do still have to index about half of the >smaller tables, but because of the data in them I don't create >clustered indexes. > >Thus I need to know if I can take an existing table and move it to a >specific file. I suppose I could a INSERT INTO NEWSmallTable SELECT * >FROM SmallTable ON NEWFileGroup? That would copy the existing small >tables I have created to the new file? > >I must admit that I am confused about the concept of FileGroup. AFAICT >all of the files I currently have are in one file group. Thus using an >On FILEGROUP would only get it into the set of 4 files, not into a >specific file of that file group. > >Do I need to create a new file on a new drive, make it a new file >group?, Then a new file on a second disk, making it a different >filegroup? Repeat until all files are in a different filegroup? This >all seems terribly cumbersome. > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy >Pang >Sent: Sunday, January 23, 2005 2:57 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > > >Hi John: > >To improve disk I/O performance, place data of table and its indexes in >separate data files (because less contention for disk resources given >the way data is accessed on disk). > >The syntax for creating index on specific filegroup is: > >"BOL Syntax" >CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name > ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) [ WITH < >index_option > [ ,...n] ] [ ON filegroup ] > >For example: >create index ix_myindex on products(product_name) on >secondary_file_group; > >To store the table in a specific data file, use the ON filegroup at the >end of CREATE TABLE statement or create a clustered index of that table >in the target filegroup. The data of a table resides in the same >filegroup as its clustered index. > >Note: each db has default filegroup. If you don't specify specific >filegroup when you create index/table, then that is where the >index/table will reside. > >Always create your clustered index first before creating your >nonclustered indexes of a table. This is because physical key in >nonclusterd indexes is composed of the clustered index key. If you >create nonclustered index first, and then clustered index, the db will >need to rebuild existing nonclusterd indexes of that table (argh!). > >Sometimes an existing index on a table helps speed up creation of other >indexes on the table. > >HTH > >Billy > > >From: "John W. Colby" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > >Date: Sun, 23 Jan 2005 13:47:45 -0500 > > > >On the same note, is it possible to cause specific tables to be > >placed in specific files? > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From tuxedo_man at hotmail.com Sun Jan 23 21:04:35 2005 From: tuxedo_man at hotmail.com (Billy Pang) Date: Mon, 24 Jan 2005 03:04:35 +0000 Subject: [dba-SQLServer] Placing indexes in a specific file In-Reply-To: <001301c501a0$38441bf0$677aa8c0@ColbyM6805> Message-ID: A database can have more than one filegroup. In EM, go to properties of user database. There is filegroups tab. Type name of new filegroup in space provided. >From: "John W. Colby" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file >Date: Sun, 23 Jan 2005 18:06:49 -0500 > >Can a database be spread over more than one filegroup? If so, then I >create >a file group that is just a single file, i.e. filegroup1 is datafile1, >filegroup2 is datafile2 etc. Then I can intentionally move a table to a >specific filegroup and get it in a specific file (disk) > >John W. Colby >www.ColbyConsulting.com > >Contribute your unused CPU cycles to a good cause: >http://folding.stanford.edu/ > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy Pang >Sent: Sunday, January 23, 2005 4:51 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > > >Hi John: > >To move a table from one filegroup to another, from EM, go into design view >of the table, bring up properties. on the first tab ("tables"), the third >last dropdown list is table filegroup. You can use this dropdown list to >move table from one filegroup to another. When you move tables from one >filegroup to another, this is what EM does is recreate a temporarily copy >of > >the table in the target filegroup, copy over data, drop old table and >rename > >new one. > >You can also move indexes from one filegroup to another via same way (ie. >table properties, indexes/keys, index filegroup dropdown list). > >Filegroups is just a way of organizing your data files. Filegroups consist >of physical data files. AFAIK, I don't think it is possible to put data of >a table in a specific physical data file (you can only put table into file >group. sql server does the rest). For performance reasons, in a single >filegroup, it is recommended that your physical data files are spread out >over multiple disks. That way all disks can work simultaneously at once to >get your data for a single table. > >Not sure what is the question "Do I need to create a new file on a new >drive, make it a new file group?, Then a new file on a second disk, making >it a different filegroup? Repeat until all files are in a different >filegroup? This all seems terribly cumbersome." I believe that you can >add > >more new data files (on a new disk) to an existing filegroup if you run out >of space on the disks on the existing data files. > >I don't remember how SQL Server allocates the data to the physical data >files. (ie. if filegroup has multiple data files, when you insert a record >into table within that filegroup, which data file is the record physically >stored in?). I don't have my sql server book with me so maybe somebody >else > >knows. > >HTH >Billy > > >From: "John W. Colby" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: dba-sqlserver at databaseadvisors.com > >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > >Date: Sun, 23 Jan 2005 15:49:17 -0500 > > > >Billy, > > > >Thanks for the response. Unfortunately I have already created most of > >the tables, and in fact already moved the data into most of the tables. > >I created the tables by simply opening the big table in design view, > >selecting the fields I wanted in the smaller table, copying the fields > >to the paste buffer, creating a new table and pasting the fields in to > >the new table and saved. I then opened QA, did a "Script object to new > >window as SELECT" , then "Script object to new window as INSERT", cut > >the select statement and > >pasted it into the VALUES clause of the insert, and finally ran the >insert > >statement. Quick and easy. The data gets moved from the BigTable to the > >new table in a couple of hours (depending on how many I run > >simultaneously). > >I then go in to each small table and build the indexes manually. Close >and > >save the table and the tables are built. > > > >As you can see I never used a SQL statement for any of this. It is > >very fast to do it manually, and that process of building the smaller > >tables is almost complete. I do still have to index about half of the > >smaller tables, but because of the data in them I don't create > >clustered indexes. > > > >Thus I need to know if I can take an existing table and move it to a > >specific file. I suppose I could a INSERT INTO NEWSmallTable SELECT * > >FROM SmallTable ON NEWFileGroup? That would copy the existing small > >tables I have created to the new file? > > > >I must admit that I am confused about the concept of FileGroup. AFAICT > >all of the files I currently have are in one file group. Thus using an > >On FILEGROUP would only get it into the set of 4 files, not into a > >specific file of that file group. > > > >Do I need to create a new file on a new drive, make it a new file > >group?, Then a new file on a second disk, making it a different > >filegroup? Repeat until all files are in a different filegroup? This > >all seems terribly cumbersome. > > > >John W. Colby > >www.ColbyConsulting.com > > > >Contribute your unused CPU cycles to a good cause: > >http://folding.stanford.edu/ > > > >-----Original Message----- > >From: dba-sqlserver-bounces at databaseadvisors.com > >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Billy > >Pang > >Sent: Sunday, January 23, 2005 2:57 PM > >To: dba-sqlserver at databaseadvisors.com > >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > > > > > >Hi John: > > > >To improve disk I/O performance, place data of table and its indexes in > >separate data files (because less contention for disk resources given > >the way data is accessed on disk). > > > >The syntax for creating index on specific filegroup is: > > > >"BOL Syntax" > >CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name > > ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) > >[ WITH < index_option > [ ,...n] ] > >[ ON filegroup ] > > > >For example: > >create index ix_myindex on products(product_name) on > >secondary_file_group; > > > >To store the table in a specific data file, use the ON filegroup at the > >end of CREATE TABLE statement or create a clustered index of that table > >in the target filegroup. The data of a table resides in the same > >filegroup as its clustered index. > > > >Note: each db has default filegroup. If you don't specify specific > >filegroup when you create index/table, then that is where the > >index/table will reside. > > > >Always create your clustered index first before creating your > >nonclustered indexes of a table. This is because physical key in > >nonclusterd indexes is composed of the clustered index key. If you > >create nonclustered index first, and then clustered index, the db will > >need to rebuild existing nonclusterd indexes of that table (argh!). > > > >Sometimes an existing index on a table helps speed up creation of other > >indexes on the table. > > > >HTH > > > >Billy > > > > >From: "John W. Colby" > > >Reply-To: dba-sqlserver at databaseadvisors.com > > >To: dba-sqlserver at databaseadvisors.com > > >Subject: RE: [dba-SQLServer] Placing indexes in a specific file > > >Date: Sun, 23 Jan 2005 13:47:45 -0500 > > > > > >On the same note, is it possible to cause specific tables to be > > >placed in specific files? > > > > > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > > > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > From jwcolby at colbyconsulting.com Mon Jan 24 12:34:00 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Mon, 24 Jan 2005 13:34:00 -0500 Subject: [dba-SQLServer] Whats going on and how to fix it In-Reply-To: Message-ID: <001b01c50243$49d298d0$677aa8c0@ColbyM6805> I created a new field in one of my "little tables" - ~10 fields, 64 million records, wrong data type by mistake. I went in to design view and changed the datatype. When I closed the table EM "went away" with the hourglass. 4 hours later still an hour glass. Task manager shows Em spending 99% of time on the folding task, with occasional jumps in SQL Server activity (CPU Time) to 10, 7,9, etc %. I used Task Manager to shut it down. Shut windows down (just in caseA) and started it back up. Opened EM and as soon as I click on the databases "folder" the hourglass comes up. More hours later... Shut EM down again, rebooted and started it back up, same thing. Now I am copying the log and pasting it back in so I can look at it (can't open the log itself) and it says Spid11 Recovery of database 'Conduit' (7) is 28% complete (approx 2216 more seconds) (Phase 3 of 3) Soo... 37 minutes to go. It appears that the db is being recovered. The question is, WTF? 4 hours (and not finished) to convert a field to another datatype? Can I just delete the field and recreate it (assuming the repair works)? It had no data in it. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ From erbachs at gmail.com Mon Jan 24 13:16:01 2005 From: erbachs at gmail.com (Steve Erbach) Date: Mon, 24 Jan 2005 13:16:01 -0600 Subject: [dba-SQLServer] Whats going on and how to fix it In-Reply-To: <001b01c50243$49d298d0$677aa8c0@ColbyM6805> References: <001b01c50243$49d298d0$677aa8c0@ColbyM6805> Message-ID: <39cb22f305012411162dfb5096@mail.gmail.com> John, What were you converting from and what's the new field type? I'd say that you'd be better served (since there was no data in the field) by deleting the field and then re-inserting it. 64 million rows. Yikes! You are definitely going to be a guru of large, unwieldy tables after this project's over, eh? Steve Erbach Neenah, WI On Mon, 24 Jan 2005 13:34:00 -0500, John W. Colby wrote: > I created a new field in one of my "little tables" - ~10 fields, 64 million > records, wrong data type by mistake. I went in to design view and changed > the datatype. When I closed the table EM "went away" with the hourglass. 4 > hours later still an hour glass. Task manager shows Em spending 99% of time > on the folding task, with occasional jumps in SQL Server activity (CPU Time) > to 10, 7,9, etc %. > > I used Task Manager to shut it down. Shut windows down (just in caseA) and > started it back up. Opened EM and as soon as I click on the databases > "folder" the hourglass comes up. More hours later... > > Shut EM down again, rebooted and started it back up, same thing. > > Now I am copying the log and pasting it back in so I can look at it (can't > open the log itself) and it says > > Spid11 Recovery of database 'Conduit' (7) is 28% complete (approx 2216 more > seconds) (Phase 3 of 3) > > Soo... 37 minutes to go. > > It appears that the db is being recovered. The question is, WTF? 4 hours > (and not finished) to convert a field to another datatype? Can I just > delete the field and recreate it (assuming the repair works)? It had no > data in it. > > John W. Colby > www.ColbyConsulting.com From jwcolby at colbyconsulting.com Mon Jan 24 14:10:20 2005 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Mon, 24 Jan 2005 15:10:20 -0500 Subject: [dba-SQLServer] Whats going on and how to fix it In-Reply-To: <39cb22f305012411162dfb5096@mail.gmail.com> Message-ID: <002001c50250$bb1ff480$677aa8c0@ColbyM6805> It was a Boolean. I typed in var and hit return when entering the data type. VarChar is not the default. 8-( I did indeed just delete the column and added it back in as the correct type. Took all of 30 seconds. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Steve Erbach Sent: Monday, January 24, 2005 2:16 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Whats going on and how to fix it John, What were you converting from and what's the new field type? I'd say that you'd be better served (since there was no data in the field) by deleting the field and then re-inserting it. 64 million rows. Yikes! You are definitely going to be a guru of large, unwieldy tables after this project's over, eh? Steve Erbach Neenah, WI On Mon, 24 Jan 2005 13:34:00 -0500, John W. Colby wrote: > I created a new field in one of my "little tables" - ~10 fields, 64 > million records, wrong data type by mistake. I went in to design view > and changed the datatype. When I closed the table EM "went away" with > the hourglass. 4 hours later still an hour glass. Task manager shows > Em spending 99% of time on the folding task, with occasional jumps in > SQL Server activity (CPU Time) to 10, 7,9, etc %. > > I used Task Manager to shut it down. Shut windows down (just in > caseA) and started it back up. Opened EM and as soon as I click on > the databases "folder" the hourglass comes up. More hours later... > > Shut EM down again, rebooted and started it back up, same thing. > > Now I am copying the log and pasting it back in so I can look at it > (can't open the log itself) and it says > > Spid11 Recovery of database 'Conduit' (7) is 28% complete (approx 2216 > more > seconds) (Phase 3 of 3) > > Soo... 37 minutes to go. > > It appears that the db is being recovered. The question is, WTF? 4 > hours (and not finished) to convert a field to another datatype? Can > I just delete the field and recreate it (assuming the repair works)? > It had no data in it. > > 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 michael at ddisolutions.com.au Mon Jan 24 19:20:31 2005 From: michael at ddisolutions.com.au (Michael Maddison) Date: Tue, 25 Jan 2005 12:20:31 +1100 Subject: [dba-SQLServer] Whats going on and how to fix it Message-ID: <59A61174B1F5B54B97FD4ADDE71E7D0107C71D@ddi-01.DDI.local> John, EM most likely will create the new table, copy + convert the data, drop the original table, rename the new table. This is all logged and within a transaction. If you stop the process, SQL will roll back the changes... Re booting doesn't stop it, this is a feature... I've also ended up with suspect DB's if you reboot in the middle of an operation. This is 1 reason why scripting changes yourself in QA is safer, particulary with large db's. cheers Michael M It was a Boolean. I typed in var and hit return when entering the data type. VarChar is not the default. 8-( I did indeed just delete the column and added it back in as the correct type. Took all of 30 seconds. John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Steve Erbach Sent: Monday, January 24, 2005 2:16 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Whats going on and how to fix it John, What were you converting from and what's the new field type? I'd say that you'd be better served (since there was no data in the field) by deleting the field and then re-inserting it. 64 million rows. Yikes! You are definitely going to be a guru of large, unwieldy tables after this project's over, eh? Steve Erbach Neenah, WI On Mon, 24 Jan 2005 13:34:00 -0500, John W. Colby wrote: > I created a new field in one of my "little tables" - ~10 fields, 64 > million records, wrong data type by mistake. I went in to design view > and changed the datatype. When I closed the table EM "went away" with > the hourglass. 4 hours later still an hour glass. Task manager shows > Em spending 99% of time on the folding task, with occasional jumps in > SQL Server activity (CPU Time) to 10, 7,9, etc %. > > I used Task Manager to shut it down. Shut windows down (just in > caseA) and started it back up. Opened EM and as soon as I click on > the databases "folder" the hourglass comes up. More hours later... > > Shut EM down again, rebooted and started it back up, same thing. > > Now I am copying the log and pasting it back in so I can look at it > (can't open the log itself) and it says > > Spid11 Recovery of database 'Conduit' (7) is 28% complete (approx 2216 > more > seconds) (Phase 3 of 3) > > Soo... 37 minutes to go. > > It appears that the db is being recovered. The question is, WTF? 4 > hours (and not finished) to convert a field to another datatype? Can > I just delete the field and recreate it (assuming the repair works)? > It had no data in it. > > John W. Colby > www.ColbyConsulting.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From sgeller at cce.umn.edu Tue Jan 25 13:43:48 2005 From: sgeller at cce.umn.edu (Susan Geller) Date: Tue, 25 Jan 2005 13:43:48 -0600 Subject: [dba-SQLServer] Decoding HTML in SQL Server Table Message-ID: I am trying to create a report in Access using data in SQL Server. The data is written to SQL Server through a c#.net application. The application stores the data for one field encoded with html so I have text that looks like this: >Subject: RE: my program >Date: Thu, 30 Dec 2004 09:25:12 -0600 > >Hi Janelle, > I want to decode the html and make it look like straight text when it appears in my Access report. I can't figure out how to do it either in SQL Server or in Access. Ideas anybody? Thanks. --Susan Susan B. Geller Office of Information Systems College of Continuing Education University of Minnesota 306 Wesbrook Hall 77 Pleasant Street SE Minneapolis, MN 55455 Phone: 612-626-4785 Fax: 612-625-2568 From sgeller at cce.umn.edu Tue Jan 25 16:58:20 2005 From: sgeller at cce.umn.edu (Susan Geller) Date: Tue, 25 Jan 2005 16:58:20 -0600 Subject: [dba-SQLServer] Decoding HTML in SQL Server Table Message-ID: Well, after searching around for a long time, I finally decided it would be easier to do something more manual. This one line of sql in my sproc gets most of the job done: Select replace(replace(replace (my_field_name, '>' , '' ), '"', ''), '<', '') >From my_table I'm still open to ideas if anybody has them. --Susan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Geller Sent: Tuesday, January 25, 2005 1:44 PM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Decoding HTML in SQL Server Table I am trying to create a report in Access using data in SQL Server. The data is written to SQL Server through a c#.net application. The application stores the data for one field encoded with html so I have text that looks like this: >Subject: RE: my program >Date: Thu, 30 Dec 2004 09:25:12 -0600 > >Hi Janelle, > I want to decode the html and make it look like straight text when it appears in my Access report. I can't figure out how to do it either in SQL Server or in Access. Ideas anybody? Thanks. --Susan Susan B. Geller Office of Information Systems College of Continuing Education University of Minnesota 306 Wesbrook Hall 77 Pleasant Street SE Minneapolis, MN 55455 Phone: 612-626-4785 Fax: 612-625-2568 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From martyconnelly at shaw.ca Wed Jan 26 02:03:43 2005 From: martyconnelly at shaw.ca (MartyConnelly) Date: Wed, 26 Jan 2005 00:03:43 -0800 Subject: [dba-SQLServer] Decoding HTML in SQL Server Table References: Message-ID: <41F74EDF.2050501@shaw.ca> You could try regular expression if you know exactly what you want to parse out If the HTML is XHTML compliant you could use XSLT Or you could try the mshtml parser but there is no telling if your html is w3c compliant. http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/hosting.asp This is documented in IE SDK Your code must have a reference to the Microsoft HTML Object Library. mshtml.dll Internet Explorer 5 or more is required to do this. Sample code Dim objLink As HTMLLinkElement Dim objMSHTML As New MSHTML.HTMLDocument Dim objDocument As MSHTML.HTMLDocument ' This function is only available with Internet Explorer 5 and up Set objDocument = objMSHTML.createDocumentFromUrl(txtURL.Text, _ vbNullString) While objDocument.readyState <> "complete" DoEvents Wend ' Source Code Debug.Print = objDocument.documentElement.outerHTML ' Title Debug.Print "Title : " & objDocument.Title ' grab a Link Collection from html For Each objLink In objDocument.links lstLinks.AddItem objLink Debug.Print "Link: " & objLink Next Susan Geller wrote: >Well, after searching around for a long time, I finally decided it would >be easier to do something more manual. This one line of sql in my sproc >gets most of the job done: > >Select replace(replace(replace (my_field_name, '>' , '' ), '"', >''), '<', '') >>From my_table > >I'm still open to ideas if anybody has them. > >--Susan > > > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan >Geller >Sent: Tuesday, January 25, 2005 1:44 PM >To: dba-sqlserver at databaseadvisors.com >Subject: [dba-SQLServer] Decoding HTML in SQL Server Table > >I am trying to create a report in Access using data in SQL Server. The >data is written to SQL Server through a c#.net application. The >application stores the data for one field encoded with html so I have >text that looks like this: > >>Subject: RE: my program >>Date: Thu, 30 Dec 2004 09:25:12 -0600 > >Hi Janelle, > > >I want to decode the html and make it look like straight text when it >appears in my Access report. I can't figure out how to do it either in >SQL Server or in Access. Ideas anybody? > >Thanks. > >--Susan > > >Susan B. Geller >Office of Information Systems >College of Continuing Education >University of Minnesota >306 Wesbrook Hall >77 Pleasant Street SE >Minneapolis, MN 55455 >Phone: 612-626-4785 >Fax: 612-625-2568 > > >_______________________________________________ >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 > > > > -- Marty Connelly Victoria, B.C. Canada