From paul.hartland at googlemail.com Wed Mar 4 04:04:54 2009 From: paul.hartland at googlemail.com (Paul Hartland) Date: Wed, 4 Mar 2009 10:04:54 +0000 Subject: [dba-SQLServer] Can't Get Select Results In Visual Basic Message-ID: <38c884770903040204x2d3de41fgfcafd31c84e50a7b@mail.gmail.com> To all, Sorry about cross posting this but really having a nightmare, I have the following store procedure in SQL Server 2005 : usp_MyStoredProcedure ( @nvcPayroll [nvarchar](50), @dtiJobDate [datetime], @nvcCode [nvarchar](1) ) AS BEGIN DECLARE @intUpdateFailed INT UPDATE dbo.MyTable SET AvailabilityCode=@nvcCode WHERE PayrollNo = @nvcPayroll AND JobDate = @dtiJobDate AND ( @nvcCode = 'A' OR @nvcCode = 'N' ) AND ( AvailabilityCode= 'A' OR AvailabilityCode= 'N' ) SET @intUpdateFailed=@@ROWCOUNT DELETE FROM dbo.MyTable2 WHERE PayrollNo=@nvcPayroll INSERT INTO MyTable2 (WebResult, PayrollNo) SELECT CASE WHEN @intUpdateFailed>0 THEN 'Success' ELSE 'Failed' END, @nvcPayroll SELECT * FROM MyTable2 WHERE PayrollNo=@nvcPayroll END If I run this in SQL Server seems to work fine, and the SELECT * FROM MyTable2 WHERE PayrollNo=@nvcPayroll returns all the fields. However I have a simple piece of VB code as below: Dim rs As ADODB.Recordset If DE.Conn.Start = adStateClosed Then DE.Conn.Open Endif Set rs = DE.Conn.Execute(usp_MyStoredProcedure '999999', '" & format(Date,"mm/dd/yy") & "','N'") msgbox rs.fields(0) DE.Conn.Close ' DE.Conn is a DataEnvironment connection which links to the SQL Server The vb code returns Item cannot be found in the collection corresponding to the requested name or ordinal. However if I run the SP, then comment out everything except the SELECT statement it returns the resultset. Can anyone tell me what is happening or what I am doing wrong please. Thanks in advance for any help on this.... -- Paul Hartland paul.hartland at googlemail.com From stuart at lexacorp.com.pg Wed Mar 4 04:50:17 2009 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Wed, 04 Mar 2009 20:50:17 +1000 Subject: [dba-SQLServer] [AccessD] Can't Get Select Results In Visual Basic In-Reply-To: <38c884770903040204x2d3de41fgfcafd31c84e50a7b@mail.gmail.com> References: <38c884770903040204x2d3de41fgfcafd31c84e50a7b@mail.gmail.com> Message-ID: <49AEE989.16930.1A61897@stuart.lexacorp.com.pg> I've run into very similar problems trying to use conditional execution and multiple selects in a SP called through ODBC (in my case using the SQLTools ODBC library with PowerBasic). It appears to be a limitation of the ODBC/ADODB drivers. In the end I had to split the one SP which worked fine in SQL Server into several separate calls to simple SPs and handle the conditional stuff in my PB code between calls. Sorry to be the bearer of bad tidings, but I suspect you may have to end up doing the same. -- Stuart On 4 Mar 2009 at 10:04, Paul Hartland wrote: > To all, > > Sorry about cross posting this but really having a nightmare, I have the > following store procedure in SQL Server 2005 : > > usp_MyStoredProcedure > ( > @nvcPayroll [nvarchar](50), > @dtiJobDate [datetime], > @nvcCode [nvarchar](1) > ) > AS > BEGIN > DECLARE @intUpdateFailed INT > UPDATE dbo.MyTable > SET AvailabilityCode=@nvcCode > WHERE PayrollNo = @nvcPayroll AND > JobDate = @dtiJobDate AND > ( > @nvcCode = 'A' OR > @nvcCode = 'N' > ) AND > ( > AvailabilityCode= 'A' OR > AvailabilityCode= 'N' > ) > > SET @intUpdateFailed=@@ROWCOUNT > DELETE FROM dbo.MyTable2 > WHERE PayrollNo=@nvcPayroll > INSERT INTO MyTable2 (WebResult, PayrollNo) > SELECT CASE WHEN @intUpdateFailed>0 THEN 'Success' ELSE 'Failed' END, > @nvcPayroll > SELECT * > FROM MyTable2 > WHERE PayrollNo=@nvcPayroll > END > > If I run this in SQL Server seems to work fine, and the SELECT * FROM > MyTable2 WHERE PayrollNo=@nvcPayroll returns all the fields. However I have > a simple piece of VB code as below: > > Dim rs As ADODB.Recordset > If DE.Conn.Start = adStateClosed Then > DE.Conn.Open > Endif > Set rs = DE.Conn.Execute(usp_MyStoredProcedure '999999', '" & > format(Date,"mm/dd/yy") & "','N'") > msgbox rs.fields(0) > > DE.Conn.Close > > ' DE.Conn is a DataEnvironment connection which links to the SQL Server > > The vb code returns Item cannot be found in the collection corresponding to > the requested name or ordinal. > > However if I run the SP, then comment out everything except the SELECT > statement it returns the resultset. > > Can anyone tell me what is happening or what I am doing wrong please. > > Thanks in advance for any help on this.... > > > > > > > -- > Paul Hartland > paul.hartland at googlemail.com > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com From David at sierranevada.com Wed Mar 4 12:16:55 2009 From: David at sierranevada.com (David Lewis) Date: Wed, 4 Mar 2009 10:16:55 -0800 Subject: [dba-SQLServer] Can't get resuts from sproc In-Reply-To: References: Message-ID: <01606FC26AD0E54B8348D886D0C074D339B53EAE4C@schwarz.sierranevada.corp> You might try the following kludge: At the beginning of the sproc, before all other code, have a dummy select statement that mirrors the final select that you want to execute: pseudo code: SELECT 'Success' as Result, ,'Some text' as nvcPayroll ,[Column 1] ,[Column 2] ... FROM MyTable2 WHERE 1=0 Obviously this will not return any rows, but it will let the front end know what kind of result set to expect. Then have the rest of the sproc as below. I'm not certain this will solve your problem, but I have used in in other instances successfully. Regards, d lewis To all, Sorry about cross posting this but really having a nightmare, I have the following store procedure in SQL Server 2005 : usp_MyStoredProcedure ( @nvcPayroll [nvarchar](50), @dtiJobDate [datetime], @nvcCode [nvarchar](1) ) AS BEGIN DECLARE @intUpdateFailed INT UPDATE dbo.MyTable SET AvailabilityCode=@nvcCode WHERE PayrollNo = @nvcPayroll AND JobDate = @dtiJobDate AND ( @nvcCode = 'A' OR @nvcCode = 'N' ) AND ( AvailabilityCode= 'A' OR AvailabilityCode= 'N' ) SET @intUpdateFailed=@@ROWCOUNT DELETE FROM dbo.MyTable2 WHERE PayrollNo=@nvcPayroll INSERT INTO MyTable2 (WebResult, PayrollNo) SELECT CASE WHEN @intUpdateFailed>0 THEN 'Success' ELSE 'Failed' END, @nvcPayroll SELECT * FROM MyTable2 WHERE PayrollNo=@nvcPayroll END If I run this in SQL Server seems to work fine, and the SELECT * FROM MyTable2 WHERE PayrollNo=@nvcPayroll returns all the fields. However I have a simple piece of VB code as below: Dim rs As ADODB.Recordset If DE.Conn.Start = adStateClosed Then DE.Conn.Open Endif Set rs = DE.Conn.Execute(usp_MyStoredProcedure '999999', '" & format(Date,"mm/dd/yy") & "','N'") msgbox rs.fields(0) DE.Conn.Close ' DE.Conn is a DataEnvironment connection which links to the SQL Server The vb code returns Item cannot be found in the collection corresponding to the requested name or ordinal. However if I run the SP, then comment out everything except the SELECT statement it returns the resultset. Can anyone tell me what is happening or what I am doing wrong please. Thanks in advance for any help on this.... The contents of this e-mail message and its attachments are covered by the Electronic Communications Privacy Act (18 U.S.C. 2510-2521) and are intended solely for the addressee(s) hereof. If you are not the named recipient, or the employee or agent responsible for delivering the message to the intended recipient, or if this message has been addressed to you in error, you are directed not to read, disclose, reproduce, distribute, disseminate or otherwise use this transmission. If you have received this communication in error, please notify us immediately by return e-mail or by telephone, 530-893-3520, and delete and/or destroy all copies of the message immediately. From davidmcafee at gmail.com Wed Mar 4 12:57:50 2009 From: davidmcafee at gmail.com (David McAfee) Date: Wed, 4 Mar 2009 10:57:50 -0800 Subject: [dba-SQLServer] Can't get resuts from sproc In-Reply-To: <01606FC26AD0E54B8348D886D0C074D339B53EAE4C@schwarz.sierranevada.corp> References: <01606FC26AD0E54B8348D886D0C074D339B53EAE4C@schwarz.sierranevada.corp> Message-ID: <8786a4c00903041057s30838fadh85bc3fbadad26543@mail.gmail.com> Try this: ALTER PROCEDURE usp_MyStoredProcedure (@nvcPayroll [nvarchar](50), @dtiJobDate [datetime], @nvcCode [nvarchar](1))AS BEGIN DECLARE @intUpdateFailed INT SET NOCOUNT ON UPDATE dbo.MyTable SET AvailabilityCode=@nvcCode WHERE PayrollNo = @nvcPayroll AND JobDate = @dtiJobDate AND (@nvcCode = 'A' OR @nvcCode = 'N') AND (AvailabilityCode= 'A' OR AvailabilityCode= 'N') SET @intUpdateFailed=@@ROWCOUNT DELETE FROM dbo.MyTable2 WHERE PayrollNo=@nvcPayroll INSERT INTO MyTable2 (WebResult, PayrollNo) SELECT CASE WHEN @intUpdateFailed>0 THEN 'Success' ELSE 'Failed' END, @nvcPayroll SET NOCOUNT OFF SELECT WebResult, PayrollNo FROM MyTable2 WHERE PayrollNo=@nvcPayroll END I added the NOCOUNT statements and also selected the actual field names from the final select. David On Wed, Mar 4, 2009 at 10:16 AM, David Lewis wrote: > > > You might try the following kludge: > > At the beginning of the sproc, before all other code, have a dummy select > statement that mirrors the final select that you want to execute: > pseudo code: SELECT 'Success' as Result, > ,'Some text' as nvcPayroll > ,[Column 1] > ,[Column 2] > ... > FROM MyTable2 > WHERE 1=0 > Obviously this will not return any rows, but it will let the front end know > what kind of result set to expect. Then have the rest of the sproc as > below. I'm not certain this will solve your problem, but I have used in in > other instances successfully. > > Regards, d lewis > > > > To all, > > Sorry about cross posting this but really having a nightmare, I have the > following store procedure in SQL Server 2005 : > > usp_MyStoredProcedure > ( > @nvcPayroll [nvarchar](50), > @dtiJobDate [datetime], > @nvcCode [nvarchar](1) > ) > AS > BEGIN > DECLARE @intUpdateFailed INT > UPDATE dbo.MyTable > SET AvailabilityCode=@nvcCode > WHERE PayrollNo = @nvcPayroll AND > JobDate = @dtiJobDate AND > ( > @nvcCode = 'A' OR > @nvcCode = 'N' > ) AND > ( > AvailabilityCode= 'A' OR > AvailabilityCode= 'N' > ) > > SET @intUpdateFailed=@@ROWCOUNT > DELETE FROM dbo.MyTable2 > WHERE PayrollNo=@nvcPayroll > INSERT INTO MyTable2 (WebResult, PayrollNo) > SELECT CASE WHEN @intUpdateFailed>0 THEN 'Success' ELSE 'Failed' END, > @nvcPayroll > SELECT * > FROM MyTable2 > WHERE PayrollNo=@nvcPayroll > END > > If I run this in SQL Server seems to work fine, and the SELECT * FROM > MyTable2 WHERE PayrollNo=@nvcPayroll returns all the fields. However I > have > a simple piece of VB code as below: > > Dim rs As ADODB.Recordset > If DE.Conn.Start = adStateClosed Then > DE.Conn.Open > Endif > Set rs = DE.Conn.Execute(usp_MyStoredProcedure '999999', '" & > format(Date,"mm/dd/yy") & "','N'") > msgbox rs.fields(0) > > DE.Conn.Close > > ' DE.Conn is a DataEnvironment connection which links to the SQL Server > > The vb code returns Item cannot be found in the collection corresponding to > the requested name or ordinal. > > However if I run the SP, then comment out everything except the SELECT > statement it returns the resultset. > > Can anyone tell me what is happening or what I am doing wrong please. > > Thanks in advance for any help on this.... > > > > > > The contents of this e-mail message and its attachments are covered by the > Electronic Communications Privacy Act (18 U.S.C. 2510-2521) and are intended > solely for the addressee(s) hereof. If you are not the named recipient, or > the employee or agent responsible for delivering the message to the intended > recipient, or if this message has been addressed to you in error, you are > directed not to read, disclose, reproduce, distribute, disseminate or > otherwise use this transmission. If you have received this communication in > error, please notify us immediately by return e-mail or by telephone, > 530-893-3520, and delete and/or destroy all copies of the message > immediately. > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fuller.artful at gmail.com Sat Mar 14 11:12:33 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Sat, 14 Mar 2009 12:12:33 -0400 Subject: [dba-SQLServer] NULLs Message-ID: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> Over on the MySQL group, a discussion has been waging about the use of NULLs. One guy in particular is adamant about forbidding them everywhere. He goes so far as to say the existence of NULLs means bad design, pure and simple. I am not quite so radical about it, but I do look askance at any column that permits them, and obviously I forbid them in any FK column. I tossed that in just to take the pulse of this group on this general topic, but my real question concerns something one of the posters wrote: "It seems that someone got bitten very hard in a soft area by a Null one day. On a more practical level, Oracle recommended to design the table with the field where NULLs are to be expected at the end of the table, that saves a little space and two, as the use of indexes is invalidated in case of nulls its is better to place the important indexed fields toward the beginning of the table." I don't know whether this is also true of SQL Server. Do you? Arthur From dwaters at usinternet.com Sat Mar 14 11:56:00 2009 From: dwaters at usinternet.com (Dan Waters) Date: Sat, 14 Mar 2009 11:56:00 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> Message-ID: Hi Arthur, This argument of 'no nulls ever' is pretty silly. Most of my design work is the automation of a business process. To go from the beginning to the end could take from a day to a week to a month or more. People fill in information whenever they can, and because some fields are optional they never do get filled in. So it makes sense to just use a single record in a table to hold the process' primary information (except for FK's like you said). It does NOT make sense to try to force people to work in a way different than they normally would just to enforce some 'perfection' rule. Databases are designed to be able to use nulls - take advantage of that. Since business processes are not a niche activity, no one should spend any time at all on a 'no nulls' argument. Just my 2 cents. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Saturday, March 14, 2009 11:13 AM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] NULLs Over on the MySQL group, a discussion has been waging about the use of NULLs. One guy in particular is adamant about forbidding them everywhere. He goes so far as to say the existence of NULLs means bad design, pure and simple. I am not quite so radical about it, but I do look askance at any column that permits them, and obviously I forbid them in any FK column. I tossed that in just to take the pulse of this group on this general topic, but my real question concerns something one of the posters wrote: "It seems that someone got bitten very hard in a soft area by a Null one day. On a more practical level, Oracle recommended to design the table with the field where NULLs are to be expected at the end of the table, that saves a little space and two, as the use of indexes is invalidated in case of nulls its is better to place the important indexed fields toward the beginning of the table." I don't know whether this is also true of SQL Server. Do you? Arthur _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From ssharkins at gmail.com Sat Mar 14 11:59:41 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Sat, 14 Mar 2009 12:59:41 -0400 Subject: [dba-SQLServer] NULLs References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> Message-ID: I agree, nulls aren't the problem, not accommodating them is. If you're going to allow them, you have to account for them in your queries, etc., but other than that... why not allow them? As for your specific SQL Server indexes to the left please question -- I have no idea and I can't imagine that with today's resources, it even matters. Susan H. > Hi Arthur, > > This argument of 'no nulls ever' is pretty silly. Most of my design work > is > the automation of a business process. To go from the beginning to the end From fuller.artful at gmail.com Sat Mar 14 14:00:27 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Sat, 14 Mar 2009 15:00:27 -0400 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> Message-ID: <29f585dd0903141200n1462dccay54ef774bb54df636@mail.gmail.com> I'm not as quick on the draw as you, Susan. There are a couple of parts to this argument. The first is the implication that any null column cannot be indexed, or even if the system allows it, the index will never be used. The second is that column position matters in terms of performance, and leftwise is better. I first heard this argument way back when in the days of DOS. dBASE was written by Wayne Ratliff and Jeb Long, both ex JPL programmers, and it mattered on mainframes. It's possible that they just brought the notion with them to the PCm or that they tested it first and the tests mirrored mainframe experience. At any rate, if the conjecture is true, then by extension one should arrange the columns in order of frequency of use.(in indexes and queries). I think that for a small database, a few hundred megs let's say, the performance difference will be minimal even if the conjecture is true. But medium to large databases (20 gigs to a terabytem say) the difference, if any, might be significant. As it happens, I have a table with over 50 million rows in it; Real data, not manufactured. I can make a copy and arrange the columns as suggested (actually, they might aready be arranged that way, in which case I'll reverse the process and move one or two toward the right) If anybody wants me, I shall be in the lab. Ooooo ho ho hoagggh. A. On Sat, Mar 14, 2009 at 12:59 PM, Susan Harkins wrote: > I agree, nulls aren't the problem, not accommodating them is. If you're > going to allow them, you have to account for them in your queries, etc., > but > other than that... why not allow them? > > As for your specific SQL Server indexes to the left please question -- I > have no idea and I can't imagine that with today's resources, it even > matters. > > Susan H. > > > From ssharkins at gmail.com Sat Mar 14 14:24:10 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Sat, 14 Mar 2009 15:24:10 -0400 Subject: [dba-SQLServer] NULLs References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> <29f585dd0903141200n1462dccay54ef774bb54df636@mail.gmail.com> Message-ID: The first is the implication that any null column cannot be > indexed, or even if the system allows it, the index will never be used. =======What you're suggesting is that even though SQL Server allows the index to be set, it won't use it -- I'd be surprised if that's the case and not surprised at all -- paradox... but we're dealing with MS. > > At any rate, if the conjecture is true, then by extension one should > arrange > the columns in order of frequency of use.(in indexes and queries). I think > that for a small database, a few hundred megs let's say, the performance > difference will be minimal even if the conjecture is true. But medium to > large databases (20 gigs to a terabytem say) the difference, if any, might > be significant. ========Well, let me say this -- I will be surprised if this matters. You'd think, if this were really the case in SQL Server, that it'd be well known already. Susan H. From Gustav at cactus.dk Sat Mar 14 14:49:37 2009 From: Gustav at cactus.dk (Gustav Brock) Date: Sat, 14 Mar 2009 20:49:37 +0100 Subject: [dba-SQLServer] NULLs Message-ID: Hi Arthur And what should be substituted for Null values? Zero length strings and "magic" values like -1 or -9999999999 for integers or 9999-12-31 for dates - or the absurd MySQL speciality: 2009-00-00, an invalid date for no date. Makes me feel tired. /gustav >>> dwaters at usinternet.com 14-03-2009 17:56 >>> Hi Arthur, This argument of 'no nulls ever' is pretty silly. Most of my design work is the automation of a business process. To go from the beginning to the end could take from a day to a week to a month or more. People fill in information whenever they can, and because some fields are optional they never do get filled in. So it makes sense to just use a single record in a table to hold the process' primary information (except for FK's like you said). It does NOT make sense to try to force people to work in a way different than they normally would just to enforce some 'perfection' rule. Databases are designed to be able to use nulls - take advantage of that. Since business processes are not a niche activity, no one should spend any time at all on a 'no nulls' argument. Just my 2 cents. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller Sent: Saturday, March 14, 2009 11:13 AM To: Discussion concerning MS SQL Server Subject: [dba-SQLServer] NULLs Over on the MySQL group, a discussion has been waging about the use of NULLs. One guy in particular is adamant about forbidding them everywhere. He goes so far as to say the existence of NULLs means bad design, pure and simple. I am not quite so radical about it, but I do look askance at any column that permits them, and obviously I forbid them in any FK column. I tossed that in just to take the pulse of this group on this general topic, but my real question concerns something one of the posters wrote: "It seems that someone got bitten very hard in a soft area by a Null one day. On a more practical level, Oracle recommended to design the table with the field where NULLs are to be expected at the end of the table, that saves a little space and two, as the use of indexes is invalidated in case of nulls its is better to place the important indexed fields toward the beginning of the table." I don't know whether this is also true of SQL Server. Do you? Arthur From fuller.artful at gmail.com Sat Mar 14 14:52:01 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Sat, 14 Mar 2009 15:52:01 -0400 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> <29f585dd0903141200n1462dccay54ef774bb54df636@mail.gmail.com> Message-ID: <29f585dd0903141252g589551cakb1024e74e68cddeb@mail.gmail.com> On your first point, I think that you just don't have enough experience with SQL Server and specifically with Profiler and query plans This tool is there precisely because the query optimizer sometimes makes decisions that may at first seem strange, but then you probe what it's doing and often that helps you restructure a query for better performance. Lots of times, for reasons that may not be initially apparent, the optimizer decides that it's quicker to do a full table scan rather than an index scan and several bookmark lookups. It is often the case that the design flaw is somewhere between the chair and the keyboard. Further, the optimizer sometimes makes mistakes; that's why there are HINTS, with which you can order the engine to use a specific index when there are several possible choices. On the second point, the recommendation comes from Oracle itself. That is not to say that SQL Server works the same way. I just thought it interesting and wanted to see what you all thought of it. A. From fuller.artful at gmail.com Sat Mar 14 14:55:17 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Sat, 14 Mar 2009 15:55:17 -0400 Subject: [dba-SQLServer] NULLs In-Reply-To: References: Message-ID: <29f585dd0903141255h1c708cd8r6fa9db28fe4ca641@mail.gmail.com> Me too. I am in favour of using NULLs where they make sense. Nonsense values are worse than Nulls by a long shot, IMO. On Sat, Mar 14, 2009 at 3:49 PM, Gustav Brock wrote: > Hi Arthur > > And what should be substituted for Null values? Zero length strings and > "magic" values like -1 or -9999999999 for integers or 9999-12-31 for dates - > or the absurd MySQL speciality: 2009-00-00, an invalid date for no date. > Makes me feel tired. > > /gustav > From ab-mi at post3.tele.dk Sun Mar 15 18:23:33 2009 From: ab-mi at post3.tele.dk (Asger Blond) Date: Mon, 16 Mar 2009 00:23:33 +0100 Subject: [dba-SQLServer] NULLs In-Reply-To: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> Message-ID: <69857DFD66F64060A936BAD12220B9DF@AB> Coming in late I have a few comments here. 1. In SQL Server you can make indexes on NULL allowed columns, and the engine sure will use these indexes if they are useful for the queries. 2. The column order of NULL allowed columns is of no importance in SQL Server as it maintains header information for each row telling if NULL allowed columns have a value or not. 3. And Arthur: "obviously I forbid them in any FK column". Don't agree, seems quite allowable to me. Imagine you have a Department and an Employee table. Your Employee table has a FK referencing the Department table. Now you just hired a new employee but haven't decided yet the department for the employee. Isn't it reasonable to make a record for the new employee leaving the FK column NULL? Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arthur Fuller Sendt: 14. marts 2009 17:13 Til: Discussion concerning MS SQL Server Emne: [dba-SQLServer] NULLs Over on the MySQL group, a discussion has been waging about the use of NULLs. One guy in particular is adamant about forbidding them everywhere. He goes so far as to say the existence of NULLs means bad design, pure and simple. I am not quite so radical about it, but I do look askance at any column that permits them, and obviously I forbid them in any FK column. I tossed that in just to take the pulse of this group on this general topic, but my real question concerns something one of the posters wrote: "It seems that someone got bitten very hard in a soft area by a Null one day. On a more practical level, Oracle recommended to design the table with the field where NULLs are to be expected at the end of the table, that saves a little space and two, as the use of indexes is invalidated in case of nulls its is better to place the important indexed fields toward the beginning of the table." I don't know whether this is also true of SQL Server. Do you? Arthur _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fuller.artful at gmail.com Sun Mar 15 23:32:51 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 16 Mar 2009 00:32:51 -0400 Subject: [dba-SQLServer] Why doesn't this work? Message-ID: <29f585dd0903152132r7088b91cr8aae9e35ace5e8bf@mail.gmail.com> I've been staring at this too long and I'm bleary now, so it's time for a fresh pair of eyes... USE [AdventureWorks] GO -- Create UDF to use in computed column expression CREATE FUNCTION [dbo].[UDF_CalculatePay] ( @basicPay INT, @BonusPercentage TINYINT, @TaxPercentage TINYINT ) RETURNS INT WITH SCHEMABINDING AS BEGIN DECLARE @TotalPay INT SET @TotalPay = @basicPay + @basicPay * @bonusPercentage / 100 - @basicPay * @taxPercentage / 100 RETURN @TotalPay END GO IF OBJECT_ID('CCIndexTest', 'U') IS NOT NULL DROP TABLE CCIndexTest GO -- Create table CCIndexTest with two computed columns CREATE TABLE [dbo].[CCIndexTest] ( [EmpNumb] [INT] NOT NULL, [DOBirth] [DATETIME] NULL, [DORetirement] AS ( DATEADD(YEAR, ( 60 ), [DOBirth]) - ( 1 ) ) PERSISTED, [BasicPay] [SMALLINT] NULL, [BonusPercentage] [TINYINT] NULL, [TaxPercentage] [TINYINT] NULL, [TotalPay] AS [dbo].[UDF_CalculatePay](basicPay, BonusPercentage, TaxPercentage) ) ON [PRIMARY] GO I get arrested on line 10 (of the Create Table part -- the udf compiles fine) with "Invalid Column Name basicPay". I do not understand what is wrong with this. Do you? TIA, Arthur From fhtapia at gmail.com Mon Mar 16 08:27:33 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 16 Mar 2009 06:27:33 -0700 Subject: [dba-SQLServer] NULLs In-Reply-To: <69857DFD66F64060A936BAD12220B9DF@AB> References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> <69857DFD66F64060A936BAD12220B9DF@AB> Message-ID: As with everything the answer is, it depends. How is your database architected? Logically the join between the employee and the dept can be a many to many which would allow you to have an unassigned employee however, I don't think that makes much business sense. Generally, a company does not hire an employee without knowing what position they need or want him for. You see? As for the argument about nulls, this topic reminds me of the old jc days on the access list. I still think there are valid places that require a null in your db. I have yet to see a performance hit for nulls in an index but it stands to reason that generally it doesn't make sense to allow them. I think this may affect you more depending on your collation you have chosen. Sent from my mobile On Mar 15, 2009, at 4:23 PM, "Asger Blond" wrote: > Coming in late I have a few comments here. > 1. In SQL Server you can make indexes on NULL allowed columns, and the > engine sure will use these indexes if they are useful for the queries. > 2. The column order of NULL allowed columns is of no importance in SQL > Server as it maintains header information for each row telling if NULL > allowed columns have a value or not. > 3. And Arthur: "obviously I forbid them in any FK column". Don't > agree, > seems quite allowable to me. Imagine you have a Department and an > Employee > table. Your Employee table has a FK referencing the Department > table. Now > you just hired a new employee but haven't decided yet the department > for the > employee. Isn't it reasonable to make a record for the new employee > leaving > the FK column NULL? > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arth > ur > Fuller > Sendt: 14. marts 2009 17:13 > Til: Discussion concerning MS SQL Server > Emne: [dba-SQLServer] NULLs > > Over on the MySQL group, a discussion has been waging about the use of > NULLs. One guy in particular is adamant about forbidding them > everywhere. He > goes so far as to say the existence of NULLs means bad design, pure > and > simple. I am not quite so radical about it, but I do look askance at > any > column that permits them, and obviously I forbid them in any FK > column. > > I tossed that in just to take the pulse of this group on this > general topic, > but my real question concerns something one of the posters wrote: > > "It seems that someone got bitten very hard in a soft area by a Null > one > day. > On a more practical level, Oracle recommended to design the table > with the > field where NULLs are to be expected at the end of the table, that > saves a > little space and two, as the use of indexes is invalidated in case > of nulls > its is better to place the important indexed fields toward the > beginning of > the table." > > I don't know whether this is also true of SQL Server. Do you? > > Arthur > _______________________________________________ > 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 ab-mi at post3.tele.dk Mon Mar 16 09:55:55 2009 From: ab-mi at post3.tele.dk (Asger Blond) Date: Mon, 16 Mar 2009 15:55:55 +0100 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB> Message-ID: > Logically the join between the employee and the dept can > be a many to many which would allow you to have an unassigned employee Don't know if I get your point here. Are you implying that an unassigned employee can't exist in a one to many relationship with referential integrity? If so you are not right: a FK constraint doesn't forbid NULLs in the FK column. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Francisco Tapia Sendt: 16. marts 2009 14:28 Til: Discussion concerning MS SQL Server Cc: Discussion concerning MS SQL Server Emne: Re: [dba-SQLServer] NULLs As with everything the answer is, it depends. How is your database architected? Logically the join between the employee and the dept can be a many to many which would allow you to have an unassigned employee however, I don't think that makes much business sense. Generally, a company does not hire an employee without knowing what position they need or want him for. You see? As for the argument about nulls, this topic reminds me of the old jc days on the access list. I still think there are valid places that require a null in your db. I have yet to see a performance hit for nulls in an index but it stands to reason that generally it doesn't make sense to allow them. I think this may affect you more depending on your collation you have chosen. Sent from my mobile On Mar 15, 2009, at 4:23 PM, "Asger Blond" wrote: > Coming in late I have a few comments here. > 1. In SQL Server you can make indexes on NULL allowed columns, and the > engine sure will use these indexes if they are useful for the queries. > 2. The column order of NULL allowed columns is of no importance in SQL > Server as it maintains header information for each row telling if NULL > allowed columns have a value or not. > 3. And Arthur: "obviously I forbid them in any FK column". Don't > agree, > seems quite allowable to me. Imagine you have a Department and an > Employee > table. Your Employee table has a FK referencing the Department > table. Now > you just hired a new employee but haven't decided yet the department > for the > employee. Isn't it reasonable to make a record for the new employee > leaving > the FK column NULL? > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arth > ur > Fuller > Sendt: 14. marts 2009 17:13 > Til: Discussion concerning MS SQL Server > Emne: [dba-SQLServer] NULLs > > Over on the MySQL group, a discussion has been waging about the use of > NULLs. One guy in particular is adamant about forbidding them > everywhere. He > goes so far as to say the existence of NULLs means bad design, pure > and > simple. I am not quite so radical about it, but I do look askance at > any > column that permits them, and obviously I forbid them in any FK > column. > > I tossed that in just to take the pulse of this group on this > general topic, > but my real question concerns something one of the posters wrote: > > "It seems that someone got bitten very hard in a soft area by a Null > one > day. > On a more practical level, Oracle recommended to design the table > with the > field where NULLs are to be expected at the end of the table, that > saves a > little space and two, as the use of indexes is invalidated in case > of nulls > its is better to place the important indexed fields toward the > beginning of > the table." > > I don't know whether this is also true of SQL Server. Do you? > > Arthur > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fhtapia at gmail.com Mon Mar 16 09:59:16 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 16 Mar 2009 07:59:16 -0700 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> <69857DFD66F64060A936BAD12220B9DF@AB> Message-ID: I was simply giving an example of how such a join might look. Also, I thought it would be odd for a company to hire an employee w/o already having a position to fill, generally I've never seen this to be true, but possibly does happen, just haven't ran into it myself. -- -Francisco http://sqlthis.blogspot.com | Tsql and More... On Mon, Mar 16, 2009 at 7:55 AM, Asger Blond wrote: > > Logically the join between the employee and the dept can > > be a many to many which would allow you to have an unassigned employee > > Don't know if I get your point here. Are you implying that an unassigned > employee can't exist in a one to many relationship with referential > integrity? If so you are not right: a FK constraint doesn't forbid NULLs in > the FK column. > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Francisco > Tapia > Sendt: 16. marts 2009 14:28 > Til: Discussion concerning MS SQL Server > Cc: Discussion concerning MS SQL Server > Emne: Re: [dba-SQLServer] NULLs > > As with everything the answer is, it depends. How is your database > architected? Logically the join between the employee and the dept can > be a many to many which would allow you to have an unassigned employee > however, I don't think that makes much business sense. Generally, a > company does not hire an employee without knowing what position they > need or want him for. You see? > > As for the argument about nulls, this topic reminds me of the old jc > days on the access list. I still think there are valid places that > require a null in your db. > > I have yet to see a performance hit for nulls in an index but it > stands to reason that generally it doesn't make sense to allow them. I > think this may affect you more depending on your collation you have > chosen. > > > Sent from my mobile > > On Mar 15, 2009, at 4:23 PM, "Asger Blond" wrote: > > > Coming in late I have a few comments here. > > 1. In SQL Server you can make indexes on NULL allowed columns, and the > > engine sure will use these indexes if they are useful for the queries. > > 2. The column order of NULL allowed columns is of no importance in SQL > > Server as it maintains header information for each row telling if NULL > > allowed columns have a value or not. > > 3. And Arthur: "obviously I forbid them in any FK column". Don't > > agree, > > seems quite allowable to me. Imagine you have a Department and an > > Employee > > table. Your Employee table has a FK referencing the Department > > table. Now > > you just hired a new employee but haven't decided yet the department > > for the > > employee. Isn't it reasonable to make a record for the new employee > > leaving > > the FK column NULL? > > > > Asger > > > > -----Oprindelig meddelelse----- > > Fra: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arth > > ur > > Fuller > > Sendt: 14. marts 2009 17:13 > > Til: Discussion concerning MS SQL Server > > Emne: [dba-SQLServer] NULLs > > > > Over on the MySQL group, a discussion has been waging about the use of > > NULLs. One guy in particular is adamant about forbidding them > > everywhere. He > > goes so far as to say the existence of NULLs means bad design, pure > > and > > simple. I am not quite so radical about it, but I do look askance at > > any > > column that permits them, and obviously I forbid them in any FK > > column. > > > > I tossed that in just to take the pulse of this group on this > > general topic, > > but my real question concerns something one of the posters wrote: > > > > "It seems that someone got bitten very hard in a soft area by a Null > > one > > day. > > On a more practical level, Oracle recommended to design the table > > with the > > field where NULLs are to be expected at the end of the table, that > > saves a > > little space and two, as the use of indexes is invalidated in case > > of nulls > > its is better to place the important indexed fields toward the > > beginning of > > the table." > > > > I don't know whether this is also true of SQL Server. Do you? > > > > Arthur > > _______________________________________________ > > 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 ssharkins at gmail.com Mon Mar 16 10:06:05 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Mon, 16 Mar 2009 11:06:05 -0400 Subject: [dba-SQLServer] NULLs References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB> Message-ID: <0B427E16D6F540EC9214BEC9B831058D@SusanOne> A hospital is a good example -- you can have a patient in the system, but not know anything about them, not even their name! If you're really worried about nulls, you can force users to choose from a set of null items: None, Unknown, and so on, which further forces problems because you're forcing a data type, regardless of how you fill it. Susan H. I was simply giving an example of how such a join might look. Also, I thought it would be odd for a company to hire an employee w/o already having a position to fill, generally I've never seen this to be true, but possibly does happen, just haven't ran into it myself. From fhtapia at gmail.com Mon Mar 16 10:16:53 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 16 Mar 2009 08:16:53 -0700 Subject: [dba-SQLServer] NULLs In-Reply-To: <0B427E16D6F540EC9214BEC9B831058D@SusanOne> References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> <69857DFD66F64060A936BAD12220B9DF@AB> <0B427E16D6F540EC9214BEC9B831058D@SusanOne> Message-ID: kudos, That is an excellent example! but I would think that this example would not justify nulls but enforce the odd -1 rule, ie, marking items as unknown. When was the last time you were allowed to leave an area of the medical form just blank? there is always an entry for -other-; data entry systems also generally allow for the unmistakable -other/unknown- field. it seems to make more sense to people than simply not filling out an area of the form. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Mon, Mar 16, 2009 at 8:06 AM, Susan Harkins wrote: > A hospital is a good example -- you can have a patient in the system, but > not know anything about them, not even their name! > > If you're really worried about nulls, you can force users to choose from a > set of null items: None, Unknown, and so on, which further forces problems > because you're forcing a data type, regardless of how you fill it. > > Susan H. > > > I was simply giving an example of how such a join might look. Also, I > thought it would be odd for a company to hire an employee w/o already > having > a position to fill, generally I've never seen this to be true, but possibly > does happen, just haven't ran into it myself. > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From ab-mi at post3.tele.dk Mon Mar 16 10:32:14 2009 From: ab-mi at post3.tele.dk (Asger Blond) Date: Mon, 16 Mar 2009 16:32:14 +0100 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB> Message-ID: OK, I see. Regarding the example: Ever heard of nepotism? The HR manager is asked to register the boss' son as a new employee not deciding for the moment which department should have the honour. And of course: Normally a FK constraint should not allow NULLs. But the fact that you have to explicitly prevent this using a NOT NULL constraint makes room for exceptions. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Francisco Tapia Sendt: 16. marts 2009 15:59 Til: Discussion concerning MS SQL Server Emne: Re: [dba-SQLServer] NULLs I was simply giving an example of how such a join might look. Also, I thought it would be odd for a company to hire an employee w/o already having a position to fill, generally I've never seen this to be true, but possibly does happen, just haven't ran into it myself. -- -Francisco http://sqlthis.blogspot.com | Tsql and More... On Mon, Mar 16, 2009 at 7:55 AM, Asger Blond wrote: > > Logically the join between the employee and the dept can > > be a many to many which would allow you to have an unassigned employee > > Don't know if I get your point here. Are you implying that an unassigned > employee can't exist in a one to many relationship with referential > integrity? If so you are not right: a FK constraint doesn't forbid NULLs in > the FK column. > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Francisco > Tapia > Sendt: 16. marts 2009 14:28 > Til: Discussion concerning MS SQL Server > Cc: Discussion concerning MS SQL Server > Emne: Re: [dba-SQLServer] NULLs > > As with everything the answer is, it depends. How is your database > architected? Logically the join between the employee and the dept can > be a many to many which would allow you to have an unassigned employee > however, I don't think that makes much business sense. Generally, a > company does not hire an employee without knowing what position they > need or want him for. You see? > > As for the argument about nulls, this topic reminds me of the old jc > days on the access list. I still think there are valid places that > require a null in your db. > > I have yet to see a performance hit for nulls in an index but it > stands to reason that generally it doesn't make sense to allow them. I > think this may affect you more depending on your collation you have > chosen. > > > Sent from my mobile > > On Mar 15, 2009, at 4:23 PM, "Asger Blond" wrote: > > > Coming in late I have a few comments here. > > 1. In SQL Server you can make indexes on NULL allowed columns, and the > > engine sure will use these indexes if they are useful for the queries. > > 2. The column order of NULL allowed columns is of no importance in SQL > > Server as it maintains header information for each row telling if NULL > > allowed columns have a value or not. > > 3. And Arthur: "obviously I forbid them in any FK column". Don't > > agree, > > seems quite allowable to me. Imagine you have a Department and an > > Employee > > table. Your Employee table has a FK referencing the Department > > table. Now > > you just hired a new employee but haven't decided yet the department > > for the > > employee. Isn't it reasonable to make a record for the new employee > > leaving > > the FK column NULL? > > > > Asger > > > > -----Oprindelig meddelelse----- > > Fra: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Arth > > ur > > Fuller > > Sendt: 14. marts 2009 17:13 > > Til: Discussion concerning MS SQL Server > > Emne: [dba-SQLServer] NULLs > > > > Over on the MySQL group, a discussion has been waging about the use of > > NULLs. One guy in particular is adamant about forbidding them > > everywhere. He > > goes so far as to say the existence of NULLs means bad design, pure > > and > > simple. I am not quite so radical about it, but I do look askance at > > any > > column that permits them, and obviously I forbid them in any FK > > column. > > > > I tossed that in just to take the pulse of this group on this > > general topic, > > but my real question concerns something one of the posters wrote: > > > > "It seems that someone got bitten very hard in a soft area by a Null > > one > > day. > > On a more practical level, Oracle recommended to design the table > > with the > > field where NULLs are to be expected at the end of the table, that > > saves a > > little space and two, as the use of indexes is invalidated in case > > of nulls > > its is better to place the important indexed fields toward the > > beginning of > > the table." > > > > I don't know whether this is also true of SQL Server. Do you? > > > > Arthur > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From dwaters at usinternet.com Mon Mar 16 10:33:28 2009 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 16 Mar 2009 10:33:28 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: <69857DFD66F64060A936BAD12220B9DF@AB> References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> <69857DFD66F64060A936BAD12220B9DF@AB> Message-ID: <5C563BFD2F8F4557BE0375DA601AB995@danwaters> On 3: If my tables were set up this way, I would have a department called 'Pending' into which all new employees would fall. Later when you decide the department you can change the FK. If I've set up a FK in a table, then I always want it populated. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Asger Blond Sent: Sunday, March 15, 2009 6:24 PM To: 'Discussion concerning MS SQL Server' Subject: Re: [dba-SQLServer] NULLs Coming in late I have a few comments here. 1. In SQL Server you can make indexes on NULL allowed columns, and the engine sure will use these indexes if they are useful for the queries. 2. The column order of NULL allowed columns is of no importance in SQL Server as it maintains header information for each row telling if NULL allowed columns have a value or not. 3. And Arthur: "obviously I forbid them in any FK column". Don't agree, seems quite allowable to me. Imagine you have a Department and an Employee table. Your Employee table has a FK referencing the Department table. Now you just hired a new employee but haven't decided yet the department for the employee. Isn't it reasonable to make a record for the new employee leaving the FK column NULL? Asger From fhtapia at gmail.com Mon Mar 16 10:46:03 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 16 Mar 2009 08:46:03 -0700 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> <69857DFD66F64060A936BAD12220B9DF@AB> Message-ID: Asger, I do see your point, I guess I'm playing more devil's advocate here since I DO user Nulls in my designs. In the business world, generally where the business is so large that they need to keep track of everyone in a database to know who works for who and what their titles are, I typically see a position created, and then it filled by the boss' son/nephew/etc, etc. etc. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Mon, Mar 16, 2009 at 8:32 AM, Asger Blond wrote: > OK, I see. > Regarding the example: Ever heard of nepotism? The HR manager is asked to > register the boss' son as a new employee not deciding for the moment which > department should have the honour. > And of course: Normally a FK constraint should not allow NULLs. But the > fact > that you have to explicitly prevent this using a NOT NULL constraint makes > room for exceptions. > > Asger > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Francisco > Tapia > Sendt: 16. marts 2009 15:59 > Til: Discussion concerning MS SQL Server > Emne: Re: [dba-SQLServer] NULLs > > I was simply giving an example of how such a join might look. Also, I > thought it would be odd for a company to hire an employee w/o already > having > a position to fill, generally I've never seen this to be true, but possibly > does happen, just haven't ran into it myself. > -- > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Mon, Mar 16, 2009 at 7:55 AM, Asger Blond wrote: > > > > Logically the join between the employee and the dept can > > > be a many to many which would allow you to have an unassigned employee > > > > Don't know if I get your point here. Are you implying that an unassigned > > employee can't exist in a one to many relationship with referential > > integrity? If so you are not right: a FK constraint doesn't forbid NULLs > in > > the FK column. > > > > Asger > > > > From ssharkins at gmail.com Mon Mar 16 10:57:24 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Mon, 16 Mar 2009 11:57:24 -0400 Subject: [dba-SQLServer] NULLs References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB><0B427E16D6F540EC9214BEC9B831058D@SusanOne> Message-ID: <37CCF306621642CC9E2CE7935D50C119@SusanOne> How do you reconcile the null item list with the actual data? The null list is text: Unknown, Not Applicable, and so on, but a social security number field is going to expect 9 digits, even if it's a text field, most will require those 9 digits -- how are you going to get around the other "best practice" issues for data entry and validation? Susan H. > kudos, That is an excellent example! but I would think that this > example > would not justify nulls but enforce the odd -1 rule, ie, marking items as > unknown. When was the last time you were allowed to leave an area of the > medical form just blank? there is always an entry for -other-; data > entry > systems also generally allow for the unmistakable -other/unknown- field. > > it seems to make more sense to people than simply not filling out an area > of > the form. > > > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Mon, Mar 16, 2009 at 8:06 AM, Susan Harkins > wrote: > >> A hospital is a good example -- you can have a patient in the system, but >> not know anything about them, not even their name! >> >> If you're really worried about nulls, you can force users to choose from >> a >> set of null items: None, Unknown, and so on, which further forces >> problems >> because you're forcing a data type, regardless of how you fill it. >> >> Susan H. >> >> >> I was simply giving an example of how such a join might look. Also, I >> thought it would be odd for a company to hire an employee w/o already >> having >> a position to fill, generally I've never seen this to be true, but >> possibly >> does happen, just haven't ran into it myself. >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From fhtapia at gmail.com Mon Mar 16 11:23:52 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 16 Mar 2009 09:23:52 -0700 Subject: [dba-SQLServer] NULLs In-Reply-To: <37CCF306621642CC9E2CE7935D50C119@SusanOne> References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com> <69857DFD66F64060A936BAD12220B9DF@AB> <0B427E16D6F540EC9214BEC9B831058D@SusanOne> <37CCF306621642CC9E2CE7935D50C119@SusanOne> Message-ID: Last time I looked at the emergency room, I never saw anyone get turned away for lack of social security. again, I'm just playing devil's advocate, simply to keep things interesting. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Mon, Mar 16, 2009 at 8:57 AM, Susan Harkins wrote: > How do you reconcile the null item list with the actual data? The null list > is text: Unknown, Not Applicable, and so on, but a social security number > field is going to expect 9 digits, even if it's a text field, most will > require those 9 digits -- how are you going to get around the other "best > practice" issues for data entry and validation? > > Susan H. > > > kudos, That is an excellent example! but I would think that this > > example > > would not justify nulls but enforce the odd -1 rule, ie, marking items > as > > unknown. When was the last time you were allowed to leave an area of the > > medical form just blank? there is always an entry for -other-; data > > entry > > systems also generally allow for the unmistakable -other/unknown- field. > > > > it seems to make more sense to people than simply not filling out an area > > of > > the form. > > > > > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Mon, Mar 16, 2009 at 8:06 AM, Susan Harkins > > wrote: > > > >> A hospital is a good example -- you can have a patient in the system, > but > >> not know anything about them, not even their name! > >> > >> If you're really worried about nulls, you can force users to choose from > >> a > >> set of null items: None, Unknown, and so on, which further forces > >> problems > >> because you're forcing a data type, regardless of how you fill it. > >> > >> Susan H. > >> > >> > >> I was simply giving an example of how such a join might look. Also, I > >> thought it would be odd for a company to hire an employee w/o already > >> having > >> a position to fill, generally I've never seen this to be true, but > >> possibly > >> does happen, just haven't ran into it myself. > >> > From ssharkins at gmail.com Mon Mar 16 11:27:21 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Mon, 16 Mar 2009 12:27:21 -0400 Subject: [dba-SQLServer] NULLs References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB><0B427E16D6F540EC9214BEC9B831058D@SusanOne><37CCF306621642CC9E2CE7935D50C119@SusanOne> Message-ID: Well, exactly... that's my point -- you don't have to have a ss# to get care. If the validation rules require a 9 digit number, how do you under, "None?" The question becomes, which is more important -- the no null rule or data validation? Which trumps? Susan H. > Last time I looked at the emergency room, I never saw anyone get turned > away > for lack of social security. again, I'm just playing devil's advocate, > simply to keep things interesting. From dwaters at usinternet.com Mon Mar 16 11:35:16 2009 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 16 Mar 2009 11:35:16 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB><0B427E16D6F540EC9214BEC9B831058D@SusanOne><37CCF306621642CC9E2CE7935D50C119@SusanOne> Message-ID: <8D8DEB0B73804592B92FDA1BDAC80D6F@danwaters> If I was designing that system, I would have two fields. One is the SSN, the other is a unique hospital defined number for people without a SSN. Either could be Null, but one of them must be filled in correctly. And neither could be a FK. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 11:27 AM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs Well, exactly... that's my point -- you don't have to have a ss# to get care. If the validation rules require a 9 digit number, how do you under, "None?" The question becomes, which is more important -- the no null rule or data validation? Which trumps? Susan H. > Last time I looked at the emergency room, I never saw anyone get turned > away > for lack of social security. again, I'm just playing devil's advocate, > simply to keep things interesting. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From ssharkins at gmail.com Mon Mar 16 11:38:30 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Mon, 16 Mar 2009 12:38:30 -0400 Subject: [dba-SQLServer] NULLs References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB><0B427E16D6F540EC9214BEC9B831058D@SusanOne><37CCF306621642CC9E2CE7935D50C119@SusanOne> <8D8DEB0B73804592B92FDA1BDAC80D6F@danwaters> Message-ID: So, what's the value of the unused field for each patient? Susan H. > If I was designing that system, I would have two fields. One is the SSN, > the other is a unique hospital defined number for people without a SSN. > Either could be Null, but one of them must be filled in correctly. And > neither could be a FK. From dwaters at usinternet.com Mon Mar 16 11:56:45 2009 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 16 Mar 2009 11:56:45 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB><0B427E16D6F540EC9214BEC9B831058D@SusanOne><37CCF306621642CC9E2CE7935D50C119@SusanOne><8D8DEB0B73804592B92FDA1BDAC80D6F@danwaters> Message-ID: It's Null - but your data validation must ensure that one of the two fields is correctly filled in. I see data validation as not applying to just single fields, but also applying to combinations of fields. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 11:39 AM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs So, what's the value of the unused field for each patient? Susan H. > If I was designing that system, I would have two fields. One is the SSN, > the other is a unique hospital defined number for people without a SSN. > Either could be Null, but one of them must be filled in correctly. And > neither could be a FK. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From ssharkins at gmail.com Mon Mar 16 12:07:36 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Mon, 16 Mar 2009 13:07:36 -0400 Subject: [dba-SQLServer] NULLs References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB><0B427E16D6F540EC9214BEC9B831058D@SusanOne><37CCF306621642CC9E2CE7935D50C119@SusanOne><8D8DEB0B73804592B92FDA1BDAC80D6F@danwaters> Message-ID: But you still have a null, and wasn't the argument against nulls, period? See, I'm having a real problem with the idea that null isn't valid and shouldn't be allowed at all. Susan H. > It's Null - but your data validation must ensure that one of the two > fields > is correctly filled in. I see data validation as not applying to just > single fields, but also applying to combinations of fields. From davidmcafee at gmail.com Mon Mar 16 12:19:28 2009 From: davidmcafee at gmail.com (David McAfee) Date: Mon, 16 Mar 2009 10:19:28 -0700 Subject: [dba-SQLServer] Why doesn't this work? In-Reply-To: <29f585dd0903152132r7088b91cr8aae9e35ace5e8bf@mail.gmail.com> References: <29f585dd0903152132r7088b91cr8aae9e35ace5e8bf@mail.gmail.com> Message-ID: <8786a4c00903161019x242424e0h2620d56eaf2e0243@mail.gmail.com> Works for me in SQL2000. Actually it didnt like PERSISTED. If I comment that line, it works for me. Function and table are created. David On Sun, Mar 15, 2009 at 9:32 PM, Arthur Fuller wrote: > I've been staring at this too long and I'm bleary now, so it's time for a > fresh pair of eyes... > > > USE [AdventureWorks] > GO > -- Create UDF to use in computed column expression > CREATE FUNCTION [dbo].[UDF_CalculatePay] > ( > @basicPay INT, > @BonusPercentage TINYINT, > @TaxPercentage TINYINT > ) > RETURNS INT > WITH SCHEMABINDING > AS BEGIN > DECLARE @TotalPay INT > SET @TotalPay = @basicPay + @basicPay * @bonusPercentage / 100 - > @basicPay > * @taxPercentage / 100 > RETURN @TotalPay > END > GO > > IF OBJECT_ID('CCIndexTest', 'U') IS NOT NULL > DROP TABLE CCIndexTest > GO > -- Create table CCIndexTest with two computed columns > CREATE TABLE [dbo].[CCIndexTest] > ( > [EmpNumb] [INT] NOT NULL, > [DOBirth] [DATETIME] NULL, > [DORetirement] AS ( DATEADD(YEAR, ( 60 ), [DOBirth]) - ( 1 ) ) > PERSISTED, > [BasicPay] [SMALLINT] NULL, > [BonusPercentage] [TINYINT] NULL, > [TaxPercentage] [TINYINT] NULL, > [TotalPay] AS [dbo].[UDF_CalculatePay](basicPay, BonusPercentage, > TaxPercentage) > ) > ON [PRIMARY] > GO > > > I get arrested on line 10 (of the Create Table part -- the udf compiles > fine) with "Invalid Column Name basicPay". I do not understand what is > wrong > with this. Do you? > > TIA, > Arthur > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From dwaters at usinternet.com Mon Mar 16 12:37:30 2009 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 16 Mar 2009 12:37:30 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB><0B427E16D6F540EC9214BEC9B831058D@SusanOne><37CCF306621642CC9E2CE7935D50C119@SusanOne><8D8DEB0B73804592B92FDA1BDAC80D6F@danwaters> Message-ID: Well - that wasn't my argument. I think Nulls are fine and appropriate. What I would not do myself is allow a FK to be Null. To me that would indicate a poor table/app design. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 12:08 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs But you still have a null, and wasn't the argument against nulls, period? See, I'm having a real problem with the idea that null isn't valid and shouldn't be allowed at all. Susan H. > It's Null - but your data validation must ensure that one of the two > fields > is correctly filled in. I see data validation as not applying to just > single fields, but also applying to combinations of fields. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From Gustav at cactus.dk Mon Mar 16 12:42:57 2009 From: Gustav at cactus.dk (Gustav Brock) Date: Mon, 16 Mar 2009 18:42:57 +0100 Subject: [dba-SQLServer] NULLs Message-ID: Hi Dan I think you - or someone else? - are contradicting yourself or someone else(?) - at least "me am totalyful confusticated" now! /gustav >>> dwaters at usinternet.com 16-03-2009 18:37 >>> Well - that wasn't my argument. I think Nulls are fine and appropriate. What I would not do myself is allow a FK to be Null. To me that would indicate a poor table/app design. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 12:08 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs But you still have a null, and wasn't the argument against nulls, period? See, I'm having a real problem with the idea that null isn't valid and shouldn't be allowed at all. Susan H. > It's Null - but your data validation must ensure that one of the two > fields > is correctly filled in. I see data validation as not applying to just > single fields, but also applying to combinations of fields. From ssharkins at gmail.com Mon Mar 16 12:47:11 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Mon, 16 Mar 2009 13:47:11 -0400 Subject: [dba-SQLServer] NULLs References: <29f585dd0903140912l32386220x98e921ab68a7f8f1@mail.gmail.com><69857DFD66F64060A936BAD12220B9DF@AB><0B427E16D6F540EC9214BEC9B831058D@SusanOne><37CCF306621642CC9E2CE7935D50C119@SusanOne><8D8DEB0B73804592B92FDA1BDAC80D6F@danwaters> Message-ID: <602DDB6AD8B742BFBC89BDE79C37ADCB@SusanOne> Okay -- I understand. Susan H. > Well - that wasn't my argument. I think Nulls are fine and appropriate. > > What I would not do myself is allow a FK to be Null. To me that would > indicate a poor table/app design. From dwaters at usinternet.com Mon Mar 16 12:50:52 2009 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 16 Mar 2009 12:50:52 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: References: Message-ID: Hi Gustav - I know I'm contradicting someone else! But if you find that I'm contradicting myself - please contradict me right back! ;-) Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Monday, March 16, 2009 12:43 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] NULLs Hi Dan I think you - or someone else? - are contradicting yourself or someone else(?) - at least "me am totalyful confusticated" now! /gustav >>> dwaters at usinternet.com 16-03-2009 18:37 >>> Well - that wasn't my argument. I think Nulls are fine and appropriate. What I would not do myself is allow a FK to be Null. To me that would indicate a poor table/app design. Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 12:08 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs But you still have a null, and wasn't the argument against nulls, period? See, I'm having a real problem with the idea that null isn't valid and shouldn't be allowed at all. Susan H. > It's Null - but your data validation must ensure that one of the two > fields > is correctly filled in. I see data validation as not applying to just > single fields, but also applying to combinations of fields. _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From ssharkins at gmail.com Mon Mar 16 12:51:55 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Mon, 16 Mar 2009 13:51:55 -0400 Subject: [dba-SQLServer] NULLs References: Message-ID: <622CF91D365242B78840F3E3D618799B@SusanOne> I'm more than confused and Gustav, if you can admit it, I can too! A FK is just a primary key in a related table, so how can it be null to begin with? I can see the record not having a match in the related table... if that's what you mean. Susan H. > Hi Dan > > I think you - or someone else? - are contradicting yourself or someone > else(?) - at least "me am totalyful confusticated" now! From Robert at webedb.com Mon Mar 16 13:19:16 2009 From: Robert at webedb.com (Robert) Date: Mon, 16 Mar 2009 14:19:16 -0400 Subject: [dba-SQLServer] NULLs Message-ID: <64383615c61e4157be6b954b5127873d@webedb.com> A foreign key as a null is fine. For example if I have a Name table and a Name Suffix table. Not every one has a name suffix of Jr., Sr. II, III, etc. so in the Name table, that value would be null. Or did I miss something? Robert ---------------------------------------- From: dba-sqlserver-request at databaseadvisors.com Sent: Monday, March 16, 2009 2:01 PM To: dba-sqlserver at databaseadvisors.com Date: Mon, 16 Mar 2009 13:51:55 -0400 From: "Susan Harkins" Subject: Re: [dba-SQLServer] NULLs To: "Discussion concerning MS SQL Server" Message-ID: <622CF91D365242B78840F3E3D618799B at SusanOne> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original I'm more than confused and Gustav, if you can admit it, I can too! A FK is just a primary key in a related table, so how can it be null to begin with? I can see the record not having a match in the related table... if that's what you mean. Susan H. > Hi Dan > > I think you - or someone else? - are contradicting yourself or someone > else(?) - at least "me am totalyful confusticated" now! From dwaters at usinternet.com Mon Mar 16 13:22:06 2009 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 16 Mar 2009 13:22:06 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: <622CF91D365242B78840F3E3D618799B@SusanOne> References: <622CF91D365242B78840F3E3D618799B@SusanOne> Message-ID: Good Question! Let's say you have a primary table and a sub table connected by a one to many relationship. Normally, the FK in the sub table is equal to the PK in the main table for at least one record. But, let say the developer has created a form which is bound only to the sub table. In this case, under one condition, that form could add a record to the sub table with no corresponding record in the primary table. The condition is that the table relationship was created so that referential integrity was NOT enforced. If referential integrity is enforced, the database will not allow the creation of a record in a sub table without a corresponding record in the primary table. When a developer creates a relationship between two tables in the Relationships window, a dialog box appears with a checkbox titled 'Enforce Referential Integrity'. It's unchecked by default. Normally, a developer does want referential integrity enforced, but it is his/her choice. I've been developing for many years, but can't think of a time when I did this - but I'm sure someone here can give a good example. Hope this helps! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 12:52 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs I'm more than confused and Gustav, if you can admit it, I can too! A FK is just a primary key in a related table, so how can it be null to begin with? I can see the record not having a match in the related table... if that's what you mean. Susan H. > Hi Dan > > I think you - or someone else? - are contradicting yourself or someone > else(?) - at least "me am totalyful confusticated" now! _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fhtapia at gmail.com Mon Mar 16 13:36:10 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 16 Mar 2009 11:36:10 -0700 Subject: [dba-SQLServer] NULLs In-Reply-To: <64383615c61e4157be6b954b5127873d@webedb.com> References: <64383615c61e4157be6b954b5127873d@webedb.com> Message-ID: Depending on the level of normalization you'd have the name table and a junction table in between it and the titles table to read something like NameTable NameID FirstName LastName TitleTable TitleID TitleValue NameTitleJunct Table NameID TitleID In this scenario you would not have a null.... (and yes I am totaly playing devi's advocate as I use Nulls in my designs) -Francisco http://sqlthis.blogspot.com | Tsql and More... On Mon, Mar 16, 2009 at 11:19 AM, Robert wrote: > > A foreign key as a null is fine. > > For example if I have a Name table and a Name Suffix table. > Not every one has a name suffix of Jr., Sr. II, III, etc. so in > the Name table, that value would be null. > > Or did I miss something? > > Robert > > ---------------------------------------- > > From: > dba-sqlserver-request at databaseadvisors.com > Sent: Monday, March 16, 2009 2:01 PM > To: dba-sqlserver at databaseadvisors.com > Date: Mon, 16 Mar 2009 13:51:55 -0400 > From: "Susan Harkins" > Subject: Re: [dba-SQLServer] NULLs > To: "Discussion concerning MS SQL Server" > > Message-ID: <622CF91D365242B78840F3E3D618799B at SusanOne> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > I'm more than confused and Gustav, if you can admit it, I can too! > > A FK is just a primary key in a related table, so how can it be null to > begin with? I can see the record not having a match in the related table... > if that's what you mean. > > Susan H. > > > Hi Dan > > > > I think you - or someone else? - are contradicting yourself or someone > > else(?) - at least "me am totalyful confusticated" now! > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From ab-mi at post3.tele.dk Mon Mar 16 13:40:49 2009 From: ab-mi at post3.tele.dk (Asger Blond) Date: Mon, 16 Mar 2009 19:40:49 +0100 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <622CF91D365242B78840F3E3D618799B@SusanOne> Message-ID: >The condition is that the table relationship was created so that >Referential integrity was NOT enforced. If referential integrity is >enforced, the database will not allow the creation of a record in a sub >table without a corresponding record in the primary table. Dan, you are not right. Enforcing referential integrity (= making a FK constraint) does NOT disallow NULLs in the referencing column (the FK column) of the sub table. This is a common misconception to which I pointed in previous postings. If you want to disallow NULLs in the FK you have to make a NOT NULL constraint on the FK. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Dan Waters Sendt: 16. marts 2009 19:22 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] NULLs Good Question! Let's say you have a primary table and a sub table connected by a one to many relationship. Normally, the FK in the sub table is equal to the PK in the main table for at least one record. But, let say the developer has created a form which is bound only to the sub table. In this case, under one condition, that form could add a record to the sub table with no corresponding record in the primary table. The condition is that the table relationship was created so that referential integrity was NOT enforced. If referential integrity is enforced, the database will not allow the creation of a record in a sub table without a corresponding record in the primary table. When a developer creates a relationship between two tables in the Relationships window, a dialog box appears with a checkbox titled 'Enforce Referential Integrity'. It's unchecked by default. Normally, a developer does want referential integrity enforced, but it is his/her choice. I've been developing for many years, but can't think of a time when I did this - but I'm sure someone here can give a good example. Hope this helps! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 12:52 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs I'm more than confused and Gustav, if you can admit it, I can too! A FK is just a primary key in a related table, so how can it be null to begin with? I can see the record not having a match in the related table... if that's what you mean. Susan H. > Hi Dan > > I think you - or someone else? - are contradicting yourself or someone > else(?) - at least "me am totalyful confusticated" now! _______________________________________________ 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 dwaters at usinternet.com Mon Mar 16 14:17:53 2009 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 16 Mar 2009 14:17:53 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <622CF91D365242B78840F3E3D618799B@SusanOne> Message-ID: Hi Asger, I stand corrected! I just tried this with two simple tables and a relationship that did enforce referential integrity, and did have cascade update and delete checked. While I can't create a new record in the subtable that doesn't have a matching number in it's FK field, I could delete the number in the FK field after the record was initially saved. I didn't know this could be done - even though referential integrity was checked, I could easily defeat it! Dangerous! Thanks! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Asger Blond Sent: Monday, March 16, 2009 1:41 PM To: 'Discussion concerning MS SQL Server' Subject: Re: [dba-SQLServer] NULLs >The condition is that the table relationship was created so that >Referential integrity was NOT enforced. If referential integrity is >enforced, the database will not allow the creation of a record in a sub >table without a corresponding record in the primary table. Dan, you are not right. Enforcing referential integrity (= making a FK constraint) does NOT disallow NULLs in the referencing column (the FK column) of the sub table. This is a common misconception to which I pointed in previous postings. If you want to disallow NULLs in the FK you have to make a NOT NULL constraint on the FK. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Dan Waters Sendt: 16. marts 2009 19:22 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] NULLs Good Question! Let's say you have a primary table and a sub table connected by a one to many relationship. Normally, the FK in the sub table is equal to the PK in the main table for at least one record. But, let say the developer has created a form which is bound only to the sub table. In this case, under one condition, that form could add a record to the sub table with no corresponding record in the primary table. The condition is that the table relationship was created so that referential integrity was NOT enforced. If referential integrity is enforced, the database will not allow the creation of a record in a sub table without a corresponding record in the primary table. When a developer creates a relationship between two tables in the Relationships window, a dialog box appears with a checkbox titled 'Enforce Referential Integrity'. It's unchecked by default. Normally, a developer does want referential integrity enforced, but it is his/her choice. I've been developing for many years, but can't think of a time when I did this - but I'm sure someone here can give a good example. Hope this helps! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 12:52 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs I'm more than confused and Gustav, if you can admit it, I can too! A FK is just a primary key in a related table, so how can it be null to begin with? I can see the record not having a match in the related table... if that's what you mean. Susan H. > Hi Dan > > I think you - or someone else? - are contradicting yourself or someone > else(?) - at least "me am totalyful confusticated" now! _______________________________________________ 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 fuller.artful at gmail.com Mon Mar 16 15:18:02 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Mon, 16 Mar 2009 16:18:02 -0400 Subject: [dba-SQLServer] Why doesn't this work? In-Reply-To: <8786a4c00903161019x242424e0h2620d56eaf2e0243@mail.gmail.com> References: <29f585dd0903152132r7088b91cr8aae9e35ace5e8bf@mail.gmail.com> <8786a4c00903161019x242424e0h2620d56eaf2e0243@mail.gmail.com> Message-ID: <29f585dd0903161318g15d597e7n338779cea7d110b8@mail.gmail.com> I found the same thing. Comment out the PERSISTED part and it works. Ironically, the source of the code was an article on using PERSISTED :) A. On Mon, Mar 16, 2009 at 1:19 PM, David McAfee wrote: > Works for me in SQL2000. > > Actually it didnt like PERSISTED. If I comment that line, it works for me. > > Function and table are created. > > David > From ab-mi at post3.tele.dk Mon Mar 16 16:07:19 2009 From: ab-mi at post3.tele.dk (Asger Blond) Date: Mon, 16 Mar 2009 22:07:19 +0100 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <622CF91D365242B78840F3E3D618799B@SusanOne> Message-ID: Hi Dan, Referential integrity says: "You can't have a value in a foreign key which isn't present in the primary key". But you can have a NULL in the foreign key. Why? Because NULL isn't a value. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Dan Waters Sendt: 16. marts 2009 20:18 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] NULLs Hi Asger, I stand corrected! I just tried this with two simple tables and a relationship that did enforce referential integrity, and did have cascade update and delete checked. While I can't create a new record in the subtable that doesn't have a matching number in it's FK field, I could delete the number in the FK field after the record was initially saved. I didn't know this could be done - even though referential integrity was checked, I could easily defeat it! Dangerous! Thanks! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Asger Blond Sent: Monday, March 16, 2009 1:41 PM To: 'Discussion concerning MS SQL Server' Subject: Re: [dba-SQLServer] NULLs >The condition is that the table relationship was created so that >Referential integrity was NOT enforced. If referential integrity is >enforced, the database will not allow the creation of a record in a sub >table without a corresponding record in the primary table. Dan, you are not right. Enforcing referential integrity (= making a FK constraint) does NOT disallow NULLs in the referencing column (the FK column) of the sub table. This is a common misconception to which I pointed in previous postings. If you want to disallow NULLs in the FK you have to make a NOT NULL constraint on the FK. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Dan Waters Sendt: 16. marts 2009 19:22 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] NULLs Good Question! Let's say you have a primary table and a sub table connected by a one to many relationship. Normally, the FK in the sub table is equal to the PK in the main table for at least one record. But, let say the developer has created a form which is bound only to the sub table. In this case, under one condition, that form could add a record to the sub table with no corresponding record in the primary table. The condition is that the table relationship was created so that referential integrity was NOT enforced. If referential integrity is enforced, the database will not allow the creation of a record in a sub table without a corresponding record in the primary table. When a developer creates a relationship between two tables in the Relationships window, a dialog box appears with a checkbox titled 'Enforce Referential Integrity'. It's unchecked by default. Normally, a developer does want referential integrity enforced, but it is his/her choice. I've been developing for many years, but can't think of a time when I did this - but I'm sure someone here can give a good example. Hope this helps! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 12:52 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs I'm more than confused and Gustav, if you can admit it, I can too! A FK is just a primary key in a related table, so how can it be null to begin with? I can see the record not having a match in the related table... if that's what you mean. Susan H. > Hi Dan > > I think you - or someone else? - are contradicting yourself or someone > else(?) - at least "me am totalyful confusticated" now! _______________________________________________ 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 dwaters at usinternet.com Mon Mar 16 16:31:28 2009 From: dwaters at usinternet.com (Dan Waters) Date: Mon, 16 Mar 2009 16:31:28 -0500 Subject: [dba-SQLServer] NULLs In-Reply-To: References: <622CF91D365242B78840F3E3D618799B@SusanOne> Message-ID: <60575B919889472AA7BB2BABF849533D@danwaters> Hi Asger, I do appreciate you pointing this out - might save myself a major problem someday! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Asger Blond Sent: Monday, March 16, 2009 4:07 PM To: 'Discussion concerning MS SQL Server' Subject: Re: [dba-SQLServer] NULLs Hi Dan, Referential integrity says: "You can't have a value in a foreign key which isn't present in the primary key". But you can have a NULL in the foreign key. Why? Because NULL isn't a value. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Dan Waters Sendt: 16. marts 2009 20:18 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] NULLs Hi Asger, I stand corrected! I just tried this with two simple tables and a relationship that did enforce referential integrity, and did have cascade update and delete checked. While I can't create a new record in the subtable that doesn't have a matching number in it's FK field, I could delete the number in the FK field after the record was initially saved. I didn't know this could be done - even though referential integrity was checked, I could easily defeat it! Dangerous! Thanks! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Asger Blond Sent: Monday, March 16, 2009 1:41 PM To: 'Discussion concerning MS SQL Server' Subject: Re: [dba-SQLServer] NULLs >The condition is that the table relationship was created so that >Referential integrity was NOT enforced. If referential integrity is >enforced, the database will not allow the creation of a record in a sub >table without a corresponding record in the primary table. Dan, you are not right. Enforcing referential integrity (= making a FK constraint) does NOT disallow NULLs in the referencing column (the FK column) of the sub table. This is a common misconception to which I pointed in previous postings. If you want to disallow NULLs in the FK you have to make a NOT NULL constraint on the FK. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Dan Waters Sendt: 16. marts 2009 19:22 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] NULLs Good Question! Let's say you have a primary table and a sub table connected by a one to many relationship. Normally, the FK in the sub table is equal to the PK in the main table for at least one record. But, let say the developer has created a form which is bound only to the sub table. In this case, under one condition, that form could add a record to the sub table with no corresponding record in the primary table. The condition is that the table relationship was created so that referential integrity was NOT enforced. If referential integrity is enforced, the database will not allow the creation of a record in a sub table without a corresponding record in the primary table. When a developer creates a relationship between two tables in the Relationships window, a dialog box appears with a checkbox titled 'Enforce Referential Integrity'. It's unchecked by default. Normally, a developer does want referential integrity enforced, but it is his/her choice. I've been developing for many years, but can't think of a time when I did this - but I'm sure someone here can give a good example. Hope this helps! Dan -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan Harkins Sent: Monday, March 16, 2009 12:52 PM To: Discussion concerning MS SQL Server Subject: Re: [dba-SQLServer] NULLs I'm more than confused and Gustav, if you can admit it, I can too! A FK is just a primary key in a related table, so how can it be null to begin with? I can see the record not having a match in the related table... if that's what you mean. Susan H. > Hi Dan > > I think you - or someone else? - are contradicting yourself or someone > else(?) - at least "me am totalyful confusticated" now! _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From Gustav at cactus.dk Tue Mar 17 12:46:14 2009 From: Gustav at cactus.dk (Gustav Brock) Date: Tue, 17 Mar 2009 18:46:14 +0100 Subject: [dba-SQLServer] VS cannot connect to SQL Server 2005 Message-ID: Hi all Any idea why my VS2008 cannot connect to a SQL Server 2005 Express on a remote machine? Plenty of reasons, I know, except from the fact that I from SQL Management Studio also on my workstation nicely can connect to that server: Microsoft SQL Server Management Studio Express 9.00.4035.00 Microsoft Data Access Components (MDAC) 2000.085.1132.00 (xpsp.080413-0852) Microsoft MSXML 2.6 3.0 4.0 5.0 6.0 Microsoft Internet Explorer 7.0.5730.11 Microsoft .NET Framework 2.0.50727.3082 Operating System 5.1.2600 --- Microsoft Visual Studio 2008 Version 9.0.30729.1 SP Microsoft .NET Framework Version 3.5 SP1 Installed Edition: Standard Targe .Net in the solution is 2.0. /gustav From fhtapia at gmail.com Tue Mar 17 16:24:57 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 17 Mar 2009 14:24:57 -0700 Subject: [dba-SQLServer] VS cannot connect to SQL Server 2005 In-Reply-To: References: Message-ID: What is the authentication you are selecting for VS2008? -Francisco http://sqlthis.blogspot.com | Tsql and More... On Tue, Mar 17, 2009 at 10:46 AM, Gustav Brock wrote: > Hi all > > Any idea why my VS2008 cannot connect to a SQL Server 2005 Express on a > remote machine? Plenty of reasons, I know, except from the fact that I from > SQL Management Studio also on my workstation nicely can connect to that > server: > > Microsoft SQL Server Management Studio Express > 9.00.4035.00 > Microsoft Data Access Components (MDAC) > 2000.085.1132.00 (xpsp.080413-0852) > Microsoft MSXML > 2.6 3.0 4.0 5.0 6.0 > Microsoft Internet Explorer > 7.0.5730.11 > Microsoft .NET Framework > 2.0.50727.3082 > Operating System > 5.1.2600 > > --- > > Microsoft Visual Studio 2008 > Version 9.0.30729.1 SP > Microsoft .NET Framework > Version 3.5 SP1 > > Installed Edition: Standard > > Targe .Net in the solution is 2.0. > > /gustav > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fuller.artful at gmail.com Tue Mar 17 18:35:58 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 17 Mar 2009 19:35:58 -0400 Subject: [dba-SQLServer] Read-only databases? Message-ID: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> Now I've gone and buggered things up nicely. I was running out of space on drive c:\ so I decided to move all my SQL databases to drive e:\. I've done that many times without incident: 1. Detach the database(s) in question. 2. Move it to the new location. 3. Re-attach the database. However, this time it didn't work. Several databases were attached, all right, but are marked read-only. And two databases could not be attached. The message I got said that the files are read-only and the fix is to change their attributes. How do I change the first group of databases so they are not read-only? I checked the attributes of the second group of files and they are not marked read-only. What is the problem here? Any suggestions? Thanks, Arthur From fhtapia at gmail.com Tue Mar 17 21:22:28 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 17 Mar 2009 19:22:28 -0700 Subject: [dba-SQLServer] Read-only databases? In-Reply-To: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> Message-ID: I've yet to run into that issue, but it sound like maybe the folder you created on drive e: was possibly set with read-only permissions? Are you saying that the engine is reading these as read-only? maybe detaching them checking the attribute then re-attaching? -Francisco http://sqlthis.blogspot.com | Tsql and More... On Tue, Mar 17, 2009 at 4:35 PM, Arthur Fuller wrote: > Now I've gone and buggered things up nicely. I was running out of space on > drive c:\ so I decided to move all my SQL databases to drive e:\. I've done > that many times without incident: > > 1. Detach the database(s) in question. > 2. Move it to the new location. > 3. Re-attach the database. > > However, this time it didn't work. Several databases were attached, all > right, but are marked read-only. And two databases could not be attached. > The message I got said that the files are read-only and the fix is to > change > their attributes. > > How do I change the first group of databases so they are not read-only? > I checked the attributes of the second group of files and they are not > marked read-only. > > What is the problem here? Any suggestions? > > Thanks, > Arthur > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fuller.artful at gmail.com Tue Mar 17 21:48:45 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 17 Mar 2009 22:48:45 -0400 Subject: [dba-SQLServer] Read-only databases? In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> Message-ID: <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> I got around the problem by creating new databases and then let the import wizard do the rest. Presto change-oh done. Whew. On Tue, Mar 17, 2009 at 10:22 PM, Francisco Tapia wrote: > I've yet to run into that issue, but it sound like maybe the folder you > created on drive e: was possibly set with read-only permissions? Are you > saying that the engine is reading these as read-only? maybe detaching them > checking the attribute then re-attaching? > > From fhtapia at gmail.com Wed Mar 18 00:01:54 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 17 Mar 2009 22:01:54 -0700 Subject: [dba-SQLServer] Read-only databases? In-Reply-To: <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> Message-ID: Ah... ok. still kind of curious when moving things around that these write permissions got in the way. what was your OS? -Francisco http://sqlthis.blogspot.com | Tsql and More... On Tue, Mar 17, 2009 at 7:48 PM, Arthur Fuller wrote: > I got around the problem by creating new databases and then let the import > wizard do the rest. Presto change-oh done. Whew. > > On Tue, Mar 17, 2009 at 10:22 PM, Francisco Tapia > wrote: > > > I've yet to run into that issue, but it sound like maybe the folder you > > created on drive e: was possibly set with read-only permissions? Are you > > saying that the engine is reading these as read-only? maybe detaching > them > > checking the attribute then re-attaching? > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From Gustav at cactus.dk Wed Mar 18 03:31:02 2009 From: Gustav at cactus.dk (Gustav Brock) Date: Wed, 18 Mar 2009 09:31:02 +0100 Subject: [dba-SQLServer] VS cannot connect to SQL Server 2005 Message-ID: Hi Francisco That is SQL Server. However, I managed to get it working. I started from the Configuration Manager the SQL Server Browser and that made a difference. By the way, SQL Management Studio defaults to a packet size of 4096 while when you create connections from within VS the default is 8000. Do you know what is to prefer and must these match? /gustav >>> fhtapia at gmail.com 17-03-2009 22:24 >>> What is the authentication you are selecting for VS2008? -Francisco http://sqlthis.blogspot.com | Tsql and More... On Tue, Mar 17, 2009 at 10:46 AM, Gustav Brock wrote: > Hi all > > Any idea why my VS2008 cannot connect to a SQL Server 2005 Express on a > remote machine? Plenty of reasons, I know, except from the fact that I from > SQL Management Studio also on my workstation nicely can connect to that > server: > > Microsoft SQL Server Management Studio Express > 9.00.4035.00 > Microsoft Data Access Components (MDAC) > 2000.085.1132.00 (xpsp.080413-0852) > Microsoft MSXML > 2.6 3.0 4.0 5.0 6.0 > Microsoft Internet Explorer > 7.0.5730.11 > Microsoft .NET Framework > 2.0.50727.3082 > Operating System > 5.1.2600 > > --- > > Microsoft Visual Studio 2008 > Version 9.0.30729.1 SP > Microsoft .NET Framework > Version 3.5 SP1 > > Installed Edition: Standard > > Targe .Net in the solution is 2.0. > > /gustav From fuller.artful at gmail.com Wed Mar 18 03:40:29 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Wed, 18 Mar 2009 04:40:29 -0400 Subject: [dba-SQLServer] Read-only databases? In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> Message-ID: <29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> OS is Vista with a service pack. Fortunately the recovery was easy, but it did kick me in the butt and remind me that it's time to back up everything. So once I got everything fixed up, I immediately fired up trusty Red Gate SQL Backup and covered my ass. Speaking of which, do you use RG SQL Backup or any other Red Gate stuff? SQL Backup is pretty amazing. It's more than twice as fast as the built-in backup and even with minimal compression, its file size is about 1/3 of the MS .bak files. A. On Wed, Mar 18, 2009 at 1:01 AM, Francisco Tapia wrote: > Ah... ok. still kind of curious when moving things around that these write > permissions got in the way. what was your OS? > > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > From fuller.artful at gmail.com Wed Mar 18 04:09:05 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Wed, 18 Mar 2009 05:09:05 -0400 Subject: [dba-SQLServer] VS cannot connect to SQL Server 2005 In-Reply-To: References: Message-ID: <29f585dd0903180209s5af227c2s8305d970ee992d05@mail.gmail.com> My understanding is that increasing the packet size is most beneficial if you are working with LoBs such as graphics or XML data. Larger packets mean fewer round trips. For "normal" data there is not much gain, if any. A. On Wed, Mar 18, 2009 at 4:31 AM, Gustav Brock wrote: > Hi Francisco > > That is SQL Server. > However, I managed to get it working. I started from the Configuration > Manager the SQL Server Browser and that made a difference. > > By the way, SQL Management Studio defaults to a packet size of 4096 while > when you create connections from within VS the default is 8000. > Do you know what is to prefer and must these match? > > /gustav > From Gustav at cactus.dk Wed Mar 18 04:17:38 2009 From: Gustav at cactus.dk (Gustav Brock) Date: Wed, 18 Mar 2009 10:17:38 +0100 Subject: [dba-SQLServer] VS cannot connect to SQL Server 2005 Message-ID: Hi Arthur Thanks. Normal data here. But isn't this time of the day/night bedtime for you? /gustav >>> fuller.artful at gmail.com 18-03-2009 10:09 >>> My understanding is that increasing the packet size is most beneficial if you are working with LoBs such as graphics or XML data. Larger packets mean fewer round trips. For "normal" data there is not much gain, if any. A. On Wed, Mar 18, 2009 at 4:31 AM, Gustav Brock wrote: > Hi Francisco > > That is SQL Server. > However, I managed to get it working. I started from the Configuration > Manager the SQL Server Browser and that made a difference. > > By the way, SQL Management Studio defaults to a packet size of 4096 while > when you create connections from within VS the default is 8000. > Do you know what is to prefer and must these match? > > /gustav From fuller.artful at gmail.com Wed Mar 18 05:04:14 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Wed, 18 Mar 2009 06:04:14 -0400 Subject: [dba-SQLServer] VS cannot connect to SQL Server 2005 In-Reply-To: References: Message-ID: <29f585dd0903180304x408c7c03v734393330b3b8342@mail.gmail.com> What can I say, Gustav. I habitually awaken at 5am, but this morning it was 4am. On Wed, Mar 18, 2009 at 5:17 AM, Gustav Brock wrote: > Hi Arthur > > Thanks. Normal data here. > But isn't this time of the day/night bedtime for you? > > /gustav > From Gustav at cactus.dk Wed Mar 18 05:13:18 2009 From: Gustav at cactus.dk (Gustav Brock) Date: Wed, 18 Mar 2009 11:13:18 +0100 Subject: [dba-SQLServer] OT: Arthur's bedtime (was: VS cannot connect to SQL Server 2005) Message-ID: Hi Arthur Pretty early to me. Depends, of cours, when you hit the pillow. /gustav >>> fuller.artful at gmail.com 18-03-2009 11:04 >>> What can I say, Gustav. I habitually awaken at 5am, but this morning it was 4am. On Wed, Mar 18, 2009 at 5:17 AM, Gustav Brock wrote: > Hi Arthur > > Thanks. Normal data here. > But isn't this time of the day/night bedtime for you? > > /gustav From fhtapia at gmail.com Wed Mar 18 10:20:58 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 18 Mar 2009 08:20:58 -0700 Subject: [dba-SQLServer] Read-only databases? In-Reply-To: <29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> <29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> Message-ID: Yup, We deal with large databases on a regular basis here now, our largest is 1.5 tb and MS backups for this would be too big. So my schedules are, weekends kick off a full backup, and weekly I kick off a Differential backup, w/ transaction log backups kicking off whenever the logs hit about 60% of it's full size. I dig Red-Gate products, I was turned on to it by a college who was trying to move data and schema changes to another server, but had different schemas and data in each set. I checked out Sql Compare first about 3 years ago, and have been a customer ever since. Currently I also use the sql-prompt 3.0 product, though when I connect to the 1.5 terabyte databases I need to turn it off or the caching of all 64k tables will kill it's productivity. Several other databases that we have are shy of 800gb and have maybe about 24k tables and with those sql-prompt works just fine. I recently took a look at their Sql-Documentor and that is a great tool! -Francisco http://sqlthis.blogspot.com | Tsql and More... On Wed, Mar 18, 2009 at 1:40 AM, Arthur Fuller wrote: > OS is Vista with a service pack. Fortunately the recovery was easy, but it > did kick me in the butt and remind me that it's time to back up everything. > So once I got everything fixed up, I immediately fired up trusty Red Gate > SQL Backup and covered my ass. Speaking of which, do you use RG SQL Backup > or any other Red Gate stuff? SQL Backup is pretty amazing. It's more than > twice as fast as the built-in backup and even with minimal compression, its > file size is about 1/3 of the MS .bak files. > > A. > > On Wed, Mar 18, 2009 at 1:01 AM, Francisco Tapia > wrote: > > > Ah... ok. still kind of curious when moving things around that these > write > > permissions got in the way. what was your OS? > > > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From markamatte at hotmail.com Tue Mar 24 09:25:40 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Tue, 24 Mar 2009 14:25:40 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> <29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> Message-ID: Hello All, I have successfully linked SQL Server2005 to Teradata. I can pull data from...and insert records into Teradata. I have NOT been able to create or drop a table in Teradata from SQL Server. Can anyone help with syntax ( or if even possible)...or what approach??? Thanks, Mark A. Matte _________________________________________________________________ Internet Explorer 8 ? Now Available. Faster, safer, easier. http://clk.atdmt.com/MRT/go/141323790/direct/01/ From fhtapia at gmail.com Tue Mar 24 12:24:10 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 24 Mar 2009 10:24:10 -0700 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> <29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> Message-ID: you should be able to execute any number of the Teradata's commands by issuing the command via OpenQuery It will be constructed as such: OpenQuery(LinkedServerName, 'Drop Table TableName') or what ever the command is for TeraData (sorry I am not as familiar with this engine so I cannot help). -Francisco http://sqlthis.blogspot.com | Tsql and More... On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte wrote: > > > Hello All, > > > > I have successfully linked SQL Server2005 to Teradata. I can pull data > from...and insert records into Teradata. > > > > I have NOT been able to create or drop a table in Teradata from SQL Server. > > > > Can anyone help with syntax ( or if even possible)...or what approach??? > > > > Thanks, > > > > Mark A. Matte > > _________________________________________________________________ > Internet Explorer 8 ? Now Available. Faster, safer, easier. > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From markamatte at hotmail.com Tue Mar 24 12:47:21 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Tue, 24 Mar 2009 17:47:21 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> <29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> Message-ID: Thanks Francisco, I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') Any ideas? Thanks, Mark > Date: Tue, 24 Mar 2009 10:24:10 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > you should be able to execute any number of the Teradata's commands by > issuing the command via OpenQuery > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop Table > TableName') or what ever the command is for TeraData (sorry I am not as > familiar with this engine so I cannot help). > > > > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte wrote: > > > > > > > Hello All, > > > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull data > > from...and insert records into Teradata. > > > > > > > > I have NOT been able to create or drop a table in Teradata from SQL Server. > > > > > > > > Can anyone help with syntax ( or if even possible)...or what approach??? > > > > > > > > Thanks, > > > > > > > > Mark A. Matte > > > > _________________________________________________________________ > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > _______________________________________________ > > 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 > _________________________________________________________________ Express your personality in color! Preview and select themes for Hotmail?. http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme From fhtapia at gmail.com Tue Mar 24 13:01:18 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 24 Mar 2009 11:01:18 -0700 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> <29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> Message-ID: Sorry, it's generally used as SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') or for Inserts INSERT OPENQUERY(LinkServer, 'Select Field From Table') Values('Value') DELETE OPENQUERY(LinkServer, 'Select Field From Table') Etc... -Francisco http://sqlthis.blogspot.com | Tsql and More... On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte wrote: > > Thanks Francisco, > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > Any ideas? > > > > Thanks, > > > > Mark > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > From: fhtapia at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > you should be able to execute any number of the Teradata's commands by > > issuing the command via OpenQuery > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop Table > > TableName') or what ever the command is for TeraData (sorry I am not as > > familiar with this engine so I cannot help). > > > > > > > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte >wrote: > > > > > > > > > > > Hello All, > > > > > > > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull data > > > from...and insert records into Teradata. > > > > > > > > > > > > I have NOT been able to create or drop a table in Teradata from SQL > Server. > > > > > > > > > > > > Can anyone help with syntax ( or if even possible)...or what > approach??? > > > > > > > > > > > > Thanks, > > > > > > > > > > > > Mark A. Matte > > > > > > _________________________________________________________________ > > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > > _______________________________________________ > > > 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 > > > > _________________________________________________________________ > Express your personality in color! Preview and select themes for Hotmail?. > > http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From markamatte at hotmail.com Tue Mar 24 13:36:22 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Tue, 24 Mar 2009 18:36:22 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com> <29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> Message-ID: Thanks, I have those...its just the CREATE and DROP syntax I can't seem to find. Thanks, Mark > Date: Tue, 24 Mar 2009 11:01:18 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > Sorry, it's generally used as > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > or for Inserts > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > Values('Value') > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > > Etc... > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte wrote: > > > > > Thanks Francisco, > > > > > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > > > > > Any ideas? > > > > > > > > Thanks, > > > > > > > > Mark > > > > > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > > From: fhtapia at gmail.com > > > To: dba-sqlserver at databaseadvisors.com > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > you should be able to execute any number of the Teradata's commands by > > > issuing the command via OpenQuery > > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop Table > > > TableName') or what ever the command is for TeraData (sorry I am not as > > > familiar with this engine so I cannot help). > > > > > > > > > > > > -Francisco > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte > >wrote: > > > > > > > > > > > > > > > Hello All, > > > > > > > > > > > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull data > > > > from...and insert records into Teradata. > > > > > > > > > > > > > > > > I have NOT been able to create or drop a table in Teradata from SQL > > Server. > > > > > > > > > > > > > > > > Can anyone help with syntax ( or if even possible)...or what > > approach??? > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > Mark A. Matte > > > > > > > > _________________________________________________________________ > > > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > > > _______________________________________________ > > > > 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 > > > > > > > _________________________________________________________________ > > Express your personality in color! Preview and select themes for Hotmail?. > > > > http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme > > _______________________________________________ > > 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 > _________________________________________________________________ Internet Explorer 8 ? Now Available. Faster, safer, easier. http://clk.atdmt.com/MRT/go/141323790/direct/01/ From ab-mi at post3.tele.dk Tue Mar 24 16:04:54 2009 From: ab-mi at post3.tele.dk (Asger Blond) Date: Tue, 24 Mar 2009 22:04:54 +0100 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com><29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com><29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> Message-ID: Mark, A linked server does not directly support DDL-statements. But you can use sp_executesql to submit a DDL-statement against the linked server. Like this: EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE TestTable(TestColumn int)" EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE TestTable" Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A Matte Sendt: 24. marts 2009 19:36 Til: dba-sqlserver at databaseadvisors.com Emne: Re: [dba-SQLServer] SQL Server linked to Teradata Thanks, I have those...its just the CREATE and DROP syntax I can't seem to find. Thanks, Mark > Date: Tue, 24 Mar 2009 11:01:18 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > Sorry, it's generally used as > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > or for Inserts > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > Values('Value') > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > > Etc... > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte wrote: > > > > > Thanks Francisco, > > > > > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > > > > > Any ideas? > > > > > > > > Thanks, > > > > > > > > Mark > > > > > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > > From: fhtapia at gmail.com > > > To: dba-sqlserver at databaseadvisors.com > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > you should be able to execute any number of the Teradata's commands by > > > issuing the command via OpenQuery > > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop Table > > > TableName') or what ever the command is for TeraData (sorry I am not as > > > familiar with this engine so I cannot help). > > > > > > > > > > > > -Francisco > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte > >wrote: > > > > > > > > > > > > > > > Hello All, > > > > > > > > > > > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull data > > > > from...and insert records into Teradata. > > > > > > > > > > > > > > > > I have NOT been able to create or drop a table in Teradata from SQL > > Server. > > > > > > > > > > > > > > > > Can anyone help with syntax ( or if even possible)...or what > > approach??? > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > Mark A. Matte > > > > > > > > _________________________________________________________________ > > > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > > > _______________________________________________ > > > > 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 > > > > > > > _________________________________________________________________ > > Express your personality in color! Preview and select themes for Hotmail?. > > > > http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX _WL_HM_express_032009#colortheme > > _______________________________________________ > > 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 > _________________________________________________________________ Internet Explorer 8 ? Now Available. Faster, safer, easier. http://clk.atdmt.com/MRT/go/141323790/direct/01/ _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From ab-mi at post3.tele.dk Tue Mar 24 17:32:57 2009 From: ab-mi at post3.tele.dk (Asger Blond) Date: Tue, 24 Mar 2009 23:32:57 +0100 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com><29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com><29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> Message-ID: <692168922B6D4471840076C28F89ADFE@AB> Ooops, ignore my answer. Didn't notice the subject line: "linked to Teradata"... Using sp_executesql of course only applies to SQL Server. Don't know if Teradata has an equivalent sp. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger Blond Sendt: 24. marts 2009 22:05 Til: 'Discussion concerning MS SQL Server' Emne: Re: [dba-SQLServer] SQL Server linked to Teradata Mark, A linked server does not directly support DDL-statements. But you can use sp_executesql to submit a DDL-statement against the linked server. Like this: EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE TestTable(TestColumn int)" EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE TestTable" Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A Matte Sendt: 24. marts 2009 19:36 Til: dba-sqlserver at databaseadvisors.com Emne: Re: [dba-SQLServer] SQL Server linked to Teradata Thanks, I have those...its just the CREATE and DROP syntax I can't seem to find. Thanks, Mark > Date: Tue, 24 Mar 2009 11:01:18 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > Sorry, it's generally used as > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > or for Inserts > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > Values('Value') > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > > Etc... > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte wrote: > > > > > Thanks Francisco, > > > > > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > > > > > Any ideas? > > > > > > > > Thanks, > > > > > > > > Mark > > > > > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > > From: fhtapia at gmail.com > > > To: dba-sqlserver at databaseadvisors.com > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > you should be able to execute any number of the Teradata's commands by > > > issuing the command via OpenQuery > > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop Table > > > TableName') or what ever the command is for TeraData (sorry I am not as > > > familiar with this engine so I cannot help). > > > > > > > > > > > > -Francisco > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte > >wrote: > > > > > > > > > > > > > > > Hello All, > > > > > > > > > > > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull data > > > > from...and insert records into Teradata. > > > > > > > > > > > > > > > > I have NOT been able to create or drop a table in Teradata from SQL > > Server. > > > > > > > > > > > > > > > > Can anyone help with syntax ( or if even possible)...or what > > approach??? > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > Mark A. Matte > > > > > > > > _________________________________________________________________ > > > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > > > _______________________________________________ > > > > 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 > > > > > > > _________________________________________________________________ > > Express your personality in color! Preview and select themes for Hotmail?. > > > > http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX _WL_HM_express_032009#colortheme > > _______________________________________________ > > 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 > _________________________________________________________________ Internet Explorer 8 ? Now Available. Faster, safer, easier. http://clk.atdmt.com/MRT/go/141323790/direct/01/ _______________________________________________ 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 markamatte at hotmail.com Wed Mar 25 08:02:58 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Wed, 25 Mar 2009 13:02:58 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: <692168922B6D4471840076C28F89ADFE@AB> References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com><29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com><29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: Asger, I read your first email...got all excited...then thought...let me read what other 'goodies' are in the other email before I go try this...build us up...to knock us down. Just kidding...thanks for the direction...this may lead to the answer after all. Thanks, Mark > From: ab-mi at post3.tele.dk > To: dba-sqlserver at databaseadvisors.com > Date: Tue, 24 Mar 2009 23:32:57 +0100 > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > Ooops, ignore my answer. Didn't notice the subject line: "linked to > Teradata"... > Using sp_executesql of course only applies to SQL Server. > Don't know if Teradata has an equivalent sp. > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger Blond > Sendt: 24. marts 2009 22:05 > Til: 'Discussion concerning MS SQL Server' > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > Mark, > > A linked server does not directly support DDL-statements. But you can use > sp_executesql to submit a DDL-statement against the linked server. Like > this: > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE > TestTable(TestColumn int)" > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE > TestTable" > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A Matte > Sendt: 24. marts 2009 19:36 > Til: dba-sqlserver at databaseadvisors.com > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > > Thanks, > > > > I have those...its just the CREATE and DROP syntax I can't seem to find. > > > > Thanks, > > > > Mark > > > Date: Tue, 24 Mar 2009 11:01:18 -0700 > > From: fhtapia at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > Sorry, it's generally used as > > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > > > or for Inserts > > > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > > Values('Value') > > > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > > > > Etc... > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte > wrote: > > > > > > > > Thanks Francisco, > > > > > > > > > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > > > > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > > > > > > > > > Any ideas? > > > > > > > > > > > > Thanks, > > > > > > > > > > > > Mark > > > > > > > > > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > > > From: fhtapia at gmail.com > > > > To: dba-sqlserver at databaseadvisors.com > > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > > > you should be able to execute any number of the Teradata's commands by > > > > issuing the command via OpenQuery > > > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop > Table > > > > TableName') or what ever the command is for TeraData (sorry I am not > as > > > > familiar with this engine so I cannot help). > > > > > > > > > > > > > > > > -Francisco > > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte > > >wrote: > > > > > > > > > > > > > > > > > > > Hello All, > > > > > > > > > > > > > > > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull > data > > > > > from...and insert records into Teradata. > > > > > > > > > > > > > > > > > > > > I have NOT been able to create or drop a table in Teradata from SQL > > > Server. > > > > > > > > > > > > > > > > > > > > Can anyone help with syntax ( or if even possible)...or what > > > approach??? > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > Mark A. Matte > > > > > > > > > > _________________________________________________________________ > > > > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > > > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > > > > _______________________________________________ > > > > > 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 > > > > > > > > > > _________________________________________________________________ > > > Express your personality in color! Preview and select themes for > Hotmail?. > > > > > > > http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX > _WL_HM_express_032009#colortheme > > > _______________________________________________ > > > 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 > > > > _________________________________________________________________ > Internet Explorer 8 ? Now Available. Faster, safer, easier. > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > _______________________________________________ > 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 > _________________________________________________________________ Windows Live? SkyDrive: Get 25 GB of free online storage. http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_032009 From markamatte at hotmail.com Wed Mar 25 08:33:17 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Wed, 25 Mar 2009 13:33:17 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: <692168922B6D4471840076C28F89ADFE@AB> References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com><29f585dd0903171948t6571564ema0c686268708cc03@mail.gmail.com><29f585dd0903180140o2f6d407emaa7e80bcc07eefcf@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: Also, I can use a pass-through query in access to drop a table...any way to port that syntax over to sql server? Thanks, Mark > From: ab-mi at post3.tele.dk > To: dba-sqlserver at databaseadvisors.com > Date: Tue, 24 Mar 2009 23:32:57 +0100 > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > Ooops, ignore my answer. Didn't notice the subject line: "linked to > Teradata"... > Using sp_executesql of course only applies to SQL Server. > Don't know if Teradata has an equivalent sp. > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger Blond > Sendt: 24. marts 2009 22:05 > Til: 'Discussion concerning MS SQL Server' > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > Mark, > > A linked server does not directly support DDL-statements. But you can use > sp_executesql to submit a DDL-statement against the linked server. Like > this: > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE > TestTable(TestColumn int)" > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE > TestTable" > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A Matte > Sendt: 24. marts 2009 19:36 > Til: dba-sqlserver at databaseadvisors.com > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > > Thanks, > > > > I have those...its just the CREATE and DROP syntax I can't seem to find. > > > > Thanks, > > > > Mark > > > Date: Tue, 24 Mar 2009 11:01:18 -0700 > > From: fhtapia at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > Sorry, it's generally used as > > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > > > or for Inserts > > > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > > Values('Value') > > > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > > > > Etc... > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte > wrote: > > > > > > > > Thanks Francisco, > > > > > > > > > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > > > > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > > > > > > > > > Any ideas? > > > > > > > > > > > > Thanks, > > > > > > > > > > > > Mark > > > > > > > > > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > > > From: fhtapia at gmail.com > > > > To: dba-sqlserver at databaseadvisors.com > > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > > > you should be able to execute any number of the Teradata's commands by > > > > issuing the command via OpenQuery > > > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop > Table > > > > TableName') or what ever the command is for TeraData (sorry I am not > as > > > > familiar with this engine so I cannot help). > > > > > > > > > > > > > > > > -Francisco > > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte > > >wrote: > > > > > > > > > > > > > > > > > > > Hello All, > > > > > > > > > > > > > > > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull > data > > > > > from...and insert records into Teradata. > > > > > > > > > > > > > > > > > > > > I have NOT been able to create or drop a table in Teradata from SQL > > > Server. > > > > > > > > > > > > > > > > > > > > Can anyone help with syntax ( or if even possible)...or what > > > approach??? > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > Mark A. Matte > > > > > > > > > > _________________________________________________________________ > > > > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > > > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > > > > _______________________________________________ > > > > > 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 > > > > > > > > > > _________________________________________________________________ > > > Express your personality in color! Preview and select themes for > Hotmail?. > > > > > > > http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX > _WL_HM_express_032009#colortheme > > > _______________________________________________ > > > 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 > > > > _________________________________________________________________ > Internet Explorer 8 ? Now Available. Faster, safer, easier. > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > _______________________________________________ > 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 > _________________________________________________________________ Internet Explorer 8 ? Now Available. Faster, safer, easier. http://clk.atdmt.com/MRT/go/141323790/direct/01/ From fhtapia at gmail.com Wed Mar 25 11:24:47 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 25 Mar 2009 09:24:47 -0700 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: Given that OpenQuery is a return set statement, maybe doing something like: SELECT * FROM OPENQUERY(LinkedServer, 'Drop Table TableName; SELECT * FROM DBC.TABLES WHERE TABLENAME = TableName ;' Ideally you should be running something like the equivalent of Select @@Error that way you can get a confirmation, of what occurred on the TeraData system. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Wed, Mar 25, 2009 at 6:33 AM, Mark A Matte wrote: > > Also, > > > > I can use a pass-through query in access to drop a table...any way to port > that syntax over to sql server? > > > > Thanks, > > > > Mark > > > From: ab-mi at post3.tele.dk > > To: dba-sqlserver at databaseadvisors.com > > Date: Tue, 24 Mar 2009 23:32:57 +0100 > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > Ooops, ignore my answer. Didn't notice the subject line: "linked to > > Teradata"... > > Using sp_executesql of course only applies to SQL Server. > > Don't know if Teradata has an equivalent sp. > > > > Asger > > > > -----Oprindelig meddelelse----- > > Fra: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger > Blond > > Sendt: 24. marts 2009 22:05 > > Til: 'Discussion concerning MS SQL Server' > > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > Mark, > > > > A linked server does not directly support DDL-statements. But you can use > > sp_executesql to submit a DDL-statement against the linked server. Like > > this: > > > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE > > TestTable(TestColumn int)" > > > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE > > TestTable" > > > > Asger > > > > -----Oprindelig meddelelse----- > > Fra: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A > Matte > > Sendt: 24. marts 2009 19:36 > > Til: dba-sqlserver at databaseadvisors.com > > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > Thanks, > > > > > > > > I have those...its just the CREATE and DROP syntax I can't seem to find. > > > > > > > > Thanks, > > > > > > > > Mark > > > > > Date: Tue, 24 Mar 2009 11:01:18 -0700 > > > From: fhtapia at gmail.com > > > To: dba-sqlserver at databaseadvisors.com > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > Sorry, it's generally used as > > > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > > > > > or for Inserts > > > > > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > > > Values('Value') > > > > > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > > > > > > Etc... > > > -Francisco > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > > > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte > > wrote: > > > > > > > > > > > Thanks Francisco, > > > > > > > > > > > > > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > > > > > > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > > > > > > > > > > > > > Any ideas? > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > Mark > > > > > > > > > > > > > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > > > > From: fhtapia at gmail.com > > > > > To: dba-sqlserver at databaseadvisors.com > > > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > > > > > you should be able to execute any number of the Teradata's commands > by > > > > > issuing the command via OpenQuery > > > > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop > > Table > > > > > TableName') or what ever the command is for TeraData (sorry I am > not > > as > > > > > familiar with this engine so I cannot help). > > > > > > > > > > > > > > > > > > > > -Francisco > > > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > > > > > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte < > markamatte at hotmail.com > > > > >wrote: > > > > > > > > > > > > > > > > > > > > > > > Hello All, > > > > > > > > > > > > > > > > > > > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull > > data > > > > > > from...and insert records into Teradata. > > > > > > > > > > > > > > > > > > > > > > > > I have NOT been able to create or drop a table in Teradata from > SQL > > > > Server. > > > > > > > > > > > > > > > > > > > > > > > > Can anyone help with syntax ( or if even possible)...or what > > > > approach??? > > > > > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > > > > > Mark A. Matte > > > > > > > > > > > > _________________________________________________________________ > > > > > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > > > > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > > > > > _______________________________________________ > > > > > > 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 > > > > > > > > > > > > > _________________________________________________________________ > > > > Express your personality in color! Preview and select themes for > > Hotmail?. > > > > > > > > > > > http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX > > _WL_HM_express_032009#colortheme > > > > _______________________________________________ > > > > 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 > > > > > > > _________________________________________________________________ > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > _______________________________________________ > > 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 > > > > _________________________________________________________________ > Internet Explorer 8 ? Now Available. Faster, safer, easier. > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From markamatte at hotmail.com Wed Mar 25 12:09:13 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Wed, 25 Mar 2009 17:09:13 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: That gives me an error : OLE DB provider "MSDASQL" for linked server "TDATA" returned message "[NCR][ODBC Teradata Driver][Teradata Database] Data definition not valid unless solitary. ". Thanks, Mark Date: Wed, 25 Mar 2009 09:24:47 -0700 From: fhtapia at gmail.com To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] SQL Server linked to Teradata Given that OpenQuery is a return set statement, maybe doing something like: SELECT * FROM OPENQUERY(LinkedServer, 'Drop Table TableName; SELECT * FROM DBC.TABLES WHERE TABLENAME = TableName ;' Ideally you should be running something like the equivalent of Select @@Error that way you can get a confirmation, of what occurred on the TeraData system. On Wed, Mar 25, 2009 at 6:33 AM, Mark A Matte References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: what if you use a simple select on a small table? -Francisco http://sqlthis.blogspot.com | Tsql and More... On Wed, Mar 25, 2009 at 10:09 AM, Mark A Matte wrote: > > That gives me an error : > > OLE DB provider "MSDASQL" for linked server "TDATA" returned message > "[NCR][ODBC Teradata Driver][Teradata Database] Data definition not valid > unless solitary. ". > > Thanks, > > Mark > > Date: Wed, 25 Mar 2009 09:24:47 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > Given that OpenQuery is a return set statement, maybe doing something like: > SELECT * FROM OPENQUERY(LinkedServer, 'Drop Table TableName; SELECT * FROM > DBC.TABLES WHERE TABLENAME = TableName ;' > Ideally you should be running something like the equivalent of Select > @@Error that way you can get a confirmation, of what occurred on the > TeraData system. > > On Wed, Mar 25, 2009 at 6:33 AM, Mark A Matte : > > Also, > > I can use a pass-through query in access to drop a table...any way to port > that syntax over to sql server? > > Thanks, > > Mark > > From: ab-mi at post3.tele.dk > To: dba-sqlserver at databaseadvisors.com > Date: Tue, 24 Mar 2009 23:32:57 +0100 > > Ooops, ignore my answer. Didn't notice the subject line: "linked to > Teradata"... > Using sp_executesql of course only applies to SQL Server. > Don't know if Teradata has an equivalent sp. > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger > Blond > Sendt: 24. marts 2009 22:05 > Til: 'Discussion concerning MS SQL Server' > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > Mark, > > A linked server does not directly support DDL-statements. But you can use > sp_executesql to submit a DDL-statement against the linked server. Like > this: > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE > TestTable(TestColumn int)" > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE > TestTable" > > Asger > > -----Oprindelig meddelelse----- > Fra: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A > Matte > Sendt: 24. marts 2009 19:36 > Til: dba-sqlserver at databaseadvisors.com > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > Thanks, > > I have those...its just the CREATE and DROP syntax I can't seem to find. > > Thanks, > > Mark > > Date: Tue, 24 Mar 2009 11:01:18 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > Sorry, it's generally used as > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > or for Inserts > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > Values('Value') > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > Etc... > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte > > Thanks Francisco, > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > Any ideas? > > Thanks, > > Mark > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > you should be able to execute any number of the Teradata's commands > by > issuing the command via OpenQuery > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop > Table > TableName') or what ever the command is for TeraData (sorry I am > not > as > familiar with this engine so I cannot help). > > > > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte < > markamatte at hotmail.com > wrote: > Hello All, > > I have successfully linked SQL Server2005 to Teradata. I can pull > data > from...and insert records into Teradata. > > I have NOT been able to create or drop a table in Teradata from > SQL > Server. > > Can anyone help with syntax ( or if even possible)...or what > approach??? > > Thanks, > > > Mark A. Matte > > _________________________________________________________________ > Internet Explorer 8 ? Now Available. Faster, safer, easier. > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From markamatte at hotmail.com Wed Mar 25 12:32:03 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Wed, 25 Mar 2009 17:32:03 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: Not sure I follow... Both of these work: Select syntax: select * from openquery(TDATA, 'select * from test_tbls.testTable') Insert Syntax: insert openquery(tdata, 'select ship_to_phn from test_tbls.testTABLE') select phone from ccms.dbo.tbltest; > Date: Wed, 25 Mar 2009 10:16:12 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > what if you use a simple select on a small table? > > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Wed, Mar 25, 2009 at 10:09 AM, Mark A Matte wrote: > > > > > That gives me an error : > > > > OLE DB provider "MSDASQL" for linked server "TDATA" returned message > > "[NCR][ODBC Teradata Driver][Teradata Database] Data definition not valid > > unless solitary. ". > > > > Thanks, > > > > Mark > > > > Date: Wed, 25 Mar 2009 09:24:47 -0700 > > From: fhtapia at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > Given that OpenQuery is a return set statement, maybe doing something like: > > SELECT * FROM OPENQUERY(LinkedServer, 'Drop Table TableName; SELECT * FROM > > DBC.TABLES WHERE TABLENAME = TableName ;' > > Ideally you should be running something like the equivalent of Select > > @@Error that way you can get a confirmation, of what occurred on the > > TeraData system. > > > > On Wed, Mar 25, 2009 at 6:33 AM, Mark A Matte > : > > > > Also, > > > > I can use a pass-through query in access to drop a table...any way to port > > that syntax over to sql server? > > > > Thanks, > > > > Mark > > > > From: ab-mi at post3.tele.dk > > To: dba-sqlserver at databaseadvisors.com > > Date: Tue, 24 Mar 2009 23:32:57 +0100 > > > > Ooops, ignore my answer. Didn't notice the subject line: "linked to > > Teradata"... > > Using sp_executesql of course only applies to SQL Server. > > Don't know if Teradata has an equivalent sp. > > > > Asger > > > > -----Oprindelig meddelelse----- > > Fra: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger > > Blond > > Sendt: 24. marts 2009 22:05 > > Til: 'Discussion concerning MS SQL Server' > > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > Mark, > > > > A linked server does not directly support DDL-statements. But you can use > > sp_executesql to submit a DDL-statement against the linked server. Like > > this: > > > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE > > TestTable(TestColumn int)" > > > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE > > TestTable" > > > > Asger > > > > -----Oprindelig meddelelse----- > > Fra: dba-sqlserver-bounces at databaseadvisors.com > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A > > Matte > > Sendt: 24. marts 2009 19:36 > > Til: dba-sqlserver at databaseadvisors.com > > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > Thanks, > > > > I have those...its just the CREATE and DROP syntax I can't seem to find. > > > > Thanks, > > > > Mark > > > > Date: Tue, 24 Mar 2009 11:01:18 -0700 > > From: fhtapia at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > Sorry, it's generally used as > > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > > > or for Inserts > > > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > > Values('Value') > > > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > > Etc... > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte > > > > > Thanks Francisco, > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > Any ideas? > > > > Thanks, > > > > Mark > > > > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > From: fhtapia at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > you should be able to execute any number of the Teradata's commands > > by > > issuing the command via OpenQuery > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop > > Table > > TableName') or what ever the command is for TeraData (sorry I am > > not > > as > > familiar with this engine so I cannot help). > > > > > > > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte < > > markamatte at hotmail.com > > wrote: > > Hello All, > > > > I have successfully linked SQL Server2005 to Teradata. I can pull > > data > > from...and insert records into Teradata. > > > > I have NOT been able to create or drop a table in Teradata from > > SQL > > Server. > > > > Can anyone help with syntax ( or if even possible)...or what > > approach??? > > > > Thanks, > > > > > > Mark A. Matte > > > > _________________________________________________________________ > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > _______________________________________________ > > 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 > _________________________________________________________________ Get quick access to your favorite MSN content with Internet Explorer 8. http://ie8.msn.com/microsoft/internet-explorer-8/en-us/ie8.aspx?ocid=B037MSN55C0701A From fhtapia at gmail.com Wed Mar 25 16:28:50 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 25 Mar 2009 14:28:50 -0700 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: What I figured you could do, as I know it works for sql server is that you would run the DROP TABLE command followed by a semicolon then the next sql statement, I think this is stilll ANSI-92 standard tsql, and should work for other engines that support the DROP TABLE syntax that's what I ment. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Wed, Mar 25, 2009 at 10:32 AM, Mark A Matte wrote: > > Not sure I follow... > > > > Both of these work: > > > > Select syntax: > > > select * from openquery(TDATA, 'select * from test_tbls.testTable') > > > Insert Syntax: > > insert openquery(tdata, 'select ship_to_phn from test_tbls.testTABLE') > select phone from ccms.dbo.tbltest; > > > > Date: Wed, 25 Mar 2009 10:16:12 -0700 > > From: fhtapia at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > what if you use a simple select on a small table? > > > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Wed, Mar 25, 2009 at 10:09 AM, Mark A Matte >wrote: > > > > > > > > That gives me an error : > > > > > > OLE DB provider "MSDASQL" for linked server "TDATA" returned message > > > "[NCR][ODBC Teradata Driver][Teradata Database] Data definition not > valid > > > unless solitary. ". > > > > > > Thanks, > > > > > > Mark > > > > > > Date: Wed, 25 Mar 2009 09:24:47 -0700 > > > From: fhtapia at gmail.com > > > To: dba-sqlserver at databaseadvisors.com > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > Given that OpenQuery is a return set statement, maybe doing something > like: > > > SELECT * FROM OPENQUERY(LinkedServer, 'Drop Table TableName; SELECT * > FROM > > > DBC.TABLES WHERE TABLENAME = TableName ;' > > > Ideally you should be running something like the equivalent of Select > > > @@Error that way you can get a confirmation, of what occurred on the > > > TeraData system. > > > > > > On Wed, Mar 25, 2009 at 6:33 AM, Mark A Matte > > > : > > > > > > Also, > > > > > > I can use a pass-through query in access to drop a table...any way to > port > > > that syntax over to sql server? > > > > > > Thanks, > > > > > > Mark > > > > > > From: ab-mi at post3.tele.dk > > > To: dba-sqlserver at databaseadvisors.com > > > Date: Tue, 24 Mar 2009 23:32:57 +0100 > > > > > > Ooops, ignore my answer. Didn't notice the subject line: "linked to > > > Teradata"... > > > Using sp_executesql of course only applies to SQL Server. > > > Don't know if Teradata has an equivalent sp. > > > > > > Asger > > > > > > -----Oprindelig meddelelse----- > > > Fra: dba-sqlserver-bounces at databaseadvisors.com > > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger > > > Blond > > > Sendt: 24. marts 2009 22:05 > > > Til: 'Discussion concerning MS SQL Server' > > > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > Mark, > > > > > > A linked server does not directly support DDL-statements. But you can > use > > > sp_executesql to submit a DDL-statement against the linked server. Like > > > this: > > > > > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE > > > TestTable(TestColumn int)" > > > > > > EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE > > > TestTable" > > > > > > Asger > > > > > > -----Oprindelig meddelelse----- > > > Fra: dba-sqlserver-bounces at databaseadvisors.com > > > [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A > > > Matte > > > Sendt: 24. marts 2009 19:36 > > > Til: dba-sqlserver at databaseadvisors.com > > > Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > Thanks, > > > > > > I have those...its just the CREATE and DROP syntax I can't seem to > find. > > > > > > Thanks, > > > > > > Mark > > > > > > Date: Tue, 24 Mar 2009 11:01:18 -0700 > > > From: fhtapia at gmail.com > > > To: dba-sqlserver at databaseadvisors.com > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > Sorry, it's generally used as > > > SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > > > > > > or for Inserts > > > > > > INSERT OPENQUERY(LinkServer, 'Select Field From Table') > > > Values('Value') > > > > > > DELETE OPENQUERY(LinkServer, 'Select Field From Table') > > > Etc... > > > -Francisco > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte > > > > > > > > Thanks Francisco, > > > > > > I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > > > > > > when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > > > > > > Any ideas? > > > > > > Thanks, > > > > > > Mark > > > > > > > > > > > > Date: Tue, 24 Mar 2009 10:24:10 -0700 > > > From: fhtapia at gmail.com > > > To: dba-sqlserver at databaseadvisors.com > > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > > > you should be able to execute any number of the Teradata's commands > > > by > > > issuing the command via OpenQuery > > > It will be constructed as such: OpenQuery(LinkedServerName, 'Drop > > > Table > > > TableName') or what ever the command is for TeraData (sorry I am > > > not > > > as > > > familiar with this engine so I cannot help). > > > > > > > > > > > > -Francisco > > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > > > > On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte < > > > markamatte at hotmail.com > > > wrote: > > > Hello All, > > > > > > I have successfully linked SQL Server2005 to Teradata. I can pull > > > data > > > from...and insert records into Teradata. > > > > > > I have NOT been able to create or drop a table in Teradata from > > > SQL > > > Server. > > > > > > Can anyone help with syntax ( or if even possible)...or what > > > approach??? > > > > > > Thanks, > > > > > > > > > Mark A. Matte > > > > > > _________________________________________________________________ > > > Internet Explorer 8 ? Now Available. Faster, safer, easier. > > > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > > > _______________________________________________ > > > 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 > > > > _________________________________________________________________ > Get quick access to your favorite MSN content with Internet Explorer 8. > > http://ie8.msn.com/microsoft/internet-explorer-8/en-us/ie8.aspx?ocid=B037MSN55C0701A > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From markamatte at hotmail.com Thu Mar 26 09:27:57 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Thu, 26 Mar 2009 14:27:57 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: Tried that...I get an error:"data definition not valid unless solitary." Thanks, Mark ---------------------------------------- > Date: Wed, 25 Mar 2009 14:28:50 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > What I figured you could do, as I know it works for sql server is that you > would run the DROP TABLE command followed by a semicolon then the next sql > statement, I think this is stilll ANSI-92 standard tsql, and should work for > other engines that support the DROP TABLE syntax > that's what I ment. > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Wed, Mar 25, 2009 at 10:32 AM, Mark A Matte wrote: > >> >> Not sure I follow... >> >> >> >> Both of these work: >> >> >> >> Select syntax: >> >> >> select * from openquery(TDATA, 'select * from test_tbls.testTable') >> >> >> Insert Syntax: >> >> insert openquery(tdata, 'select ship_to_phn from test_tbls.testTABLE') >> select phone from ccms.dbo.tbltest; >> >> >>> Date: Wed, 25 Mar 2009 10:16:12 -0700 >>> From: fhtapia at gmail.com >>> To: dba-sqlserver at databaseadvisors.com >>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata >>> >>> what if you use a simple select on a small table? >>> >>> -Francisco >>> http://sqlthis.blogspot.com | Tsql and More... >>> >>> >>> On Wed, Mar 25, 2009 at 10:09 AM, Mark A Matte>>>wrote: >>> >>>> >>>> That gives me an error : >>>> >>>> OLE DB provider "MSDASQL" for linked server "TDATA" returned message >>>> "[NCR][ODBC Teradata Driver][Teradata Database] Data definition not >> valid >>>> unless solitary. ". >>>> >>>> Thanks, >>>> >>>> Mark >>>> >>>> Date: Wed, 25 Mar 2009 09:24:47 -0700 >>>> From: fhtapia at gmail.com >>>> To: dba-sqlserver at databaseadvisors.com >>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata >>>> >>>> Given that OpenQuery is a return set statement, maybe doing something >> like: >>>> SELECT * FROM OPENQUERY(LinkedServer, 'Drop Table TableName; SELECT * >> FROM >>>> DBC.TABLES WHERE TABLENAME = TableName ;' >>>> Ideally you should be running something like the equivalent of Select >>>> @@Error that way you can get a confirmation, of what occurred on the >>>> TeraData system. >>>> >>>> On Wed, Mar 25, 2009 at 6:33 AM, Mark A Matte >>>>>> : >>>> >>>> Also, >>>> >>>> I can use a pass-through query in access to drop a table...any way to >> port >>>> that syntax over to sql server? >>>> >>>> Thanks, >>>> >>>> Mark >>>> >>>> From: ab-mi at post3.tele.dk >>>> To: dba-sqlserver at databaseadvisors.com >>>> Date: Tue, 24 Mar 2009 23:32:57 +0100 >>>> >>>> Ooops, ignore my answer. Didn't notice the subject line: "linked to >>>> Teradata"... >>>> Using sp_executesql of course only applies to SQL Server. >>>> Don't know if Teradata has an equivalent sp. >>>> >>>> Asger >>>> >>>> -----Oprindelig meddelelse----- >>>> Fra: dba-sqlserver-bounces at databaseadvisors.com >>>> [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger >>>> Blond >>>> Sendt: 24. marts 2009 22:05 >>>> Til: 'Discussion concerning MS SQL Server' >>>> Emne: Re: [dba-SQLServer] SQL Server linked to Teradata >>>> >>>> Mark, >>>> >>>> A linked server does not directly support DDL-statements. But you can >> use >>>> sp_executesql to submit a DDL-statement against the linked server. Like >>>> this: >>>> >>>> EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE >>>> TestTable(TestColumn int)" >>>> >>>> EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE >>>> TestTable" >>>> >>>> Asger >>>> >>>> -----Oprindelig meddelelse----- >>>> Fra: dba-sqlserver-bounces at databaseadvisors.com >>>> [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark A >>>> Matte >>>> Sendt: 24. marts 2009 19:36 >>>> Til: dba-sqlserver at databaseadvisors.com >>>> Emne: Re: [dba-SQLServer] SQL Server linked to Teradata >>>> >>>> Thanks, >>>> >>>> I have those...its just the CREATE and DROP syntax I can't seem to >> find. >>>> >>>> Thanks, >>>> >>>> Mark >>>> >>>> Date: Tue, 24 Mar 2009 11:01:18 -0700 >>>> From: fhtapia at gmail.com >>>> To: dba-sqlserver at databaseadvisors.com >>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata >>>> >>>> Sorry, it's generally used as >>>> SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') >>>> >>>> or for Inserts >>>> >>>> INSERT OPENQUERY(LinkServer, 'Select Field From Table') >>>> Values('Value') >>>> >>>> DELETE OPENQUERY(LinkServer, 'Select Field From Table') >>>> Etc... >>>> -Francisco >>>> http://sqlthis.blogspot.com | Tsql and More... >>>> >>>> On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte >>>>>>>> >>>> Thanks Francisco, >>>> >>>> I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" >>>> >>>> when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') >>>> >>>> Any ideas? >>>> >>>> Thanks, >>>> >>>> Mark >>>> >>>> >>>> >>>> Date: Tue, 24 Mar 2009 10:24:10 -0700 >>>> From: fhtapia at gmail.com >>>> To: dba-sqlserver at databaseadvisors.com >>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata >>>> >>>> you should be able to execute any number of the Teradata's commands >>>> by >>>> issuing the command via OpenQuery >>>> It will be constructed as such: OpenQuery(LinkedServerName, 'Drop >>>> Table >>>> TableName') or what ever the command is for TeraData (sorry I am >>>> not >>>> as >>>> familiar with this engine so I cannot help). >>>> >>>> >>>> >>>> -Francisco >>>> http://sqlthis.blogspot.com | Tsql and More... >>>> >>>> >>>> On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte < >>>> markamatte at hotmail.com >>>> wrote: >>>> Hello All, >>>> >>>> I have successfully linked SQL Server2005 to Teradata. I can pull >>>> data >>>> from...and insert records into Teradata. >>>> >>>> I have NOT been able to create or drop a table in Teradata from >>>> SQL >>>> Server. >>>> >>>> Can anyone help with syntax ( or if even possible)...or what >>>> approach??? >>>> >>>> Thanks, >>>> >>>> >>>> Mark A. Matte _________________________________________________________________ Internet Explorer 8 ? Get your Hotmail Accelerated. Download free! http://clk.atdmt.com/MRT/go/141323790/direct/01/ From fhtapia at gmail.com Thu Mar 26 09:33:10 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Thu, 26 Mar 2009 07:33:10 -0700 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: hmm, I'll need to read up on the teradata oledb connector and see what it does support... sorry... -Francisco On Thu, Mar 26, 2009 at 7:27 AM, Mark A Matte wrote: > > Tried that...I get an error:"data definition not valid unless solitary." > > Thanks, > > Mark > > ---------------------------------------- > > Date: Wed, 25 Mar 2009 14:28:50 -0700 > > From: fhtapia at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > > > What I figured you could do, as I know it works for sql server is that > you > > would run the DROP TABLE command followed by a semicolon then the next > sql > > statement, I think this is stilll ANSI-92 standard tsql, and should work > for > > other engines that support the DROP TABLE syntax > > that's what I ment. > > -Francisco > > http://sqlthis.blogspot.com | Tsql and More... > > > > > > On Wed, Mar 25, 2009 at 10:32 AM, Mark A Matte wrote: > > > >> > >> Not sure I follow... > >> > >> > >> > >> Both of these work: > >> > >> > >> > >> Select syntax: > >> > >> > >> select * from openquery(TDATA, 'select * from test_tbls.testTable') > >> > >> > >> Insert Syntax: > >> > >> insert openquery(tdata, 'select ship_to_phn from test_tbls.testTABLE') > >> select phone from ccms.dbo.tbltest; > >> > >> > >>> Date: Wed, 25 Mar 2009 10:16:12 -0700 > >>> From: fhtapia at gmail.com > >>> To: dba-sqlserver at databaseadvisors.com > >>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > >>> > >>> what if you use a simple select on a small table? > >>> > >>> -Francisco > >>> http://sqlthis.blogspot.com | Tsql and More... > >>> > >>> > >>> On Wed, Mar 25, 2009 at 10:09 AM, Mark A Matte>>>wrote: > >>> > >>>> > >>>> That gives me an error : > >>>> > >>>> OLE DB provider "MSDASQL" for linked server "TDATA" returned message > >>>> "[NCR][ODBC Teradata Driver][Teradata Database] Data definition not > >> valid > >>>> unless solitary. ". > >>>> > >>>> Thanks, > >>>> > >>>> Mark > >>>> > >>>> Date: Wed, 25 Mar 2009 09:24:47 -0700 > >>>> From: fhtapia at gmail.com > >>>> To: dba-sqlserver at databaseadvisors.com > >>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > >>>> > >>>> Given that OpenQuery is a return set statement, maybe doing something > >> like: > >>>> SELECT * FROM OPENQUERY(LinkedServer, 'Drop Table TableName; SELECT * > >> FROM > >>>> DBC.TABLES WHERE TABLENAME = TableName ;' > >>>> Ideally you should be running something like the equivalent of Select > >>>> @@Error that way you can get a confirmation, of what occurred on the > >>>> TeraData system. > >>>> > >>>> On Wed, Mar 25, 2009 at 6:33 AM, Mark A Matte > >>>>>> : > >>>> > >>>> Also, > >>>> > >>>> I can use a pass-through query in access to drop a table...any way to > >> port > >>>> that syntax over to sql server? > >>>> > >>>> Thanks, > >>>> > >>>> Mark > >>>> > >>>> From: ab-mi at post3.tele.dk > >>>> To: dba-sqlserver at databaseadvisors.com > >>>> Date: Tue, 24 Mar 2009 23:32:57 +0100 > >>>> > >>>> Ooops, ignore my answer. Didn't notice the subject line: "linked to > >>>> Teradata"... > >>>> Using sp_executesql of course only applies to SQL Server. > >>>> Don't know if Teradata has an equivalent sp. > >>>> > >>>> Asger > >>>> > >>>> -----Oprindelig meddelelse----- > >>>> Fra: dba-sqlserver-bounces at databaseadvisors.com > >>>> [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger > >>>> Blond > >>>> Sendt: 24. marts 2009 22:05 > >>>> Til: 'Discussion concerning MS SQL Server' > >>>> Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > >>>> > >>>> Mark, > >>>> > >>>> A linked server does not directly support DDL-statements. But you can > >> use > >>>> sp_executesql to submit a DDL-statement against the linked server. > Like > >>>> this: > >>>> > >>>> EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE > >>>> TestTable(TestColumn int)" > >>>> > >>>> EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE > >>>> TestTable" > >>>> > >>>> Asger > >>>> > >>>> -----Oprindelig meddelelse----- > >>>> Fra: dba-sqlserver-bounces at databaseadvisors.com > >>>> [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark > A > >>>> Matte > >>>> Sendt: 24. marts 2009 19:36 > >>>> Til: dba-sqlserver at databaseadvisors.com > >>>> Emne: Re: [dba-SQLServer] SQL Server linked to Teradata > >>>> > >>>> Thanks, > >>>> > >>>> I have those...its just the CREATE and DROP syntax I can't seem to > >> find. > >>>> > >>>> Thanks, > >>>> > >>>> Mark > >>>> > >>>> Date: Tue, 24 Mar 2009 11:01:18 -0700 > >>>> From: fhtapia at gmail.com > >>>> To: dba-sqlserver at databaseadvisors.com > >>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > >>>> > >>>> Sorry, it's generally used as > >>>> SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') > >>>> > >>>> or for Inserts > >>>> > >>>> INSERT OPENQUERY(LinkServer, 'Select Field From Table') > >>>> Values('Value') > >>>> > >>>> DELETE OPENQUERY(LinkServer, 'Select Field From Table') > >>>> Etc... > >>>> -Francisco > >>>> http://sqlthis.blogspot.com | Tsql and More... > >>>> > >>>> On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte > >>>>>>>> > >>>> Thanks Francisco, > >>>> > >>>> I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" > >>>> > >>>> when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') > >>>> > >>>> Any ideas? > >>>> > >>>> Thanks, > >>>> > >>>> Mark > >>>> > >>>> > >>>> > >>>> Date: Tue, 24 Mar 2009 10:24:10 -0700 > >>>> From: fhtapia at gmail.com > >>>> To: dba-sqlserver at databaseadvisors.com > >>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > >>>> > >>>> you should be able to execute any number of the Teradata's commands > >>>> by > >>>> issuing the command via OpenQuery > >>>> It will be constructed as such: OpenQuery(LinkedServerName, 'Drop > >>>> Table > >>>> TableName') or what ever the command is for TeraData (sorry I am > >>>> not > >>>> as > >>>> familiar with this engine so I cannot help). > >>>> > >>>> > >>>> > >>>> -Francisco > >>>> http://sqlthis.blogspot.com | Tsql and More... > >>>> > >>>> > >>>> On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte < > >>>> markamatte at hotmail.com > >>>> wrote: > >>>> Hello All, > >>>> > >>>> I have successfully linked SQL Server2005 to Teradata. I can pull > >>>> data > >>>> from...and insert records into Teradata. > >>>> > >>>> I have NOT been able to create or drop a table in Teradata from > >>>> SQL > >>>> Server. > >>>> > >>>> Can anyone help with syntax ( or if even possible)...or what > >>>> approach??? > >>>> > >>>> Thanks, > >>>> > >>>> > >>>> Mark A. Matte > _________________________________________________________________ > Internet Explorer 8 ? Get your Hotmail Accelerated. Download free! > http://clk.atdmt.com/MRT/go/141323790/direct/01/ > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From markamatte at hotmail.com Thu Mar 26 09:45:21 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Thu, 26 Mar 2009 14:45:21 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <692168922B6D4471840076C28F89ADFE@AB> Message-ID: Thanks Francisco, I've hit almost every site google found that mentioned Teradata or linked servers. The one funny part...is I CAN do this with Access as a pass-through query. Anything you find would be much appreciated...but I would not expect you to put too much effort into it. Thanks again, Mark ---------------------------------------- > Date: Thu, 26 Mar 2009 07:33:10 -0700 > From: fhtapia at gmail.com > > hmm, I'll need to read up on the teradata oledb connector and see what it > does support... sorry... > > -Francisco > > > > On Thu, Mar 26, 2009 at 7:27 AM, Mark A Matte wrote: > >> >> Tried that...I get an error:"data definition not valid unless solitary." >> >> Thanks, >> >> Mark >> >> ---------------------------------------- >>> Date: Wed, 25 Mar 2009 14:28:50 -0700 >>> From: fhtapia at gmail.com >>> >>> What I figured you could do, as I know it works for sql server is that >> you >>> would run the DROP TABLE command followed by a semicolon then the next >> sql >>> statement, I think this is stilll ANSI-92 standard tsql, and should work >> for >>> other engines that support the DROP TABLE syntax >>> that's what I ment. >>> -Francisco >>> http://sqlthis.blogspot.com | Tsql and More... >>> >>> >>> On Wed, Mar 25, 2009 at 10:32 AM, Mark A Matte wrote: >>> >>>> >>>> Not sure I follow... >>>> >>>> >>>> >>>> Both of these work: >>>> >>>> >>>> >>>> Select syntax: >>>> >>>> >>>> select * from openquery(TDATA, 'select * from test_tbls.testTable') >>>> >>>> >>>> Insert Syntax: >>>> >>>> insert openquery(tdata, 'select ship_to_phn from test_tbls.testTABLE') >>>> select phone from ccms.dbo.tbltest; >>>> >>>> >>>>> Date: Wed, 25 Mar 2009 10:16:12 -0700 >>>>> From: fhtapia at gmail.com >>>>> To: dba-sqlserver at databaseadvisors.com >>>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata >>>>> >>>>> what if you use a simple select on a small table? >>>>> >>>>> -Francisco >>>>> http://sqlthis.blogspot.com | Tsql and More... >>>>> >>>>> >>>>> On Wed, Mar 25, 2009 at 10:09 AM, Mark A Matte>>>wrote: >>>>> >>>>>> >>>>>> That gives me an error : >>>>>> >>>>>> OLE DB provider "MSDASQL" for linked server "TDATA" returned message >>>>>> "[NCR][ODBC Teradata Driver][Teradata Database] Data definition not >>>> valid >>>>>> unless solitary. ". >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Mark >>>>>> >>>>>> Date: Wed, 25 Mar 2009 09:24:47 -0700 >>>>>> From: fhtapia at gmail.com >>>>>> To: dba-sqlserver at databaseadvisors.com >>>>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata >>>>>> >>>>>> Given that OpenQuery is a return set statement, maybe doing something >>>> like: >>>>>> SELECT * FROM OPENQUERY(LinkedServer, 'Drop Table TableName; SELECT * >>>> FROM >>>>>> DBC.TABLES WHERE TABLENAME = TableName ;' >>>>>> Ideally you should be running something like the equivalent of Select >>>>>> @@Error that way you can get a confirmation, of what occurred on the >>>>>> TeraData system. >>>>>> >>>>>> On Wed, Mar 25, 2009 at 6:33 AM, Mark A Matte >>>>>>>> : >>>>>> >>>>>> Also, >>>>>> >>>>>> I can use a pass-through query in access to drop a table...any way to >>>> port >>>>>> that syntax over to sql server? >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Mark >>>>>> >>>>>> From: ab-mi at post3.tele.dk >>>>>> To: dba-sqlserver at databaseadvisors.com >>>>>> Date: Tue, 24 Mar 2009 23:32:57 +0100 >>>>>> >>>>>> Ooops, ignore my answer. Didn't notice the subject line: "linked to >>>>>> Teradata"... >>>>>> Using sp_executesql of course only applies to SQL Server. >>>>>> Don't know if Teradata has an equivalent sp. >>>>>> >>>>>> Asger >>>>>> >>>>>> -----Oprindelig meddelelse----- >>>>>> Fra: dba-sqlserver-bounces at databaseadvisors.com >>>>>> [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Asger >>>>>> Blond >>>>>> Sendt: 24. marts 2009 22:05 >>>>>> Til: 'Discussion concerning MS SQL Server' >>>>>> Emne: Re: [dba-SQLServer] SQL Server linked to Teradata >>>>>> >>>>>> Mark, >>>>>> >>>>>> A linked server does not directly support DDL-statements. But you can >>>> use >>>>>> sp_executesql to submit a DDL-statement against the linked server. >> Like >>>>>> this: >>>>>> >>>>>> EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "CREATE TABLE >>>>>> TestTable(TestColumn int)" >>>>>> >>>>>> EXECUTE YourLinkedServer.YourDatabase.dbo.sp_executesql "DROP TABLE >>>>>> TestTable" >>>>>> >>>>>> Asger >>>>>> >>>>>> -----Oprindelig meddelelse----- >>>>>> Fra: dba-sqlserver-bounces at databaseadvisors.com >>>>>> [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Mark >> A >>>>>> Matte >>>>>> Sendt: 24. marts 2009 19:36 >>>>>> Til: dba-sqlserver at databaseadvisors.com >>>>>> Emne: Re: [dba-SQLServer] SQL Server linked to Teradata >>>>>> >>>>>> Thanks, >>>>>> >>>>>> I have those...its just the CREATE and DROP syntax I can't seem to >>>> find. >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Mark >>>>>> >>>>>> Date: Tue, 24 Mar 2009 11:01:18 -0700 >>>>>> From: fhtapia at gmail.com >>>>>> To: dba-sqlserver at databaseadvisors.com >>>>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata >>>>>> >>>>>> Sorry, it's generally used as >>>>>> SELECT * FROM OPENQUERY(LinkServer, 'Select Field From Table') >>>>>> >>>>>> or for Inserts >>>>>> >>>>>> INSERT OPENQUERY(LinkServer, 'Select Field From Table') >>>>>> Values('Value') >>>>>> >>>>>> DELETE OPENQUERY(LinkServer, 'Select Field From Table') >>>>>> Etc... >>>>>> -Francisco >>>>>> http://sqlthis.blogspot.com | Tsql and More... >>>>>> >>>>>> On Tue, Mar 24, 2009 at 10:47 AM, Mark A Matte >>>>>>>>>> >>>>>> Thanks Francisco, >>>>>> >>>>>> I get an error (from SQL Server) "Incorrect syntax near 'OpenQuery'" >>>>>> >>>>>> when I use: OpenQuery(LinkedServerName, 'Drop Table TableName') >>>>>> >>>>>> Any ideas? >>>>>> >>>>>> Thanks, >>>>>> >>>>>> Mark >>>>>> >>>>>> >>>>>> >>>>>> Date: Tue, 24 Mar 2009 10:24:10 -0700 >>>>>> From: fhtapia at gmail.com >>>>>> To: dba-sqlserver at databaseadvisors.com >>>>>> Subject: Re: [dba-SQLServer] SQL Server linked to Teradata >>>>>> >>>>>> you should be able to execute any number of the Teradata's commands >>>>>> by >>>>>> issuing the command via OpenQuery >>>>>> It will be constructed as such: OpenQuery(LinkedServerName, 'Drop >>>>>> Table >>>>>> TableName') or what ever the command is for TeraData (sorry I am >>>>>> not >>>>>> as >>>>>> familiar with this engine so I cannot help). >>>>>> >>>>>> >>>>>> >>>>>> -Francisco >>>>>> http://sqlthis.blogspot.com | Tsql and More... >>>>>> >>>>>> >>>>>> On Tue, Mar 24, 2009 at 7:25 AM, Mark A Matte < >>>>>> markamatte at hotmail.com >>>>>> wrote: >>>>>> Hello All, >>>>>> >>>>>> I have successfully linked SQL Server2005 to Teradata. I can pull >>>>>> data >>>>>> from...and insert records into Teradata. >>>>>> >>>>>> I have NOT been able to create or drop a table in Teradata from >>>>>> SQL >>>>>> Server. >>>>>> >>>>>> Can anyone help with syntax ( or if even possible)...or what >>>>>> approach??? >>>>>> >>>>>> Thanks, >>>>>> >>>>>> >>>>>> Mark A. Matte _________________________________________________________________ Windows Live? SkyDrive: Get 25 GB of free online storage. http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_032009 From stuart at lexacorp.com.pg Thu Mar 26 16:35:36 2009 From: stuart at lexacorp.com.pg (Stuart McLachlan) Date: Fri, 27 Mar 2009 07:35:36 +1000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com>, , Message-ID: <49CC81C8.23790.7D4B350@stuart.lexacorp.com.pg> ODBC drivers have various levels of conformance. I've run into some that are very basic (don't ask me what I think of Jade) Many proprietary systems are not even relational databases as we know them, they are Object Oriented and the ODBC driver is based on virtual tables - which of necessity limits much of the DDL part of ODBC. (don't ask me what I think of Jade) It's quite possible that the Teradata ODBC driver just doesn't support what you are trying to do. -- Stuart On 26 Mar 2009 at 14:45, Mark A Matte wrote: > > Thanks Francisco, > > I've hit almost every site google found that mentioned Teradata or linked servers. The one funny part...is I CAN do this with Access as a pass-through query. > > Anything you find would be much appreciated...but I would not expect you to put too much effort into it. > > Thanks again, > > Mark > From fhtapia at gmail.com Thu Mar 26 17:32:40 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Thu, 26 Mar 2009 15:32:40 -0700 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: <49CC81C8.23790.7D4B350@stuart.lexacorp.com.pg> References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <49CC81C8.23790.7D4B350@stuart.lexacorp.com.pg> Message-ID: That's a good point, which teradata driver did you load? I know often times the vendor will have newer versions of said drivers, (ala oracle) where you can update your oledb driver so that it works better with the 3rd party database. again I am not at all familiar with teradata to be very useful beyond Google searches. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Thu, Mar 26, 2009 at 2:35 PM, Stuart McLachlan wrote: > ODBC drivers have various levels of conformance. > > I've run into some that are very basic (don't ask me what I think of Jade) > > Many proprietary systems are not even relational databases as we know them, > they are > Object Oriented and the ODBC driver is based on virtual tables - which of > necessity limits > much of the DDL part of ODBC. (don't ask me what I think of Jade) > > It's quite possible that the Teradata ODBC driver just doesn't support what > you are trying to > do. > > -- > Stuart > > On 26 Mar 2009 at 14:45, Mark A Matte wrote: > > > > > Thanks Francisco, > > > > I've hit almost every site google found that mentioned Teradata or linked > servers. The one funny part...is I CAN do this with Access as a > pass-through query. > > > > Anything you find would be much appreciated...but I would not expect you > to put too much effort into it. > > > > Thanks again, > > > > Mark > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From markamatte at hotmail.com Fri Mar 27 08:13:38 2009 From: markamatte at hotmail.com (Mark A Matte) Date: Fri, 27 Mar 2009 13:13:38 +0000 Subject: [dba-SQLServer] SQL Server linked to Teradata In-Reply-To: References: <29f585dd0903171635w9fbf656i4becadf41640e32c@mail.gmail.com> <49CC81C8.23790.7D4B350@stuart.lexacorp.com.pg> Message-ID: They went ahead and created some 'permanent' tables. For now...I'm gonna give up on dropping the tables from SQL Server. Thanks again for the assistance. Mark A. Matte ---------------------------------------- > Date: Thu, 26 Mar 2009 15:32:40 -0700 > From: fhtapia at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] SQL Server linked to Teradata > > That's a good point, which teradata driver did you load? I know often times > the vendor will have newer versions of said drivers, (ala oracle) where you > can update your oledb driver so that it works better with the 3rd party > database. > again I am not at all familiar with teradata to be very useful beyond Google > searches. > > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > On Thu, Mar 26, 2009 at 2:35 PM, Stuart McLachlan wrote: > >> ODBC drivers have various levels of conformance. >> >> I've run into some that are very basic (don't ask me what I think of Jade) >> >> Many proprietary systems are not even relational databases as we know them, >> they are >> Object Oriented and the ODBC driver is based on virtual tables - which of >> necessity limits >> much of the DDL part of ODBC. (don't ask me what I think of Jade) >> >> It's quite possible that the Teradata ODBC driver just doesn't support what >> you are trying to >> do. >> >> -- >> Stuart >> >> On 26 Mar 2009 at 14:45, Mark A Matte wrote: >> >>> >>> Thanks Francisco, >>> >>> I've hit almost every site google found that mentioned Teradata or linked >> servers. The one funny part...is I CAN do this with Access as a >> pass-through query. >>> >>> Anything you find would be much appreciated...but I would not expect you >> to put too much effort into it. >>> >>> Thanks again, >>> >>> Mark >>> >> >> >> _______________________________________________ >> 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 > _________________________________________________________________ Quick access to Windows Live and your favorite MSN content with Internet Explorer 8. http://ie8.msn.com/microsoft/internet-explorer-8/en-us/ie8.aspx?ocid=B037MSN55C0701A From fuller.artful at gmail.com Sun Mar 29 07:27:43 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Sun, 29 Mar 2009 08:27:43 -0400 Subject: [dba-SQLServer] [AccessD] OT: AccessD Forum, List, Bottom posting, sigs, etc... In-Reply-To: References: <49CB3175.4191.2B2FD5F@stuart.lexacorp.com.pg> <1FB183EA3FE64D4C8BB753C1AD49BCAD@jislaptopdev> <019201c9ae1f$267a2c90$736e85b0$@net> <49CB9C1A.3040700@colbyconsulting.com> <49CC47DC.7000209@colbyconsulting.com> Message-ID: <29f585dd0903290527g4dbf9731x1fba4ca7de1e5633@mail.gmail.com> Me too. A few days back JWC made a comment about the SQL list and its members' failure to supply productive replies. I suppose that I am one of the guilty parties, and I apologize for citing "BOL" etc. as the place to look for answers. But while we are discussing references, I want to plug a book written by an occasional visitor to the SQL list. Paul Nielson's SQL Bible is fantastic. I can't think of another book I own that has been more thoroughly thumbed through, and has more sticky notes stuck on imporant pages. A couple of months ago I met Paul at SQLTeach in Montreal and he is not only extremely knowledgable but also very approachable. And finally, he has a project called Nordic which is an object-relational code generator. Anyone working in Visual Studio etc. should examine Paul's project. It is quite amazing. Visit www.sqlbible.com. Note: I'm replying to a message and thus this will end up on the Access list not the SQL list.... But many readers have both interests in mind. And I will cc the SQL list with this message, too. Arthur From Gustav at cactus.dk Sun Mar 29 12:42:39 2009 From: Gustav at cactus.dk (Gustav Brock) Date: Sun, 29 Mar 2009 19:42:39 +0200 Subject: [dba-SQLServer] [AccessD] OT: AccessD Forum, List, Bottom posting, sigs, etc... Message-ID: Hi Arthur http://www.sqlserverbible.com/ it is. /gustav >>> fuller.artful at gmail.com 29-03-2009 14:27 >>> Me too. A few days back JWC made a comment about the SQL list and its members' failure to supply productive replies. I suppose that I am one of the guilty parties, and I apologize for citing "BOL" etc. as the place to look for answers. But while we are discussing references, I want to plug a book written by an occasional visitor to the SQL list. Paul Nielson's SQL Bible is fantastic. I can't think of another book I own that has been more thoroughly thumbed through, and has more sticky notes stuck on imporant pages. A couple of months ago I met Paul at SQLTeach in Montreal and he is not only extremely knowledgable but also very approachable. And finally, he has a project called Nordic which is an object-relational code generator. Anyone working in Visual Studio etc. should examine Paul's project. It is quite amazing. Visit www.sqlbible.com. Note: I'm replying to a message and thus this will end up on the Access list not the SQL list.... But many readers have both interests in mind. And I will cc the SQL list with this message, too. Arthur From robert at webedb.com Mon Mar 30 08:16:55 2009 From: robert at webedb.com (Robert L. Stewart) Date: Mon, 30 Mar 2009 08:16:55 -0500 Subject: [dba-SQLServer] Bottom posting, sigs, etc... In-Reply-To: References: Message-ID: <200903301600.n2UG04HR011430@databaseadvisors.com> I gave up trying to help him because he never listened to what any one other than himself had to say. Or, he was always correct even when he wasn't. Robert At 01:00 PM 3/29/2009, you wrote: >Date: Sun, 29 Mar 2009 08:27:43 -0400 >From: Arthur Fuller >Subject: Re: [dba-SQLServer] [AccessD] OT: AccessD Forum, List, Bottom > posting, sigs, etc... >To: Access Developers discussion and problem solving > >Cc: Discussion concerning MS SQL Server > >Message-ID: > <29f585dd0903290527g4dbf9731x1fba4ca7de1e5633 at mail.gmail.com> >Content-Type: text/plain; charset=ISO-8859-1 > >Me too. A few days back JWC made a comment about the SQL list and its >members' failure to supply productive replies. I suppose that I am one of >the guilty parties, and I apologize for citing "BOL" etc. as the place to >look for answers. But while we are discussing references, I want to plug a >book written by an occasional visitor to the SQL list. Paul Nielson's SQL >Bible is fantastic. I can't think of another book I own that has been more >thoroughly thumbed through, and has more sticky notes stuck on imporant >pages. A couple of months ago I met Paul at SQLTeach in Montreal and he is >not only extremely knowledgable but also very approachable. And finally, he >has a project called Nordic which is an object-relational code generator. >Anyone working in Visual Studio etc. should examine Paul's project. It is >quite amazing. Visit www.sqlbible.com. Note: I'm replying to a message and >thus this will end up on the Access list not the SQL list.... But many >readers have both interests in mind. And I will cc the SQL list with this >message, too. > ??C6?? ?P From fhtapia at gmail.com Mon Mar 30 11:24:55 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Mon, 30 Mar 2009 09:24:55 -0700 Subject: [dba-SQLServer] Bottom posting, sigs, etc... In-Reply-To: <200903301600.n2UG04HR011430@databaseadvisors.com> References: <200903301600.n2UG04HR011430@databaseadvisors.com> Message-ID: The thing is that generally when you don't understand something you tend to follow up with a question... such as I don't understand that, or I don't think that applies to me because of xyz. sometimes you need to repeat yourself because this is an email list and not a forum where you can simply just tell people ... doh... read the 3 messages above. etc. John would have liked hand crafted examples that matched his situation where he could have lifted the code and plopped it down on his screen. I know I at the time was too busy with my day job to provide very detail responses, but tried to provide him with keywords and links to articles that answered his questions, sometimes that ment that he would have had to write his own sproc, I know how scary that can be especially since he has that gargantuam database and the last thing he wanted to do was to run a useless query that would possibly take days to run, and not have a result. Unfortunately for him he chose the wrong time to learn more about sql server while taking on such a huge project. -Francisco http://sqlthis.blogspot.com | Tsql and More... 2009/3/30 Robert L. Stewart > I gave up trying to help him because he never listened to what > any one other than himself had to say. Or, he was always correct > even when he wasn't. > > > Robert > > >