From Kenneth.Stoker at pnl.gov Mon Jan 12 15:04:01 2004 From: Kenneth.Stoker at pnl.gov (Stoker, Kenneth E) Date: Mon, 12 Jan 2004 13:04:01 -0800 Subject: [dba-SQLServer] Running Sprocs using a batch file that is then executed in aNetwork Job Scheduler Message-ID: <249C1CB246997C48BB74963CCD361C1B014A0374@pnlmse28.pnl.gov> Everyone, I have been asked to build a batchrun script that will be run by a network scheduler to execute a couple of stored procedures. Can any of you give me some advice on or point me to some resources on proper construction of such a script. I have built very simple batchrun scripts in the past but have not done one like this. Thank you. Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov From tuxedo_man at hotmail.com Mon Jan 12 15:17:49 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Mon, 12 Jan 2004 21:17:49 +0000 Subject: [dba-SQLServer] Running Sprocs using a batch file that is then executed in aNetwork Job Scheduler Message-ID: Not sure if this helps but would you consider using the SQL Server Agent to schedule and execute the stored procedure? The interface to create a SQL Server Agent Job is quite straightforward and it can write entries into the Event Log upon successful/failure. >From: "Stoker, Kenneth E" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer] Running Sprocs using a batch file that is then >executed in aNetwork Job Scheduler >Date: Mon, 12 Jan 2004 13:04:01 -0800 > >Everyone, > >I have been asked to build a batchrun script that will be run by a >network scheduler to execute a couple of stored procedures. Can any of >you give me some advice on or point me to some resources on proper >construction of such a script. I have built very simple batchrun >scripts in the past but have not done one like this. > >Thank you. > >Ken Stoker >Technology Commercialization >Information Systems Administrator >PH: (509) 375-3758 >FAX: (509) 375-6731 >E-mail: Kenneth.Stoker at pnl.gov > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca From Kenneth.Stoker at pnl.gov Mon Jan 12 16:08:28 2004 From: Kenneth.Stoker at pnl.gov (Stoker, Kenneth E) Date: Mon, 12 Jan 2004 14:08:28 -0800 Subject: [dba-SQLServer] Running Sprocs using a batch file that is thenexecuted in aNetwork Job Scheduler Message-ID: <249C1CB246997C48BB74963CCD361C1B07C942@pnlmse28.pnl.gov> I understand where you are coming from, but the powers that be have stated that we need to use the network scheduler versus setting up a SQL Server Agent Job. There are also some external items that need to be part of the job. Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov -----Original Message----- From: Billy Pang [mailto:tuxedo_man at hotmail.com] Sent: Monday, January 12, 2004 1:18 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer] Running Sprocs using a batch file that is thenexecuted in aNetwork Job Scheduler Not sure if this helps but would you consider using the SQL Server Agent to schedule and execute the stored procedure? The interface to create a SQL Server Agent Job is quite straightforward and it can write entries into the Event Log upon successful/failure. >From: "Stoker, Kenneth E" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer] Running Sprocs using a batch file that is then >executed in aNetwork Job Scheduler >Date: Mon, 12 Jan 2004 13:04:01 -0800 > >Everyone, > >I have been asked to build a batchrun script that will be run by a >network scheduler to execute a couple of stored procedures. Can any of >you give me some advice on or point me to some resources on proper >construction of such a script. I have built very simple batchrun >scripts in the past but have not done one like this. > >Thank you. > >Ken Stoker >Technology Commercialization >Information Systems Administrator >PH: (509) 375-3758 >FAX: (509) 375-6731 >E-mail: Kenneth.Stoker at pnl.gov > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin .msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From my.lists at verizon.net Mon Jan 12 16:25:02 2004 From: my.lists at verizon.net (Francisco H Tapia) Date: Mon, 12 Jan 2004 14:25:02 -0800 Subject: [dba-SQLServer] Running Sprocs using a batch file that is thenexecuted in aNetwork Job Scheduler In-Reply-To: <249C1CB246997C48BB74963CCD361C1B07C942@pnlmse28.pnl.gov> References: <249C1CB246997C48BB74963CCD361C1B07C942@pnlmse28.pnl.gov> Message-ID: <40031EBE.1000908@verizon.net> i hear ya, it can be done using osql, check BOL for syntax -- -Francisco Stoker, Kenneth E wrote: >I understand where you are coming from, but the powers that be have >stated that we need to use the network scheduler versus setting up a SQL >Server Agent Job. There are also some external items that need to be >part of the job. > > >Ken Stoker >Technology Commercialization >Information Systems Administrator >PH: (509) 375-3758 >FAX: (509) 375-6731 >E-mail: Kenneth.Stoker at pnl.gov > > >-----Original Message----- >From: Billy Pang [mailto:tuxedo_man at hotmail.com] >Sent: Monday, January 12, 2004 1:18 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Running Sprocs using a batch file that is >thenexecuted in aNetwork Job Scheduler > > >Not sure if this helps but would you consider using the SQL Server Agent >to >schedule and execute the stored procedure? The interface to create a >SQL >Server Agent Job is quite straightforward and it can write entries into >the >Event Log upon successful/failure. > > > > >>From: "Stoker, Kenneth E" >>Reply-To: dba-sqlserver at databaseadvisors.com >>To: dba-SQLServer at databaseadvisors.com >>Subject: [dba-SQLServer] Running Sprocs using a batch file that is then >>executed in aNetwork Job Scheduler >>Date: Mon, 12 Jan 2004 13:04:01 -0800 >> >>Everyone, >> >>I have been asked to build a batchrun script that will be run by a >>network scheduler to execute a couple of stored procedures. Can any of >> >> > > > >>you give me some advice on or point me to some resources on proper >>construction of such a script. I have built very simple batchrun >>scripts in the past but have not done one like this. >> >>Thank you. >> >>Ken Stoker >> >> > > > From Kenneth.Stoker at pnl.gov Mon Jan 12 17:18:52 2004 From: Kenneth.Stoker at pnl.gov (Stoker, Kenneth E) Date: Mon, 12 Jan 2004 15:18:52 -0800 Subject: [dba-SQLServer] Running Sprocs using a batch file that isthenexecuted in aNetwork Job Scheduler Message-ID: <249C1CB246997C48BB74963CCD361C1B014A0378@pnlmse28.pnl.gov> I have been looking everything I can find on osql, but I cannot find anything about using a dsn. There are switches for supplying a username and password, but not a dsn. Is it possible to supply a dsn instead? What would the switch be? Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov -----Original Message----- From: Francisco H Tapia [mailto:my.lists at verizon.net] Sent: Monday, January 12, 2004 2:25 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer] Running Sprocs using a batch file that isthenexecuted in aNetwork Job Scheduler i hear ya, it can be done using osql, check BOL for syntax -- -Francisco Stoker, Kenneth E wrote: >I understand where you are coming from, but the powers that be have >stated that we need to use the network scheduler versus setting up a >SQL Server Agent Job. There are also some external items that need to >be part of the job. > > >Ken Stoker >Technology Commercialization >Information Systems Administrator >PH: (509) 375-3758 >FAX: (509) 375-6731 >E-mail: Kenneth.Stoker at pnl.gov > > >-----Original Message----- >From: Billy Pang [mailto:tuxedo_man at hotmail.com] >Sent: Monday, January 12, 2004 1:18 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer] Running Sprocs using a batch file that is >thenexecuted in aNetwork Job Scheduler > > >Not sure if this helps but would you consider using the SQL Server >Agent to schedule and execute the stored procedure? The interface to >create a SQL >Server Agent Job is quite straightforward and it can write entries into >the >Event Log upon successful/failure. > > > > >>From: "Stoker, Kenneth E" >>Reply-To: dba-sqlserver at databaseadvisors.com >>To: dba-SQLServer at databaseadvisors.com >>Subject: [dba-SQLServer] Running Sprocs using a batch file that is >>then executed in aNetwork Job Scheduler >>Date: Mon, 12 Jan 2004 13:04:01 -0800 >> >>Everyone, >> >>I have been asked to build a batchrun script that will be run by a >>network scheduler to execute a couple of stored procedures. Can any of >> >> > > > >>you give me some advice on or point me to some resources on proper >>construction of such a script. I have built very simple batchrun >>scripts in the past but have not done one like this. >> >>Thank you. >> >>Ken Stoker >> >> > > > _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From my.lists at verizon.net Mon Jan 12 18:15:05 2004 From: my.lists at verizon.net (Francisco H Tapia) Date: Mon, 12 Jan 2004 16:15:05 -0800 Subject: [dba-SQLServer] Running Sprocs using a batch file that isthenexecuted in aNetwork Job Scheduler In-Reply-To: <249C1CB246997C48BB74963CCD361C1B014A0378@pnlmse28.pnl.gov> References: <249C1CB246997C48BB74963CCD361C1B014A0378@pnlmse28.pnl.gov> Message-ID: <40033889.1000400@verizon.net> There is no need for a DSN... you are connecting directly to the server for instance: Your batch would contain: osql -S SQLServerName -U UidName -P password -Q "Exec databasename.dbo.sproc Parameter1, Parameter2, etc" osql -S SQLServerName2 -U UidName -P password -Q "Exec databasename.dbo.sproc2 Parameter1, Parameter2, etc" osql -S SQLServerName3 -U UidName -P password -Q "Exec databasename.dbo.sproc3 Parameter1, Parameter2, etc" You can also run a sproc from one sql server from another but you'd have to set up a linked server within a particular sql server such as then you would only need to run your batch like this... osql -S SQLServerName -U UidName -P password -Q "Exec databasename.dbo.sproc Parameter1, Parameter2, etc" osql -S SQLServerName -U UidName -P password -Q "Exec LinkedServer2.databasename.dbo.sproc2 Parameter1, Parameter2, etc" osql -S SQLServerName -U UidName -P password -Q "Exec LinkedServer3.databasename.dbo.sproc3 Parameter1, Parameter2, etc" -- -Francisco Stoker, Kenneth E wrote: >I have been looking everything I can find on osql, but I cannot find >anything about using a dsn. There are switches for supplying a username >and password, but not a dsn. Is it possible to supply a dsn instead? >What would the switch be? > >Ken Stoker >Technology Commercialization >Information Systems Administrator >PH: (509) 375-3758 >FAX: (509) 375-6731 >E-mail: Kenneth.Stoker at pnl.gov > > >-----Original Message----- >From: Francisco H Tapia [mailto:my.lists at verizon.net] >Sent: Monday, January 12, 2004 2:25 PM >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] Running Sprocs using a batch file that >isthenexecuted in aNetwork Job Scheduler > > >i hear ya, it can be done using osql, check BOL for syntax > > > > > From knicholson at gpsx.net Tue Jan 13 13:08:17 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Tue, 13 Jan 2004 14:08:17 -0500 Subject: [dba-SQLServer]Stored Procedure Mystery Message-ID: Where has everybody been? No messages in like, forever. Did you all hit the lottery? Here is the top question of the day!!!! I have three stored procedures that I need to run in order for each account. exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'A', 0 exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841' Now, I have a file that contains that 6 digit number following the b32, and the corresponding '6881.xxxx' number in another file. All other values are constant. Is there some way (in English) to have these procedures run once with values, go to the next line and grab the next values and populate the line, execute, go to the next set of values, etc. THANKS! From tuxedo_man at hotmail.com Tue Jan 13 13:37:57 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Tue, 13 Jan 2004 19:37:57 +0000 Subject: [dba-SQLServer]Stored Procedure Mystery Message-ID: Where are the values grabbed from? A table or from the results of the sproc? Also, what is the signficance of the "exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841'" line? >From: "Nicholson, Karen" >Reply-To: dba-sqlserver at databaseadvisors.com >To: "Dba-Sqlserver (E-mail)" >Subject: [dba-SQLServer]Stored Procedure Mystery >Date: Tue, 13 Jan 2004 14:08:17 -0500 > >Where has everybody been? No messages in like, forever. Did you all hit >the >lottery? > >Here is the top question of the day!!!! > >I have three stored procedures that I need to run in order for each >account. > >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'A', 0 >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'C', 0 >exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841' > >Now, I have a file that contains that 6 digit number following the b32, and >the corresponding >'6881.xxxx' number in another file. All other values are constant. > >Is there some way (in English) to have these procedures run once with >values, go to the next line and grab the next values and populate the line, >execute, go to the next set of values, etc. > >THANKS! >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca From knicholson at gpsx.net Tue Jan 13 13:46:14 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Tue, 13 Jan 2004 14:46:14 -0500 Subject: [dba-SQLServer]Stored Procedure Mystery Message-ID: The values are grabbed from a table that I built. The 279104 is the system_no and the '6881.7841' is the cs_no. These are three stored procedures that need to be run in succession for all of the records in my table, myB32Updates. I have Professional SQL Server book open to SQL cursors. Trying to see if I can create a cursor to modify these three lines that I am holding in a stored procedure. -----Original Message----- From: Billy Pang [mailto:tuxedo_man at hotmail.com] Sent: Tuesday, January 13, 2004 2:38 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Stored Procedure Mystery Where are the values grabbed from? A table or from the results of the sproc? Also, what is the signficance of the "exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841'" line? >From: "Nicholson, Karen" >Reply-To: dba-sqlserver at databaseadvisors.com >To: "Dba-Sqlserver (E-mail)" >Subject: [dba-SQLServer]Stored Procedure Mystery >Date: Tue, 13 Jan 2004 14:08:17 -0500 > >Where has everybody been? No messages in like, forever. Did you all hit >the >lottery? > >Here is the top question of the day!!!! > >I have three stored procedures that I need to run in order for each >account. > >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'A', 0 >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'C', 0 >exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841' > >Now, I have a file that contains that 6 digit number following the b32, and >the corresponding >'6881.xxxx' number in another file. All other values are constant. > >Is there some way (in English) to have these procedures run once with >values, go to the next line and grab the next values and populate the line, >execute, go to the next set of values, etc. > >THANKS! >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoin .msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From knicholson at gpsx.net Tue Jan 13 14:25:47 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Tue, 13 Jan 2004 15:25:47 -0500 Subject: [dba-SQLServer]Stored Procedure Mystery Message-ID: I think I am getting it, doing the cursor thing. still have to add my begin statement fetch next (always reminds me of a dog ....) and so forth. Think this will work? CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no print convert(varchar, at system_no) + convert(varchar, at cs_no) exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 while (@counter <=5) and (@@fetch_status=0) close cursortest deallocate cursortest GO -----Original Message----- From: Nicholson, Karen [mailto:knicholson at gpsx.net] Sent: Tuesday, January 13, 2004 2:46 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Stored Procedure Mystery The values are grabbed from a table that I built. The 279104 is the system_no and the '6881.7841' is the cs_no. These are three stored procedures that need to be run in succession for all of the records in my table, myB32Updates. I have Professional SQL Server book open to SQL cursors. Trying to see if I can create a cursor to modify these three lines that I am holding in a stored procedure. -----Original Message----- From: Billy Pang [mailto:tuxedo_man at hotmail.com] Sent: Tuesday, January 13, 2004 2:38 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Stored Procedure Mystery Where are the values grabbed from? A table or from the results of the sproc? Also, what is the signficance of the "exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841'" line? >From: "Nicholson, Karen" >Reply-To: dba-sqlserver at databaseadvisors.com >To: "Dba-Sqlserver (E-mail)" >Subject: [dba-SQLServer]Stored Procedure Mystery >Date: Tue, 13 Jan 2004 14:08:17 -0500 > >Where has everybody been? No messages in like, forever. Did you all hit >the >lottery? > >Here is the top question of the day!!!! > >I have three stored procedures that I need to run in order for each >account. > >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'A', 0 >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'C', 0 >exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841' > >Now, I have a file that contains that 6 digit number following the b32, and >the corresponding >'6881.xxxx' number in another file. All other values are constant. > >Is there some way (in English) to have these procedures run once with >values, go to the next line and grab the next values and populate the line, >execute, go to the next set of values, etc. > >THANKS! >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoin .msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From tuxedo_man at hotmail.com Tue Jan 13 14:51:40 2004 From: tuxedo_man at hotmail.com (Billy Pang) Date: Tue, 13 Jan 2004 20:51:40 +0000 Subject: [dba-SQLServer]Stored Procedure Mystery Message-ID: Some thoughts: - not sure why you need the @counter <=5 in the while condition. maybe just using "@@FETCH_STATUS = 0" is good enough? - you probably want to use BEGIN-END block right below your WHILE loop; within the BEGIN-END block, put in there what you want to do for each record you retrieve from tblMyB32Updates. Alsol, you need to include the "fetch next from cursortest into @system_no, @cs_no" line in there so that you will move onto the next record. - I don't remember the syntax top of my head but if you are concerned with speed, try using the FAST-FORWARD-READ-ONLY cursor because it is faster than the other cursors HTH Billy >From: "Nicholson, Karen" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer]Stored Procedure Mystery >Date: Tue, 13 Jan 2004 15:25:47 -0500 > >I think I am getting it, doing the cursor thing. >still have to add my begin statement fetch next (always >reminds me of a dog ....) and so forth. Think this will >work? > > >CREATE PROCEDURE dbo.gps_move_to_B32 AS > >declare @counter int, > @system_no int, > @cs_no varchar(10) >declare cursortest CURSOR >GLOBAL >FOR > select system_no, cs_no > from > tblMyB32Updates > >select @counter = 1 >open cursortest >fetch next from cursortest into @system_no, @cs_no >print convert(varchar, at system_no) + convert(varchar, at cs_no) >exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 >while (@counter <=5) and (@@fetch_status=0) >close cursortest >deallocate cursortest >GO > >-----Original Message----- >From: Nicholson, Karen [mailto:knicholson at gpsx.net] >Sent: Tuesday, January 13, 2004 2:46 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer]Stored Procedure Mystery > > >The values are grabbed from a table that I built. The 279104 is the >system_no >and the '6881.7841' is the cs_no. > >These are three stored procedures that need to be run in succession for all >of the >records in my table, myB32Updates. > >I have Professional SQL Server book open to SQL cursors. Trying to see if >I >can >create a cursor to modify these three lines that I am holding in a stored >procedure. > >-----Original Message----- >From: Billy Pang [mailto:tuxedo_man at hotmail.com] >Sent: Tuesday, January 13, 2004 2:38 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer]Stored Procedure Mystery > > >Where are the values grabbed from? A table or from the results of the >sproc? > > Also, what is the signficance of the "exec ap_cs_account_to_change_tran >279104, 'GUARD', '6881.7841'" line? > > > >From: "Nicholson, Karen" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: "Dba-Sqlserver (E-mail)" > >Subject: [dba-SQLServer]Stored Procedure Mystery > >Date: Tue, 13 Jan 2004 14:08:17 -0500 > > > >Where has everybody been? No messages in like, forever. Did you all hit > >the > >lottery? > > > >Here is the top question of the day!!!! > > > >I have three stored procedures that I need to run in order for each > >account. > > > >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'A', 0 > >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'C', 0 > >exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841' > > > >Now, I have a file that contains that 6 digit number following the b32, >and > >the corresponding > >'6881.xxxx' number in another file. All other values are constant. > > > >Is there some way (in English) to have these procedures run once with > >values, go to the next line and grab the next values and populate the >line, > >execute, go to the next set of values, etc. > > > >THANKS! > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > >_________________________________________________________________ >MSN 8 with e-mail virus protection service: 2 months FREE* >http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoin >.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca > >_______________________________________________ >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 > _________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 From knicholson at gpsx.net Tue Jan 13 15:12:50 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Tue, 13 Jan 2004 16:12:50 -0500 Subject: [dba-SQLServer]Stored Procedure Mystery Message-ID: This is the completed code. I am doing them in groups of 5 because this stored procedure is populating tables to go over to a unix system. I don't want to bring down my data link, so I am doing it in bits and pieces, like groups of 5. CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates /*where system_no = 279051*/ select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no /*print convert(varchar, at system_no) + convert(varchar, at cs_no)*/ exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran @system_no, 'GUARD', @cs_no while (@counter <=5) and (@@fetch_status=0) begin select @counter = @counter +1 fetch next from cursortest into @system_no, @cs_no end close cursortest deallocate cursortest GO -----Original Message----- From: Billy Pang [mailto:tuxedo_man at hotmail.com] Sent: Tuesday, January 13, 2004 3:52 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Stored Procedure Mystery Some thoughts: - not sure why you need the @counter <=5 in the while condition. maybe just using "@@FETCH_STATUS = 0" is good enough? - you probably want to use BEGIN-END block right below your WHILE loop; within the BEGIN-END block, put in there what you want to do for each record you retrieve from tblMyB32Updates. Alsol, you need to include the "fetch next from cursortest into @system_no, @cs_no" line in there so that you will move onto the next record. - I don't remember the syntax top of my head but if you are concerned with speed, try using the FAST-FORWARD-READ-ONLY cursor because it is faster than the other cursors HTH Billy >From: "Nicholson, Karen" >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer]Stored Procedure Mystery >Date: Tue, 13 Jan 2004 15:25:47 -0500 > >I think I am getting it, doing the cursor thing. >still have to add my begin statement fetch next (always >reminds me of a dog ....) and so forth. Think this will >work? > > >CREATE PROCEDURE dbo.gps_move_to_B32 AS > >declare @counter int, > @system_no int, > @cs_no varchar(10) >declare cursortest CURSOR >GLOBAL >FOR > select system_no, cs_no > from > tblMyB32Updates > >select @counter = 1 >open cursortest >fetch next from cursortest into @system_no, @cs_no >print convert(varchar, at system_no) + convert(varchar, at cs_no) >exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 >while (@counter <=5) and (@@fetch_status=0) >close cursortest >deallocate cursortest >GO > >-----Original Message----- >From: Nicholson, Karen [mailto:knicholson at gpsx.net] >Sent: Tuesday, January 13, 2004 2:46 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer]Stored Procedure Mystery > > >The values are grabbed from a table that I built. The 279104 is the >system_no >and the '6881.7841' is the cs_no. > >These are three stored procedures that need to be run in succession for all >of the >records in my table, myB32Updates. > >I have Professional SQL Server book open to SQL cursors. Trying to see if >I >can >create a cursor to modify these three lines that I am holding in a stored >procedure. > >-----Original Message----- >From: Billy Pang [mailto:tuxedo_man at hotmail.com] >Sent: Tuesday, January 13, 2004 2:38 PM >To: dba-sqlserver at databaseadvisors.com >Subject: RE: [dba-SQLServer]Stored Procedure Mystery > > >Where are the values grabbed from? A table or from the results of the >sproc? > > Also, what is the signficance of the "exec ap_cs_account_to_change_tran >279104, 'GUARD', '6881.7841'" line? > > > >From: "Nicholson, Karen" > >Reply-To: dba-sqlserver at databaseadvisors.com > >To: "Dba-Sqlserver (E-mail)" > >Subject: [dba-SQLServer]Stored Procedure Mystery > >Date: Tue, 13 Jan 2004 14:08:17 -0500 > > > >Where has everybody been? No messages in like, forever. Did you all hit > >the > >lottery? > > > >Here is the top question of the day!!!! > > > >I have three stored procedures that I need to run in order for each > >account. > > > >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'A', 0 > >exec ap_system_to_b32 279104, '6881.7841', 'GUARD', 'C', 0 > >exec ap_cs_account_to_change_tran 279104, 'GUARD', '6881.7841' > > > >Now, I have a file that contains that 6 digit number following the b32, >and > >the corresponding > >'6881.xxxx' number in another file. All other values are constant. > > > >Is there some way (in English) to have these procedures run once with > >values, go to the next line and grab the next values and populate the >line, > >execute, go to the next set of values, etc. > > > >THANKS! > >_______________________________________________ > >dba-SQLServer mailing list > >dba-SQLServer at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > >http://www.databaseadvisors.com > > > >_________________________________________________________________ >MSN 8 with e-mail virus protection service: 2 months FREE* >http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoi n >.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca > >_______________________________________________ >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 > _________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From knicholson at gpsx.net Thu Jan 15 08:57:23 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Thu, 15 Jan 2004 09:57:23 -0500 Subject: [dba-SQLServer]Cursor Help!!! Message-ID: This procedure just hits one record, it does not loop through. Any ideas why? This is only my second cursor routine, thank goodness. Oh - and the between statement is correct - all those records are there in the tblMyB32Updates. CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates where system_no between 279128 AND 279364 select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no print convert(varchar, at system_no) + convert(varchar, at cs_no) exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran @system_no, 'GUARD', @cs_no insert into system_event(cs_no, [date],event_class,comline_no,operator,scheduled_date,server_id, cs_event_no) values(@cs_no, getdate(), 'A',0,'KN','1/1/1900','A',4625) while (@@fetch_status=0) begin select @counter = @counter +1 fetch next from cursortest into @system_no, @cs_no end close cursortest deallocate cursortest GO From Kenneth.Stoker at pnl.gov Thu Jan 15 10:58:51 2004 From: Kenneth.Stoker at pnl.gov (Stoker, Kenneth E) Date: Thu, 15 Jan 2004 08:58:51 -0800 Subject: [dba-SQLServer]Cursor Help!!! Message-ID: <249C1CB246997C48BB74963CCD361C1B014A037E@pnlmse28.pnl.gov> I believe that it is because your loop is only incrementing your count variable and fetching the next record. All the exec statements and the insert statement occur prior to the while loop and therefore only get executed once because they are not part of the loop. If you move your while (@@fetch_status = 0) Begin lines before the print line, like below, it should work. CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates where system_no between 279128 AND 279364 select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no while (@@fetch_status=0) begin print convert(varchar, at system_no) + convert(varchar, at cs_no) exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran @system_no, 'GUARD', @cs_no insert into system_event(cs_no, [date],event_class,comline_no,operator,scheduled_date,server_id, cs_event_no) values(@cs_no, getdate(), 'A',0,'KN','1/1/1900','A',4625) select @counter = @counter +1 fetch next from cursortest into @system_no, @cs_no end close cursortest deallocate cursortest GO Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov -----Original Message----- From: Nicholson, Karen [mailto:knicholson at gpsx.net] Sent: Thursday, January 15, 2004 6:57 AM To: Dba-Sqlserver (E-mail) Subject: [dba-SQLServer]Cursor Help!!! This procedure just hits one record, it does not loop through. Any ideas why? This is only my second cursor routine, thank goodness. Oh - and the between statement is correct - all those records are there in the tblMyB32Updates. CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates where system_no between 279128 AND 279364 select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no print convert(varchar, at system_no) + convert(varchar, at cs_no) exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran @system_no, 'GUARD', @cs_no insert into system_event(cs_no, [date],event_class,comline_no,operator,scheduled_date,server_id, cs_event_no) values(@cs_no, getdate(), 'A',0,'KN','1/1/1900','A',4625) while (@@fetch_status=0) begin select @counter = @counter +1 fetch next from cursortest into @system_no, @cs_no end close cursortest deallocate cursortest GO _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From knicholson at gpsx.net Thu Jan 15 11:07:12 2004 From: knicholson at gpsx.net (Nicholson, Karen) Date: Thu, 15 Jan 2004 12:07:12 -0500 Subject: [dba-SQLServer]Cursor Help!!! Message-ID: You are my hero. Thank you so much. -----Original Message----- From: Stoker, Kenneth E [mailto:Kenneth.Stoker at pnl.gov] Sent: Thursday, January 15, 2004 11:59 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Cursor Help!!! I believe that it is because your loop is only incrementing your count variable and fetching the next record. All the exec statements and the insert statement occur prior to the while loop and therefore only get executed once because they are not part of the loop. If you move your while (@@fetch_status = 0) Begin lines before the print line, like below, it should work. CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates where system_no between 279128 AND 279364 select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no while (@@fetch_status=0) begin print convert(varchar, at system_no) + convert(varchar, at cs_no) exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran @system_no, 'GUARD', @cs_no insert into system_event(cs_no, [date],event_class,comline_no,operator,scheduled_date,server_id, cs_event_no) values(@cs_no, getdate(), 'A',0,'KN','1/1/1900','A',4625) select @counter = @counter +1 fetch next from cursortest into @system_no, @cs_no end close cursortest deallocate cursortest GO Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov -----Original Message----- From: Nicholson, Karen [mailto:knicholson at gpsx.net] Sent: Thursday, January 15, 2004 6:57 AM To: Dba-Sqlserver (E-mail) Subject: [dba-SQLServer]Cursor Help!!! This procedure just hits one record, it does not loop through. Any ideas why? This is only my second cursor routine, thank goodness. Oh - and the between statement is correct - all those records are there in the tblMyB32Updates. CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates where system_no between 279128 AND 279364 select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no print convert(varchar, at system_no) + convert(varchar, at cs_no) exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran @system_no, 'GUARD', @cs_no insert into system_event(cs_no, [date],event_class,comline_no,operator,scheduled_date,server_id, cs_event_no) values(@cs_no, getdate(), 'A',0,'KN','1/1/1900','A',4625) while (@@fetch_status=0) begin select @counter = @counter +1 fetch next from cursortest into @system_no, @cs_no end close cursortest deallocate cursortest GO _______________________________________________ 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 Kenneth.Stoker at pnl.gov Thu Jan 15 11:20:28 2004 From: Kenneth.Stoker at pnl.gov (Stoker, Kenneth E) Date: Thu, 15 Jan 2004 09:20:28 -0800 Subject: [dba-SQLServer]Cursor Help!!! Message-ID: <249C1CB246997C48BB74963CCD361C1B014A0380@pnlmse28.pnl.gov> Glad to hear it worked and to be of help. Maybe this will start a new trend for me, finally able to be useful to the lists here :-) Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov -----Original Message----- From: Nicholson, Karen [mailto:knicholson at gpsx.net] Sent: Thursday, January 15, 2004 9:07 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Cursor Help!!! You are my hero. Thank you so much. -----Original Message----- From: Stoker, Kenneth E [mailto:Kenneth.Stoker at pnl.gov] Sent: Thursday, January 15, 2004 11:59 AM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Cursor Help!!! I believe that it is because your loop is only incrementing your count variable and fetching the next record. All the exec statements and the insert statement occur prior to the while loop and therefore only get executed once because they are not part of the loop. If you move your while (@@fetch_status = 0) Begin lines before the print line, like below, it should work. CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates where system_no between 279128 AND 279364 select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no while (@@fetch_status=0) begin print convert(varchar, at system_no) + convert(varchar, at cs_no) exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran @system_no, 'GUARD', @cs_no insert into system_event(cs_no, [date],event_class,comline_no,operator,scheduled_date,server_id, cs_event_no) values(@cs_no, getdate(), 'A',0,'KN','1/1/1900','A',4625) select @counter = @counter +1 fetch next from cursortest into @system_no, @cs_no end close cursortest deallocate cursortest GO Ken Stoker Technology Commercialization Information Systems Administrator PH: (509) 375-3758 FAX: (509) 375-6731 E-mail: Kenneth.Stoker at pnl.gov -----Original Message----- From: Nicholson, Karen [mailto:knicholson at gpsx.net] Sent: Thursday, January 15, 2004 6:57 AM To: Dba-Sqlserver (E-mail) Subject: [dba-SQLServer]Cursor Help!!! This procedure just hits one record, it does not loop through. Any ideas why? This is only my second cursor routine, thank goodness. Oh - and the between statement is correct - all those records are there in the tblMyB32Updates. CREATE PROCEDURE dbo.gps_move_to_B32 AS declare @counter int, @system_no int, @cs_no varchar(10) declare cursortest CURSOR GLOBAL FOR select system_no, cs_no from tblMyB32Updates where system_no between 279128 AND 279364 select @counter = 1 open cursortest fetch next from cursortest into @system_no, @cs_no print convert(varchar, at system_no) + convert(varchar, at cs_no) exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'A', 0 exec ap_system_to_b32 @system_no, @cs_no, 'GUARD', 'C', 0 exec ap_cs_account_to_change_tran @system_no, 'GUARD', @cs_no insert into system_event(cs_no, [date],event_class,comline_no,operator,scheduled_date,server_id, cs_event_no) values(@cs_no, getdate(), 'A',0,'KN','1/1/1900','A',4625) while (@@fetch_status=0) begin select @counter = @counter +1 fetch next from cursortest into @system_no, @cs_no end close cursortest deallocate cursortest GO _______________________________________________ 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 chizotz at charter.net Sat Jan 17 02:01:11 2004 From: chizotz at charter.net (Ron Allen) Date: Sat, 17 Jan 2004 02:01:11 -0600 Subject: [dba-SQLServer]Running DTS Package from external program? In-Reply-To: References: Message-ID: <185604671.20040117020111@charter.net> Is it possible to execute a SQL Server 2000 DTS package from an external program, such as one written in C#? If so, any pointers in the right direction on how to do it? The C# program can have admin permissions if needed. I've looked at BOL and Googled a bit and don't see anything... Thanks, Ron From martyconnelly at shaw.ca Sat Jan 17 12:19:27 2004 From: martyconnelly at shaw.ca (MartyConnelly) Date: Sat, 17 Jan 2004 10:19:27 -0800 Subject: [dba-SQLServer]Running DTS Package from external program? References: <185604671.20040117020111@charter.net> Message-ID: <40097CAF.8010402@shaw.ca> Have a look around here http://www.sqlservercentral.com/default.asp To do it in VB http://www.sqldts.com/default.aspx?6,104,208,7,1 and Using SQL Server DTS with Visual Basic: Resources and Known Issues Most of these are getting around multi threading not available in VB http://www.sqldts.com/default.aspx?258 One major consideration to take into account when executing DTS from a client machine is that, such as you would be doing when running your application on your machine is that where the package executes, under the security context of the logged on user. This means any file paths must be accessible, and any data transferred will go through your machine. DTS is not a server side process. So check your clients will have access to required dll's as well. Ron Allen wrote: >Is it possible to execute a SQL Server 2000 DTS package from an >external program, such as one written in C#? If so, any pointers in >the right direction on how to do it? The C# program can have admin >permissions if needed. > >I've looked at BOL and Googled a bit and don't see anything... > >Thanks, > >Ron > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > > > > -- Marty Connelly Victoria, B.C. Canada From chizotz at charter.net Mon Jan 19 00:18:29 2004 From: chizotz at charter.net (Ron Allen) Date: Mon, 19 Jan 2004 00:18:29 -0600 Subject: [dba-SQLServer]Running DTS Package from external program? In-Reply-To: <40097CAF.8010402@shaw.ca> References: <185604671.20040117020111@charter.net> <40097CAF.8010402@shaw.ca> Message-ID: <631019796.20040119001829@charter.net> Thank you Marty. I posted that message as my last work-related act before the weekend, and now my reply to you is the first work-related act of a new week. In the morning, I'll start wading through these sites. They look pretty helpful to me. Thanks, Ron Saturday, January 17, 2004, 12:19:27 PM, you wrote: M> Have a look around here M> http://www.sqlservercentral.com/default.asp M> To do it in VB M> http://www.sqldts.com/default.aspx?6,104,208,7,1 M> and M> Using SQL Server DTS with Visual Basic: Resources and Known Issues M> Most of these are getting around multi threading not available in VB M> http://www.sqldts.com/default.aspx?258 M> One major consideration to take into account when executing DTS from a M> client machine is that, such as you would be doing when running your M> application on your machine is that where the package executes, under M> the security context of the logged on user. This means any file paths M> must be accessible, and any data transferred will go through your M> machine. DTS is not a server side process. So check your clients will M> have access M> to required dll's as well. From Robert.Djabarov at usaa.com Mon Jan 19 09:36:34 2004 From: Robert.Djabarov at usaa.com (Djabarov, Robert) Date: Mon, 19 Jan 2004 09:36:34 -0600 Subject: [dba-SQLServer]Running DTS Package from external program? Message-ID: <3CCEA32DFF043C4CB99B835557E11B300389D5DA@ex02.eagle.usaa.com> It's not C#, but you can figure it out how to use there as well. http://support.microsoft.com/?kbid=252987 -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Ron Allen Sent: Saturday, January 17, 2004 2:01 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer]Running DTS Package from external program? Is it possible to execute a SQL Server 2000 DTS package from an external program, such as one written in C#? If so, any pointers in the right direction on how to do it? The C# program can have admin permissions if needed. I've looked at BOL and Googled a bit and don't see anything... Thanks, Ron _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From chizotz at charter.net Mon Jan 19 17:05:52 2004 From: chizotz at charter.net (Ron Allen) Date: Mon, 19 Jan 2004 17:05:52 -0600 Subject: [dba-SQLServer]Running DTS Package from external program? In-Reply-To: <40097CAF.8010402@shaw.ca> References: <185604671.20040117020111@charter.net> <40097CAF.8010402@shaw.ca> Message-ID: <1061463171.20040119170552@charter.net> FYI, I found that by using the dtsrun utility in a parameterized stored procedure that uses xp_cmdshell, I could execute my DTS package from C# and force it to run on the server -- perfect solution for me. Thanks for the help on this, you got me pointed in the right direction. Ron From davide at dalyn.co.nz Mon Jan 19 19:43:04 2004 From: davide at dalyn.co.nz (David Emerson) Date: Tue, 20 Jan 2004 14:43:04 +1300 Subject: [dba-SQLServer]Sproc not returning records Message-ID: <5.2.0.9.0.20040120142924.00b2a970@mail.dalyn.co.nz> AXP, SQL2000 I have a sproc that calls a number of other sprocs to fill in a table. Then it uses this table to retrieve records. If I run it (by pressing the ! button in Access) then the table is filled in, but the grid that shows the retrieved records has two column headings Expr<1> and Expr<2> (three are expected with proper names). There are the correct number of records but all the rows are blank. If however I run the code to fill in the table first. Then when that has stopped run the code for retrieving the records I get a grid showing the correct column names and data. My next attempt was to have a second sproc that executes the first one (without the final select statement), then runs the select statement. This had the same effect as if it was one sproc. Does anyone have an idea why this is happening? The code is below. Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (877) 456-1205 ALTER PROCEDURE spSalesTransactLoadSummary ( @dtmDate1 varchar(20), @intDate2 int ) AS SET NOCOUNT ON DELETE FROM dbo.ttmpLoadAllocateRpt DECLARE @intyyyymm int, @charDate varchar(10) WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= @intDate2 BEGIN SET @intyyyymm = YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1) SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, @dtmDate1)) + '/' + CONVERT(nvarchar(20), DATEPART(dd, @dtmDate1)) + '/' + CONVERT(nvarchar(20),DATEPART(yy, @dtmDate1)) EXEC dbo.spLoadAllocat4 @intyyyymm EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate EXEC dbo.spLoadAllocatOther @intyyyymm SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) END --Note - up to here works fine. Next statement not work if run at same time as above. SELECT tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth, SUM(ttmpLoadAllocateRpt.GJ) as GJSum FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN (tblGateStations INNER JOIN ttmpLoadAllocateRpt ON tblGateStations.GateID = ttmpLoadAllocateRpt.GateIDNo) ON tblCustomers.CustomerID = ttmpLoadAllocateRpt.CustomerID) ON tblNetOwners.NetOwnerID = tblGateStations.NetOwnIDNo GROUP BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth ORDER BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth If @@Error <> 0 Begin Select 'Unexpected error occurred: ', @@Error Return @@Error End else return 0 From DMcAfee at haascnc.com Mon Jan 19 20:39:51 2004 From: DMcAfee at haascnc.com (David McAfee) Date: Mon, 19 Jan 2004 18:39:51 -0800 Subject: [dba-SQLServer]Sproc not returning records Message-ID: <657FB70438B7D311AF320090279C18010614401E@EXCHMAIL> put SET NOCOUNT OFF before your final select (after your note) which will return the data to Access. HTH David McAfee -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Monday, January 19, 2004 5:43 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer]Sproc not returning records AXP, SQL2000 I have a sproc that calls a number of other sprocs to fill in a table. Then it uses this table to retrieve records. If I run it (by pressing the ! button in Access) then the table is filled in, but the grid that shows the retrieved records has two column headings Expr<1> and Expr<2> (three are expected with proper names). There are the correct number of records but all the rows are blank. If however I run the code to fill in the table first. Then when that has stopped run the code for retrieving the records I get a grid showing the correct column names and data. My next attempt was to have a second sproc that executes the first one (without the final select statement), then runs the select statement. This had the same effect as if it was one sproc. Does anyone have an idea why this is happening? The code is below. Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (877) 456-1205 ALTER PROCEDURE spSalesTransactLoadSummary ( @dtmDate1 varchar(20), @intDate2 int ) AS SET NOCOUNT ON DELETE FROM dbo.ttmpLoadAllocateRpt DECLARE @intyyyymm int, @charDate varchar(10) WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= @intDate2 BEGIN SET @intyyyymm = YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1) SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, @dtmDate1)) + '/' + CONVERT(nvarchar(20), DATEPART(dd, @dtmDate1)) + '/' + CONVERT(nvarchar(20),DATEPART(yy, @dtmDate1)) EXEC dbo.spLoadAllocat4 @intyyyymm EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate EXEC dbo.spLoadAllocatOther @intyyyymm SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) END --Note - up to here works fine. Next statement not work if run at same time as above. SELECT tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth, SUM(ttmpLoadAllocateRpt.GJ) as GJSum FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN (tblGateStations INNER JOIN ttmpLoadAllocateRpt ON tblGateStations.GateID = ttmpLoadAllocateRpt.GateIDNo) ON tblCustomers.CustomerID = ttmpLoadAllocateRpt.CustomerID) ON tblNetOwners.NetOwnerID = tblGateStations.NetOwnIDNo GROUP BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth ORDER BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth If @@Error <> 0 Begin Select 'Unexpected error occurred: ', @@Error Return @@Error End else return 0 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Mon Jan 19 20:59:05 2004 From: davide at dalyn.co.nz (David Emerson) Date: Tue, 20 Jan 2004 15:59:05 +1300 Subject: [dba-SQLServer]Sproc not returning records In-Reply-To: <657FB70438B7D311AF320090279C18010614401E@EXCHMAIL> Message-ID: <5.2.0.9.0.20040120155833.00bc0400@mail.dalyn.co.nz> Thanks for the response. Tried it and made no difference. David At 19/01/2004, you wrote: >put > >SET NOCOUNT OFF > > before your final select (after your note) which will return the data to > Access. > >HTH >David McAfee >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >Emerson >Sent: Monday, January 19, 2004 5:43 PM >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer]Sproc not returning records > > >AXP, SQL2000 > >I have a sproc that calls a number of other sprocs to fill in a >table. Then it uses this table to retrieve records. If I run it (by >pressing the ! button in Access) then the table is filled in, but the grid >that shows the retrieved records has two column headings Expr<1> and >Expr<2> (three are expected with proper names). There are the correct >number of records but all the rows are blank. > >If however I run the code to fill in the table first. Then when that has >stopped run the code for retrieving the records I get a grid showing the >correct column names and data. > >My next attempt was to have a second sproc that executes the first one >(without the final select statement), then runs the select statement. This >had the same effect as if it was one sproc. > >Does anyone have an idea why this is happening? The code is below. > >Regards > >David Emerson >Dalyn Software Ltd >25 Cunliffe St, Churton Park >Wellington, New Zealand >Ph/Fax (877) 456-1205 > > >ALTER PROCEDURE spSalesTransactLoadSummary > ( > @dtmDate1 varchar(20), > @intDate2 int > ) >AS > SET NOCOUNT ON > > DELETE FROM dbo.ttmpLoadAllocateRpt > > DECLARE @intyyyymm int, @charDate varchar(10) > > WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= @intDate2 > BEGIN > SET @intyyyymm = YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1) > SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, >@dtmDate1)) + '/' + > CONVERT(nvarchar(20), DATEPART(dd, @dtmDate1)) + >'/' + > CONVERT(nvarchar(20),DATEPART(yy, @dtmDate1)) > EXEC dbo.spLoadAllocat4 @intyyyymm > EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate > EXEC dbo.spLoadAllocatOther @intyyyymm > SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) > END > >--Note - up to here works fine. Next statement not work if run at same >time as above. > > SELECT tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth, > SUM(ttmpLoadAllocateRpt.GJ) as GJSum > FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN >(tblGateStations INNER JOIN > ttmpLoadAllocateRpt ON tblGateStations.GateID = >ttmpLoadAllocateRpt.GateIDNo) > ON tblCustomers.CustomerID = >ttmpLoadAllocateRpt.CustomerID) ON > tblNetOwners.NetOwnerID = tblGateStations.NetOwnIDNo > GROUP BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth > ORDER BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth > > If @@Error <> 0 > Begin > Select 'Unexpected error occurred: ', @@Error > Return @@Error > End > else > return 0 > >_______________________________________________ >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 Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax 0064 4 478-7456 From my.lists at verizon.net Tue Jan 20 03:36:09 2004 From: my.lists at verizon.net (Francisco H Tapia) Date: Tue, 20 Jan 2004 01:36:09 -0800 Subject: [dba-SQLServer]Sproc not returning records In-Reply-To: <5.2.0.9.0.20040120155833.00bc0400@mail.dalyn.co.nz> References: <5.2.0.9.0.20040120155833.00bc0400@mail.dalyn.co.nz> Message-ID: <400CF689.8090304@verizon.net> just a hunch but try remming these out... >> else >> return 0 -- -Francisco David Emerson wrote: > Thanks for the response. Tried it and made no difference. > > David > > At 19/01/2004, you wrote: > >> put >> >> SET NOCOUNT OFF >> >> before your final select (after your note) which will return the data >> to Access. >> >> HTH >> David McAfee >> -----Original Message----- >> From: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >> Emerson >> Sent: Monday, January 19, 2004 5:43 PM >> To: dba-SQLServer at databaseadvisors.com >> Subject: [dba-SQLServer]Sproc not returning records >> >> >> AXP, SQL2000 >> >> I have a sproc that calls a number of other sprocs to fill in a >> table. Then it uses this table to retrieve records. If I run it (by >> pressing the ! button in Access) then the table is filled in, but the >> grid >> that shows the retrieved records has two column headings Expr<1> and >> Expr<2> (three are expected with proper names). There are the correct >> number of records but all the rows are blank. >> >> If however I run the code to fill in the table first. Then when that has >> stopped run the code for retrieving the records I get a grid showing the >> correct column names and data. >> >> My next attempt was to have a second sproc that executes the first one >> (without the final select statement), then runs the select statement. >> This >> had the same effect as if it was one sproc. >> >> Does anyone have an idea why this is happening? The code is below. >> >> Regards >> >> David Emerson >> Dalyn Software Ltd >> 25 Cunliffe St, Churton Park >> Wellington, New Zealand >> Ph/Fax (877) 456-1205 >> >> >> ALTER PROCEDURE spSalesTransactLoadSummary >> ( >> @dtmDate1 varchar(20), >> @intDate2 int >> ) >> AS >> SET NOCOUNT ON >> >> DELETE FROM dbo.ttmpLoadAllocateRpt >> >> DECLARE @intyyyymm int, @charDate varchar(10) >> >> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= @intDate2 >> BEGIN >> SET @intyyyymm = YEAR(@dtmDate1) * 100 + >> MONTH(@dtmDate1) >> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, >> @dtmDate1)) + '/' + >> CONVERT(nvarchar(20), DATEPART(dd, @dtmDate1)) + >> '/' + >> CONVERT(nvarchar(20),DATEPART(yy, @dtmDate1)) >> EXEC dbo.spLoadAllocat4 @intyyyymm >> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate >> EXEC dbo.spLoadAllocatOther @intyyyymm >> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) >> END >> >> --Note - up to here works fine. Next statement not work if run at same >> time as above. >> >> SELECT tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth, >> SUM(ttmpLoadAllocateRpt.GJ) as GJSum >> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN >> (tblGateStations INNER JOIN >> ttmpLoadAllocateRpt ON tblGateStations.GateID = >> ttmpLoadAllocateRpt.GateIDNo) >> ON tblCustomers.CustomerID = >> ttmpLoadAllocateRpt.CustomerID) ON >> tblNetOwners.NetOwnerID = tblGateStations.NetOwnIDNo >> GROUP BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth >> ORDER BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth >> >> If @@Error <> 0 >> Begin >> Select 'Unexpected error occurred: ', @@Error >> Return @@Error >> End >> else >> return 0 >> >> _______________________________________________ >> 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 > > > Regards > > David Emerson From davide at dalyn.co.nz Tue Jan 20 14:00:05 2004 From: davide at dalyn.co.nz (David Emerson) Date: Wed, 21 Jan 2004 09:00:05 +1300 Subject: [dba-SQLServer]Sproc not returning records In-Reply-To: <400CF689.8090304@verizon.net> References: <5.2.0.9.0.20040120155833.00bc0400@mail.dalyn.co.nz> <5.2.0.9.0.20040120155833.00bc0400@mail.dalyn.co.nz> Message-ID: <5.2.0.9.0.20040121085903.00b2ab70@mail.dalyn.co.nz> Still no joy. David At 20/01/2004, Francisco wrote: >just a hunch but try remming these out... > >> else > >> return 0 >-- >-Francisco > >David Emerson wrote: > >>Thanks for the response. Tried it and made no difference. >>David >>At 19/01/2004, you wrote: >> >>>put >>> >>>SET NOCOUNT OFF >>> >>> before your final select (after your note) which will return the data >>> to Access. >>> >>>HTH >>>David McAfee >>>-----Original Message----- >>>From: dba-sqlserver-bounces at databaseadvisors.com >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >>>Emerson >>>Sent: Monday, January 19, 2004 5:43 PM >>>To: dba-SQLServer at databaseadvisors.com >>>Subject: [dba-SQLServer]Sproc not returning records >>> >>>AXP, SQL2000 >>> >>>I have a sproc that calls a number of other sprocs to fill in a >>>table. Then it uses this table to retrieve records. If I run it (by >>>pressing the ! button in Access) then the table is filled in, but the grid >>>that shows the retrieved records has two column headings Expr<1> and >>>Expr<2> (three are expected with proper names). There are the correct >>>number of records but all the rows are blank. >>> >>>If however I run the code to fill in the table first. Then when that has >>>stopped run the code for retrieving the records I get a grid showing the >>>correct column names and data. >>> >>>My next attempt was to have a second sproc that executes the first one >>>(without the final select statement), then runs the select statement. >>>This >>>had the same effect as if it was one sproc. >>> >>>Does anyone have an idea why this is happening? The code is below. >>> >>>Regards >>> >>>David Emerson >>>Dalyn Software Ltd >>>25 Cunliffe St, Churton Park >>>Wellington, New Zealand >>>Ph/Fax (877) 456-1205 >>> >>> >>>ALTER PROCEDURE spSalesTransactLoadSummary >>> ( >>> @dtmDate1 varchar(20), >>> @intDate2 int >>> ) >>>AS >>> SET NOCOUNT ON >>> >>> DELETE FROM dbo.ttmpLoadAllocateRpt >>> >>> DECLARE @intyyyymm int, @charDate varchar(10) >>> >>> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= @intDate2 >>> BEGIN >>> SET @intyyyymm = YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1) >>> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, >>>@dtmDate1)) + '/' + >>> CONVERT(nvarchar(20), DATEPART(dd, @dtmDate1)) + >>>'/' + >>> CONVERT(nvarchar(20),DATEPART(yy, @dtmDate1)) >>> EXEC dbo.spLoadAllocat4 @intyyyymm >>> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate >>> EXEC dbo.spLoadAllocatOther @intyyyymm >>> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) >>> END >>> >>>--Note - up to here works fine. Next statement not work if run at same >>>time as above. >>> >>> SELECT tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth, >>> SUM(ttmpLoadAllocateRpt.GJ) as GJSum >>> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN >>>(tblGateStations INNER JOIN >>> ttmpLoadAllocateRpt ON tblGateStations.GateID = >>>ttmpLoadAllocateRpt.GateIDNo) >>> ON tblCustomers.CustomerID = >>>ttmpLoadAllocateRpt.CustomerID) ON >>> tblNetOwners.NetOwnerID = tblGateStations.NetOwnIDNo >>> GROUP BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth >>> ORDER BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth >>> >>> If @@Error <> 0 >>> Begin >>> Select 'Unexpected error occurred: ', @@Error >>> Return @@Error >>> End >>> else >>> return 0 From DMcAfee at haascnc.com Tue Jan 20 14:54:14 2004 From: DMcAfee at haascnc.com (David McAfee) Date: Tue, 20 Jan 2004 12:54:14 -0800 Subject: [dba-SQLServer]Sproc not returning records Message-ID: <657FB70438B7D311AF320090279C180106144022@EXCHMAIL> David, did you try both my and Francisco's advise together? I believe you need the SET NOCOUNT OFF after your notes, but following your code it also looks like you end with either a choice of returning an error or a 0 (if no error). Try commenting out that whole block as such: /* If @@Error <> 0 Begin Select 'Unexpected error occurred: ', @@Error Return @@Error End else return 0 */ David -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Tuesday, January 20, 2004 12:00 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer]Sproc not returning records Still no joy. David At 20/01/2004, Francisco wrote: >just a hunch but try remming these out... > >> else > >> return 0 >-- >-Francisco > >David Emerson wrote: > >>Thanks for the response. Tried it and made no difference. >>David >>At 19/01/2004, you wrote: >> >>>put >>> >>>SET NOCOUNT OFF >>> >>> before your final select (after your note) which will return the data >>> to Access. >>> >>>HTH >>>David McAfee >>>-----Original Message----- >>>From: dba-sqlserver-bounces at databaseadvisors.com >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >>>Emerson >>>Sent: Monday, January 19, 2004 5:43 PM >>>To: dba-SQLServer at databaseadvisors.com >>>Subject: [dba-SQLServer]Sproc not returning records >>> >>>AXP, SQL2000 >>> >>>I have a sproc that calls a number of other sprocs to fill in a >>>table. Then it uses this table to retrieve records. If I run it (by >>>pressing the ! button in Access) then the table is filled in, but the grid >>>that shows the retrieved records has two column headings Expr<1> and >>>Expr<2> (three are expected with proper names). There are the correct >>>number of records but all the rows are blank. >>> >>>If however I run the code to fill in the table first. Then when that has >>>stopped run the code for retrieving the records I get a grid showing the >>>correct column names and data. >>> >>>My next attempt was to have a second sproc that executes the first one >>>(without the final select statement), then runs the select statement. >>>This >>>had the same effect as if it was one sproc. >>> >>>Does anyone have an idea why this is happening? The code is below. >>> >>>Regards >>> >>>David Emerson >>>Dalyn Software Ltd >>>25 Cunliffe St, Churton Park >>>Wellington, New Zealand >>>Ph/Fax (877) 456-1205 >>> >>> >>>ALTER PROCEDURE spSalesTransactLoadSummary >>> ( >>> @dtmDate1 varchar(20), >>> @intDate2 int >>> ) >>>AS >>> SET NOCOUNT ON >>> >>> DELETE FROM dbo.ttmpLoadAllocateRpt >>> >>> DECLARE @intyyyymm int, @charDate varchar(10) >>> >>> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= @intDate2 >>> BEGIN >>> SET @intyyyymm = YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1) >>> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, >>>@dtmDate1)) + '/' + >>> CONVERT(nvarchar(20), DATEPART(dd, @dtmDate1)) + >>>'/' + >>> CONVERT(nvarchar(20),DATEPART(yy, @dtmDate1)) >>> EXEC dbo.spLoadAllocat4 @intyyyymm >>> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate >>> EXEC dbo.spLoadAllocatOther @intyyyymm >>> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) >>> END >>> >>>--Note - up to here works fine. Next statement not work if run at same >>>time as above. >>> >>> SELECT tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth, >>> SUM(ttmpLoadAllocateRpt.GJ) as GJSum >>> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN >>>(tblGateStations INNER JOIN >>> ttmpLoadAllocateRpt ON tblGateStations.GateID = >>>ttmpLoadAllocateRpt.GateIDNo) >>> ON tblCustomers.CustomerID = >>>ttmpLoadAllocateRpt.CustomerID) ON >>> tblNetOwners.NetOwnerID = tblGateStations.NetOwnIDNo >>> GROUP BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth >>> ORDER BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth >>> >>> If @@Error <> 0 >>> Begin >>> Select 'Unexpected error occurred: ', @@Error >>> Return @@Error >>> End >>> else >>> return 0 From davide at dalyn.co.nz Tue Jan 20 15:16:42 2004 From: davide at dalyn.co.nz (David Emerson) Date: Wed, 21 Jan 2004 10:16:42 +1300 Subject: [dba-SQLServer]Sproc not returning records In-Reply-To: <657FB70438B7D311AF320090279C180106144022@EXCHMAIL> Message-ID: <5.2.0.9.0.20040121101431.00ba7fd8@mail.dalyn.co.nz> Tried all permutations of the suggestions including your one below. Still no luck. It seems strange that the number of records is correct, just the number of columns and column headings are wrong. David At 20/01/2004, you wrote: >David, did you try both my and Francisco's advise together? >I believe you need the SET NOCOUNT OFF after your notes, >but following your code it also looks like you end with either >a choice of returning an error or a 0 (if no error). > >Try commenting out that whole block as such: > >/* >If @@Error <> 0 > Begin > Select 'Unexpected error occurred: ', @@Error > Return @@Error > End >else > return 0 >*/ > >David >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >Emerson >Sent: Tuesday, January 20, 2004 12:00 PM >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer]Sproc not returning records > >Still no joy. > >David > >At 20/01/2004, Francisco wrote: > >just a hunch but try remming these out... > > >> else > > >> return 0 > >-- > >-Francisco > > > >David Emerson wrote: > > > >>Thanks for the response. Tried it and made no difference. > >>David > >>At 19/01/2004, you wrote: > >> > >>>put > >>> > >>>SET NOCOUNT OFF > >>> > >>> before your final select (after your note) which will return the data > >>> to Access. > >>> > >>>HTH > >>>David McAfee > >>>-----Original Message----- > >>>From: dba-sqlserver-bounces at databaseadvisors.com > >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David > >>>Emerson > >>>Sent: Monday, January 19, 2004 5:43 PM > >>>To: dba-SQLServer at databaseadvisors.com > >>>Subject: [dba-SQLServer]Sproc not returning records > >>> > >>>AXP, SQL2000 > >>> > >>>I have a sproc that calls a number of other sprocs to fill in a > >>>table. Then it uses this table to retrieve records. If I run it (by > >>>pressing the ! button in Access) then the table is filled in, but the grid > >>>that shows the retrieved records has two column headings Expr<1> and > >>>Expr<2> (three are expected with proper names). There are the correct > >>>number of records but all the rows are blank. > >>> > >>>If however I run the code to fill in the table first. Then when that has > >>>stopped run the code for retrieving the records I get a grid showing the > >>>correct column names and data. > >>> > >>>My next attempt was to have a second sproc that executes the first one > >>>(without the final select statement), then runs the select statement. > >>>This > >>>had the same effect as if it was one sproc. > >>> > >>>Does anyone have an idea why this is happening? The code is below. > >>> > >>>Regards > >>> > >>>David Emerson > >>>Dalyn Software Ltd > >>>25 Cunliffe St, Churton Park > >>>Wellington, New Zealand > >>>Ph/Fax (877) 456-1205 > >>> > >>> > >>>ALTER PROCEDURE spSalesTransactLoadSummary > >>> ( > >>> @dtmDate1 varchar(20), > >>> @intDate2 int > >>> ) > >>>AS > >>> SET NOCOUNT ON > >>> > >>> DELETE FROM dbo.ttmpLoadAllocateRpt > >>> > >>> DECLARE @intyyyymm int, @charDate varchar(10) > >>> > >>> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= @intDate2 > >>> BEGIN > >>> SET @intyyyymm = YEAR(@dtmDate1) * 100 + > MONTH(@dtmDate1) > >>> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, > >>>@dtmDate1)) + '/' + > >>> CONVERT(nvarchar(20), DATEPART(dd, @dtmDate1)) + > >>>'/' + > >>> CONVERT(nvarchar(20),DATEPART(yy, @dtmDate1)) > >>> EXEC dbo.spLoadAllocat4 @intyyyymm > >>> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate > >>> EXEC dbo.spLoadAllocatOther @intyyyymm > >>> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) > >>> END > >>> > >>>--Note - up to here works fine. Next statement not work if run at same > >>>time as above. > >>> > >>> SELECT tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth, > >>> SUM(ttmpLoadAllocateRpt.GJ) as GJSum > >>> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN > >>>(tblGateStations INNER JOIN > >>> ttmpLoadAllocateRpt ON tblGateStations.GateID = > >>>ttmpLoadAllocateRpt.GateIDNo) > >>> ON tblCustomers.CustomerID = > >>>ttmpLoadAllocateRpt.CustomerID) ON > >>> tblNetOwners.NetOwnerID = tblGateStations.NetOwnIDNo > >>> GROUP BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth > >>> ORDER BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth > >>> > >>> If @@Error <> 0 > >>> Begin > >>> Select 'Unexpected error occurred: ', @@Error > >>> Return @@Error > >>> End > >>> else > >>> return 0 From Robert.Djabarov at usaa.com Tue Jan 20 15:42:40 2004 From: Robert.Djabarov at usaa.com (Djabarov, Robert) Date: Tue, 20 Jan 2004 15:42:40 -0600 Subject: [dba-SQLServer]Sproc not returning records Message-ID: <3CCEA32DFF043C4CB99B835557E11B3003D0444A@ex02.eagle.usaa.com> The error handling specified will not work correctly if the actual error occurs. Also, leave SET NOCOUNT ON in the main procedure and add the same statement to the procedures that are being called within the loop. Actually this behavior is typical of a connection object not accounting for the presence of action queries while being used for data retrieval. It is a trivial task for a front-end dev. Tool like VB or C#, but becomes a challenge for something like Access due to the nature of the underlying architecture of the Jet engine. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David McAfee Sent: Tuesday, January 20, 2004 2:54 PM To: 'dba-sqlserver at databaseadvisors.com' Cc: 'David Emerson' Subject: RE: [dba-SQLServer]Sproc not returning records David, did you try both my and Francisco's advise together? I believe you need the SET NOCOUNT OFF after your notes, but following your code it also looks like you end with either a choice of returning an error or a 0 (if no error). Try commenting out that whole block as such: /* If @@Error <> 0 Begin Select 'Unexpected error occurred: ', @@Error Return @@Error End else return 0 */ David -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David Emerson Sent: Tuesday, January 20, 2004 12:00 PM To: dba-sqlserver at databaseadvisors.com Subject: Re: [dba-SQLServer]Sproc not returning records Still no joy. David At 20/01/2004, Francisco wrote: >just a hunch but try remming these out... > >> else > >> return 0 >-- >-Francisco > >David Emerson wrote: > >>Thanks for the response. Tried it and made no difference. David >>At 19/01/2004, you wrote: >> >>>put >>> >>>SET NOCOUNT OFF >>> >>> before your final select (after your note) which will return the >>> data >>> to Access. >>> >>>HTH >>>David McAfee >>>-----Original Message----- >>>From: dba-sqlserver-bounces at databaseadvisors.com >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >>>Emerson >>>Sent: Monday, January 19, 2004 5:43 PM >>>To: dba-SQLServer at databaseadvisors.com >>>Subject: [dba-SQLServer]Sproc not returning records >>> >>>AXP, SQL2000 >>> >>>I have a sproc that calls a number of other sprocs to fill in a >>>table. Then it uses this table to retrieve records. If I run it (by >>>pressing the ! button in Access) then the table is filled in, but the >>>grid that shows the retrieved records has two column headings Expr<1> >>>and Expr<2> (three are expected with proper names). There are the >>>correct number of records but all the rows are blank. >>> >>>If however I run the code to fill in the table first. Then when that >>>has stopped run the code for retrieving the records I get a grid >>>showing the correct column names and data. >>> >>>My next attempt was to have a second sproc that executes the first >>>one (without the final select statement), then runs the select >>>statement. This had the same effect as if it was one sproc. >>> >>>Does anyone have an idea why this is happening? The code is below. >>> >>>Regards >>> >>>David Emerson >>>Dalyn Software Ltd >>>25 Cunliffe St, Churton Park >>>Wellington, New Zealand >>>Ph/Fax (877) 456-1205 >>> >>> >>>ALTER PROCEDURE spSalesTransactLoadSummary >>> ( >>> @dtmDate1 varchar(20), >>> @intDate2 int >>> ) >>>AS >>> SET NOCOUNT ON >>> >>> DELETE FROM dbo.ttmpLoadAllocateRpt >>> >>> DECLARE @intyyyymm int, @charDate varchar(10) >>> >>> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= @intDate2 >>> BEGIN >>> SET @intyyyymm = YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1) >>> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, >>>@dtmDate1)) + '/' + >>> CONVERT(nvarchar(20), DATEPART(dd, >>>@dtmDate1)) + '/' + >>> CONVERT(nvarchar(20),DATEPART(yy, @dtmDate1)) >>> EXEC dbo.spLoadAllocat4 @intyyyymm >>> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate >>> EXEC dbo.spLoadAllocatOther @intyyyymm >>> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) >>> END >>> >>>--Note - up to here works fine. Next statement not work if run at >>>same time as above. >>> >>> SELECT tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth, >>> SUM(ttmpLoadAllocateRpt.GJ) as GJSum >>> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN >>>(tblGateStations INNER JOIN >>> ttmpLoadAllocateRpt ON tblGateStations.GateID = >>>ttmpLoadAllocateRpt.GateIDNo) >>> ON tblCustomers.CustomerID = >>>ttmpLoadAllocateRpt.CustomerID) ON >>> tblNetOwners.NetOwnerID = tblGateStations.NetOwnIDNo >>> GROUP BY tblNetOwners.NetOwnerName, ttmpLoadAllocateRpt.YrMth >>> ORDER BY tblNetOwners.NetOwnerName, >>>ttmpLoadAllocateRpt.YrMth >>> >>> If @@Error <> 0 >>> Begin >>> Select 'Unexpected error occurred: ', @@Error >>> Return @@Error >>> End >>> else >>> return 0 _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Tue Jan 20 16:03:19 2004 From: davide at dalyn.co.nz (David Emerson) Date: Wed, 21 Jan 2004 11:03:19 +1300 Subject: [dba-SQLServer]Sproc not returning records In-Reply-To: <3CCEA32DFF043C4CB99B835557E11B3003D0444A@ex02.eagle.usaa.c om> Message-ID: <5.2.0.9.0.20040121110110.00ba9090@mail.dalyn.co.nz> I have checked all the related sprocs and all have SET NOCOUNT ON. Any other suggestions? David At 20/01/2004, you wrote: >The error handling specified will not work correctly if the actual error >occurs. Also, leave SET NOCOUNT ON in the main procedure and add the >same statement to the procedures that are being called within the loop. >Actually this behavior is typical of a connection object not accounting >for the presence of action queries while being used for data retrieval. >It is a trivial task for a front-end dev. Tool like VB or C#, but >becomes a challenge for something like Access due to the nature of the >underlying architecture of the Jet engine. > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >McAfee >Sent: Tuesday, January 20, 2004 2:54 PM >To: 'dba-sqlserver at databaseadvisors.com' >Cc: 'David Emerson' >Subject: RE: [dba-SQLServer]Sproc not returning records > > >David, did you try both my and Francisco's advise together? >I believe you need the SET NOCOUNT OFF after your notes, >but following your code it also looks like you end with either >a choice of returning an error or a 0 (if no error). > >Try commenting out that whole block as such: > >/* >If @@Error <> 0 > Begin > Select 'Unexpected error occurred: ', @@Error > Return @@Error > End >else > return 0 >*/ > > >David >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >Emerson >Sent: Tuesday, January 20, 2004 12:00 PM >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer]Sproc not returning records > > >Still no joy. > >David > >At 20/01/2004, Francisco wrote: > >just a hunch but try remming these out... > > >> else > > >> return 0 > >-- > >-Francisco > > > >David Emerson wrote: > > > >>Thanks for the response. Tried it and made no difference. David > >>At 19/01/2004, you wrote: > >> > >>>put > >>> > >>>SET NOCOUNT OFF > >>> > >>> before your final select (after your note) which will return the > >>> data > >>> to Access. > >>> > >>>HTH > >>>David McAfee > >>>-----Original Message----- > >>>From: dba-sqlserver-bounces at databaseadvisors.com > >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David > > >>>Emerson > >>>Sent: Monday, January 19, 2004 5:43 PM > >>>To: dba-SQLServer at databaseadvisors.com > >>>Subject: [dba-SQLServer]Sproc not returning records > >>> > >>>AXP, SQL2000 > >>> > >>>I have a sproc that calls a number of other sprocs to fill in a > >>>table. Then it uses this table to retrieve records. If I run it (by > > >>>pressing the ! button in Access) then the table is filled in, but the > > >>>grid that shows the retrieved records has two column headings Expr<1> > > >>>and Expr<2> (three are expected with proper names). There are the > >>>correct number of records but all the rows are blank. > >>> > >>>If however I run the code to fill in the table first. Then when that > > >>>has stopped run the code for retrieving the records I get a grid > >>>showing the correct column names and data. > >>> > >>>My next attempt was to have a second sproc that executes the first > >>>one (without the final select statement), then runs the select > >>>statement. This had the same effect as if it was one sproc. > >>> > >>>Does anyone have an idea why this is happening? The code is below. > >>> > >>>Regards > >>> > >>>David Emerson > >>>Dalyn Software Ltd > >>>25 Cunliffe St, Churton Park > >>>Wellington, New Zealand > >>>Ph/Fax (877) 456-1205 > >>> > >>> > >>>ALTER PROCEDURE spSalesTransactLoadSummary > >>> ( > >>> @dtmDate1 varchar(20), > >>> @intDate2 int > >>> ) > >>>AS > >>> SET NOCOUNT ON > >>> > >>> DELETE FROM dbo.ttmpLoadAllocateRpt > >>> > >>> DECLARE @intyyyymm int, @charDate varchar(10) > >>> > >>> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= >@intDate2 > >>> BEGIN > >>> SET @intyyyymm = YEAR(@dtmDate1) * 100 + >MONTH(@dtmDate1) > >>> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, > >>>@dtmDate1)) + '/' + > >>> CONVERT(nvarchar(20), DATEPART(dd, > >>>@dtmDate1)) + '/' + > >>> CONVERT(nvarchar(20),DATEPART(yy, >@dtmDate1)) > >>> EXEC dbo.spLoadAllocat4 @intyyyymm > >>> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate > >>> EXEC dbo.spLoadAllocatOther @intyyyymm > >>> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) > >>> END > >>> > >>>--Note - up to here works fine. Next statement not work if run at > >>>same time as above. > >>> > >>> SELECT tblNetOwners.NetOwnerName, >ttmpLoadAllocateRpt.YrMth, > >>> SUM(ttmpLoadAllocateRpt.GJ) as GJSum > >>> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN > >>>(tblGateStations INNER JOIN > >>> ttmpLoadAllocateRpt ON tblGateStations.GateID = > >>>ttmpLoadAllocateRpt.GateIDNo) > >>> ON tblCustomers.CustomerID = > >>>ttmpLoadAllocateRpt.CustomerID) ON > >>> tblNetOwners.NetOwnerID = >tblGateStations.NetOwnIDNo > >>> GROUP BY tblNetOwners.NetOwnerName, >ttmpLoadAllocateRpt.YrMth > >>> ORDER BY tblNetOwners.NetOwnerName, > >>>ttmpLoadAllocateRpt.YrMth > >>> > >>> If @@Error <> 0 > >>> Begin > >>> Select 'Unexpected error occurred: ', >@@Error > >>> Return @@Error > >>> End > >>> else > >>> return 0 From davide at dalyn.co.nz Tue Jan 20 16:05:57 2004 From: davide at dalyn.co.nz (David Emerson) Date: Wed, 21 Jan 2004 11:05:57 +1300 Subject: [dba-SQLServer]Error Handler (was Sproc not returning records) In-Reply-To: <3CCEA32DFF043C4CB99B835557E11B3003D0444A@ex02.eagle.usaa.c om> Message-ID: <5.2.0.9.0.20040121110322.00bdfd80@mail.dalyn.co.nz> This was a handler I was given by someone else. What is wrong with it and how should it be fixed? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (877) 456-1205 At 20/01/2004, Robert Djabarov wrote: >The error handling specified will not work correctly if the actual error >occurs. > >/* >If @@Error <> 0 > Begin > Select 'Unexpected error occurred: ', @@Error > Return @@Error > End >else > return 0 >*/ From Robert.Djabarov at usaa.com Tue Jan 20 16:15:01 2004 From: Robert.Djabarov at usaa.com (Djabarov, Robert) Date: Tue, 20 Jan 2004 16:15:01 -0600 Subject: [dba-SQLServer]Error Handler (was Sproc not returning records) Message-ID: <3CCEA32DFF043C4CB99B835557E11B3003D04459@ex02.eagle.usaa.com> Declare @error int, @cmd varchar(8000) ... Set @error = @@error If @error != 0 begin set @cmd = 'Unexpected error occurred: ' + cast(@error as varchar(25)) raiserror (@cmd, 15, 1) return @error End Return (0) -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Tuesday, January 20, 2004 4:06 PM To: dba-SQLServer at databaseadvisors.com Subject: [dba-SQLServer]Error Handler (was Sproc not returning records) This was a handler I was given by someone else. What is wrong with it and how should it be fixed? Regards David Emerson Dalyn Software Ltd 25 Cunliffe St, Churton Park Wellington, New Zealand Ph/Fax (877) 456-1205 At 20/01/2004, Robert Djabarov wrote: >The error handling specified will not work correctly if the actual >error occurs. > >/* >If @@Error <> 0 > Begin > Select 'Unexpected error occurred: ', @@Error > Return @@Error > End >else > return 0 >*/ _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From davide at dalyn.co.nz Tue Jan 20 16:54:26 2004 From: davide at dalyn.co.nz (David Emerson) Date: Wed, 21 Jan 2004 11:54:26 +1300 Subject: [dba-SQLServer]Error Handler (was Sproc not returning records) In-Reply-To: <3CCEA32DFF043C4CB99B835557E11B3003D04459@ex02.eagle.usaa.c om> Message-ID: <5.2.0.9.0.20040121115201.00bc3d28@mail.dalyn.co.nz> Thanks Robert. It seems that if there was an error then both the error and 0 would be returned. Is this correct? Or should there be an Else in there before Return (0)? David At 20/01/2004, you wrote: >Declare @error int, @cmd varchar(8000) >... >Set @error = @@error >If @error != 0 begin > set @cmd = 'Unexpected error occurred: ' + cast(@error as >varchar(25)) > raiserror (@cmd, 15, 1) > return @error >End >Return (0) > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >Emerson >Sent: Tuesday, January 20, 2004 4:06 PM >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer]Error Handler (was Sproc not returning records) > > >This was a handler I was given by someone else. What is wrong with it >and >how should it be fixed? > >Regards > >David Emerson >Dalyn Software Ltd >25 Cunliffe St, Churton Park >Wellington, New Zealand >Ph/Fax (877) 456-1205 > >At 20/01/2004, Robert Djabarov wrote: > >The error handling specified will not work correctly if the actual > >error occurs. > > > >/* > >If @@Error <> 0 > > Begin > > Select 'Unexpected error occurred: ', @@Error > > Return @@Error > > End > >else > > return 0 > >*/ > >_______________________________________________ >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 Robert.Djabarov at usaa.com Tue Jan 20 17:12:17 2004 From: Robert.Djabarov at usaa.com (Djabarov, Robert) Date: Tue, 20 Jan 2004 17:12:17 -0600 Subject: [dba-SQLServer]Error Handler (was Sproc not returning records) Message-ID: <3CCEA32DFF043C4CB99B835557E11B3003D04479@ex02.eagle.usaa.com> The presence of RETURN @ERROR will terminate the execution of the procedure before it reaches RETURN (0), hence - if RETURN (0) was reached - no error was encountered. -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David Emerson Sent: Tuesday, January 20, 2004 4:54 PM To: dba-sqlserver at databaseadvisors.com Subject: RE: [dba-SQLServer]Error Handler (was Sproc not returning records) Thanks Robert. It seems that if there was an error then both the error and 0 would be returned. Is this correct? Or should there be an Else in there before Return (0)? David At 20/01/2004, you wrote: >Declare @error int, @cmd varchar(8000) >... >Set @error = @@error >If @error != 0 begin > set @cmd = 'Unexpected error occurred: ' + cast(@error as >varchar(25)) > raiserror (@cmd, 15, 1) > return @error >End >Return (0) > >-----Original Message----- >From: dba-sqlserver-bounces at databaseadvisors.com >[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >Emerson >Sent: Tuesday, January 20, 2004 4:06 PM >To: dba-SQLServer at databaseadvisors.com >Subject: [dba-SQLServer]Error Handler (was Sproc not returning records) > > >This was a handler I was given by someone else. What is wrong with it >and how should it be fixed? > >Regards > >David Emerson >Dalyn Software Ltd >25 Cunliffe St, Churton Park >Wellington, New Zealand >Ph/Fax (877) 456-1205 > >At 20/01/2004, Robert Djabarov wrote: > >The error handling specified will not work correctly if the actual > >error occurs. > > > >/* > >If @@Error <> 0 > > Begin > > Select 'Unexpected error occurred: ', @@Error > > Return @@Error > > End > >else > > return 0 > >*/ > >_______________________________________________ >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 davide at dalyn.co.nz Wed Jan 28 16:31:48 2004 From: davide at dalyn.co.nz (David Emerson) Date: Thu, 29 Jan 2004 11:31:48 +1300 Subject: [dba-SQLServer]Sproc not returning records In-Reply-To: <5.2.0.9.0.20040121110110.00ba9090@mail.dalyn.co.nz> References: <3CCEA32DFF043C4CB99B835557E11B3003D0444A@ex02.eagle.usaa.c om> Message-ID: <5.2.0.9.0.20040129112927.00bcbdf0@mail.dalyn.co.nz> Finally solved problem by splitting up the sproc into two separate ones - the first executing the other sprocs, the second selecting the records from the table. Thanks for all the suggestions. David At 21/01/2004, you wrote: >I have checked all the related sprocs and all have SET NOCOUNT ON. Any >other suggestions? > >David > >At 20/01/2004, you wrote: >>The error handling specified will not work correctly if the actual error >>occurs. Also, leave SET NOCOUNT ON in the main procedure and add the >>same statement to the procedures that are being called within the loop. >>Actually this behavior is typical of a connection object not accounting >>for the presence of action queries while being used for data retrieval. >>It is a trivial task for a front-end dev. Tool like VB or C#, but >>becomes a challenge for something like Access due to the nature of the >>underlying architecture of the Jet engine. >> >>-----Original Message----- >>From: dba-sqlserver-bounces at databaseadvisors.com >>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>McAfee >>Sent: Tuesday, January 20, 2004 2:54 PM >>To: 'dba-sqlserver at databaseadvisors.com' >>Cc: 'David Emerson' >>Subject: RE: [dba-SQLServer]Sproc not returning records >> >> >>David, did you try both my and Francisco's advise together? >>I believe you need the SET NOCOUNT OFF after your notes, >>but following your code it also looks like you end with either >>a choice of returning an error or a 0 (if no error). >> >>Try commenting out that whole block as such: >> >>/* >>If @@Error <> 0 >> Begin >> Select 'Unexpected error occurred: ', @@Error >> Return @@Error >> End >>else >> return 0 >>*/ >> >> >>David >>-----Original Message----- >>From: dba-sqlserver-bounces at databaseadvisors.com >>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >>Emerson >>Sent: Tuesday, January 20, 2004 12:00 PM >>To: dba-sqlserver at databaseadvisors.com >>Subject: Re: [dba-SQLServer]Sproc not returning records >> >> >>Still no joy. >> >>David >> >>At 20/01/2004, Francisco wrote: >> >just a hunch but try remming these out... >> > >> else >> > >> return 0 >> >-- >> >-Francisco >> > >> >David Emerson wrote: >> > >> >>Thanks for the response. Tried it and made no difference. David >> >>At 19/01/2004, you wrote: >> >> >> >>>put >> >>> >> >>>SET NOCOUNT OFF >> >>> >> >>> before your final select (after your note) which will return the >> >>> data >> >>> to Access. >> >>> >> >>>HTH >> >>>David McAfee >> >>>-----Original Message----- >> >>>From: dba-sqlserver-bounces at databaseadvisors.com >> >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >> >> >>>Emerson >> >>>Sent: Monday, January 19, 2004 5:43 PM >> >>>To: dba-SQLServer at databaseadvisors.com >> >>>Subject: [dba-SQLServer]Sproc not returning records >> >>> >> >>>AXP, SQL2000 >> >>> >> >>>I have a sproc that calls a number of other sprocs to fill in a >> >>>table. Then it uses this table to retrieve records. If I run it (by >> >> >>>pressing the ! button in Access) then the table is filled in, but the >> >> >>>grid that shows the retrieved records has two column headings Expr<1> >> >> >>>and Expr<2> (three are expected with proper names). There are the >> >>>correct number of records but all the rows are blank. >> >>> >> >>>If however I run the code to fill in the table first. Then when that >> >> >>>has stopped run the code for retrieving the records I get a grid >> >>>showing the correct column names and data. >> >>> >> >>>My next attempt was to have a second sproc that executes the first >> >>>one (without the final select statement), then runs the select >> >>>statement. This had the same effect as if it was one sproc. >> >>> >> >>>Does anyone have an idea why this is happening? The code is below. >> >>> >> >>>Regards >> >>> >> >>>David Emerson >> >>>Dalyn Software Ltd >> >>>25 Cunliffe St, Churton Park >> >>>Wellington, New Zealand >> >>>Ph/Fax (877) 456-1205 >> >>> >> >>> >> >>>ALTER PROCEDURE spSalesTransactLoadSummary >> >>> ( >> >>> @dtmDate1 varchar(20), >> >>> @intDate2 int >> >>> ) >> >>>AS >> >>> SET NOCOUNT ON >> >>> >> >>> DELETE FROM dbo.ttmpLoadAllocateRpt >> >>> >> >>> DECLARE @intyyyymm int, @charDate varchar(10) >> >>> >> >>> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= >>@intDate2 >> >>> BEGIN >> >>> SET @intyyyymm = YEAR(@dtmDate1) * 100 + >>MONTH(@dtmDate1) >> >>> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, >> >>>@dtmDate1)) + '/' + >> >>> CONVERT(nvarchar(20), DATEPART(dd, >> >>>@dtmDate1)) + '/' + >> >>> CONVERT(nvarchar(20),DATEPART(yy, >>@dtmDate1)) >> >>> EXEC dbo.spLoadAllocat4 @intyyyymm >> >>> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate >> >>> EXEC dbo.spLoadAllocatOther @intyyyymm >> >>> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) >> >>> END >> >>> >> >>>--Note - up to here works fine. Next statement not work if run at >> >>>same time as above. >> >>> >> >>> SELECT tblNetOwners.NetOwnerName, >>ttmpLoadAllocateRpt.YrMth, >> >>> SUM(ttmpLoadAllocateRpt.GJ) as GJSum >> >>> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN >> >>>(tblGateStations INNER JOIN >> >>> ttmpLoadAllocateRpt ON tblGateStations.GateID = >> >>>ttmpLoadAllocateRpt.GateIDNo) >> >>> ON tblCustomers.CustomerID = >> >>>ttmpLoadAllocateRpt.CustomerID) ON >> >>> tblNetOwners.NetOwnerID = >>tblGateStations.NetOwnIDNo >> >>> GROUP BY tblNetOwners.NetOwnerName, >>ttmpLoadAllocateRpt.YrMth >> >>> ORDER BY tblNetOwners.NetOwnerName, >> >>>ttmpLoadAllocateRpt.YrMth >> >>> >> >>> If @@Error <> 0 >> >>> Begin >> >>> Select 'Unexpected error occurred: ', >>@@Error >> >>> Return @@Error >> >>> End >> >>> else >> >>> return 0 From my.lists at verizon.net Wed Jan 28 16:59:51 2004 From: my.lists at verizon.net (Francisco H Tapia) Date: Wed, 28 Jan 2004 14:59:51 -0800 Subject: [dba-SQLServer]Sproc not returning records In-Reply-To: <5.2.0.9.0.20040129112927.00bcbdf0@mail.dalyn.co.nz> References: <3CCEA32DFF043C4CB99B835557E11B3003D0444A@ex02.eagle.usaa.c om> <5.2.0.9.0.20040129112927.00bcbdf0@mail.dalyn.co.nz> Message-ID: <40183EE7.1050106@verizon.net> glad you got it going... did you stick the sprocs into a 3rd sproc, or just calling each individually now? David Emerson wrote: > Finally solved problem by splitting up the sproc into two separate > ones - the first executing the other sprocs, the second selecting the > records from the table. > > Thanks for all the suggestions. > > David > > At 21/01/2004, you wrote: > >> I have checked all the related sprocs and all have SET NOCOUNT ON. >> Any other suggestions? >> >> David >> >> At 20/01/2004, you wrote: >> >>> The error handling specified will not work correctly if the actual >>> error >>> occurs. Also, leave SET NOCOUNT ON in the main procedure and add the >>> same statement to the procedures that are being called within the loop. >>> Actually this behavior is typical of a connection object not accounting >>> for the presence of action queries while being used for data retrieval. >>> It is a trivial task for a front-end dev. Tool like VB or C#, but >>> becomes a challenge for something like Access due to the nature of the >>> underlying architecture of the Jet engine. >>> >>> -----Original Message----- >>> From: dba-sqlserver-bounces at databaseadvisors.com >>> [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>> McAfee >>> Sent: Tuesday, January 20, 2004 2:54 PM >>> To: 'dba-sqlserver at databaseadvisors.com' >>> Cc: 'David Emerson' >>> Subject: RE: [dba-SQLServer]Sproc not returning records >>> >>> >>> David, did you try both my and Francisco's advise together? >>> I believe you need the SET NOCOUNT OFF after your notes, >>> but following your code it also looks like you end with either >>> a choice of returning an error or a 0 (if no error). >>> >>> Try commenting out that whole block as such: >>> >>> /* >>> If @@Error <> 0 >>> Begin >>> Select 'Unexpected error occurred: ', @@Error >>> Return @@Error >>> End >>> else >>> return 0 >>> */ >>> >>> >>> David >>> -----Original Message----- >>> From: dba-sqlserver-bounces at databaseadvisors.com >>> [mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >>> Emerson >>> Sent: Tuesday, January 20, 2004 12:00 PM >>> To: dba-sqlserver at databaseadvisors.com >>> Subject: Re: [dba-SQLServer]Sproc not returning records >>> >>> >>> Still no joy. >>> >>> David >>> >>> At 20/01/2004, Francisco wrote: >>> >just a hunch but try remming these out... >>> > >> else >>> > >> return 0 >>> >-- >>> >-Francisco >>> > >>> >David Emerson wrote: >>> > >>> >>Thanks for the response. Tried it and made no difference. David >>> >>At 19/01/2004, you wrote: >>> >> >>> >>>put >>> >>> >>> >>>SET NOCOUNT OFF >>> >>> >>> >>> before your final select (after your note) which will return the >>> >>> data >>> >>> to Access. >>> >>> >>> >>>HTH >>> >>>David McAfee >>> >>>-----Original Message----- >>> >>>From: dba-sqlserver-bounces at databaseadvisors.com >>> >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of >>> David >>> >>> >>>Emerson >>> >>>Sent: Monday, January 19, 2004 5:43 PM >>> >>>To: dba-SQLServer at databaseadvisors.com >>> >>>Subject: [dba-SQLServer]Sproc not returning records >>> >>> >>> >>>AXP, SQL2000 >>> >>> >>> >>>I have a sproc that calls a number of other sprocs to fill in a >>> >>>table. Then it uses this table to retrieve records. If I run it >>> (by >>> >>> >>>pressing the ! button in Access) then the table is filled in, but >>> the >>> >>> >>>grid that shows the retrieved records has two column headings >>> Expr<1> >>> >>> >>>and Expr<2> (three are expected with proper names). There are the >>> >>>correct number of records but all the rows are blank. >>> >>> >>> >>>If however I run the code to fill in the table first. Then when >>> that >>> >>> >>>has stopped run the code for retrieving the records I get a grid >>> >>>showing the correct column names and data. >>> >>> >>> >>>My next attempt was to have a second sproc that executes the first >>> >>>one (without the final select statement), then runs the select >>> >>>statement. This had the same effect as if it was one sproc. >>> >>> >>> >>>Does anyone have an idea why this is happening? The code is below. >>> >>> >>> >>>Regards >>> >>> >>> >>>David Emerson >>> >>>Dalyn Software Ltd >>> >>>25 Cunliffe St, Churton Park >>> >>>Wellington, New Zealand >>> >>>Ph/Fax (877) 456-1205 >>> >>> >>> >>> >>> >>>ALTER PROCEDURE spSalesTransactLoadSummary >>> >>> ( >>> >>> @dtmDate1 varchar(20), >>> >>> @intDate2 int >>> >>> ) >>> >>>AS >>> >>> SET NOCOUNT ON >>> >>> >>> >>> DELETE FROM dbo.ttmpLoadAllocateRpt >>> >>> >>> >>> DECLARE @intyyyymm int, @charDate varchar(10) >>> >>> >>> >>> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= >>> @intDate2 >>> >>> BEGIN >>> >>> SET @intyyyymm = YEAR(@dtmDate1) * 100 + >>> MONTH(@dtmDate1) >>> >>> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, >>> >>>@dtmDate1)) + '/' + >>> >>> CONVERT(nvarchar(20), DATEPART(dd, >>> >>>@dtmDate1)) + '/' + >>> >>> CONVERT(nvarchar(20),DATEPART(yy, >>> @dtmDate1)) >>> >>> EXEC dbo.spLoadAllocat4 @intyyyymm >>> >>> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate >>> >>> EXEC dbo.spLoadAllocatOther @intyyyymm >>> >>> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) >>> >>> END >>> >>> >>> >>>--Note - up to here works fine. Next statement not work if run at >>> >>>same time as above. >>> >>> >>> >>> SELECT tblNetOwners.NetOwnerName, >>> ttmpLoadAllocateRpt.YrMth, >>> >>> SUM(ttmpLoadAllocateRpt.GJ) as GJSum >>> >>> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN >>> >>>(tblGateStations INNER JOIN >>> >>> ttmpLoadAllocateRpt ON tblGateStations.GateID = >>> >>>ttmpLoadAllocateRpt.GateIDNo) >>> >>> ON tblCustomers.CustomerID = >>> >>>ttmpLoadAllocateRpt.CustomerID) ON >>> >>> tblNetOwners.NetOwnerID = >>> tblGateStations.NetOwnIDNo >>> >>> GROUP BY tblNetOwners.NetOwnerName, >>> ttmpLoadAllocateRpt.YrMth >>> >>> ORDER BY tblNetOwners.NetOwnerName, >>> >>>ttmpLoadAllocateRpt.YrMth >>> >>> >>> >>> If @@Error <> 0 >>> >>> Begin >>> >>> Select 'Unexpected error occurred: ', >>> @@Error >>> >>> Return @@Error >>> >>> End >>> >>> else >>> >>> return 0 >> > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > -- -Francisco From davide at dalyn.co.nz Wed Jan 28 17:09:23 2004 From: davide at dalyn.co.nz (David Emerson) Date: Thu, 29 Jan 2004 12:09:23 +1300 Subject: [dba-SQLServer]Sproc not returning records In-Reply-To: <40183EE7.1050106@verizon.net> References: <5.2.0.9.0.20040129112927.00bcbdf0@mail.dalyn.co.nz> <5.2.0.9.0.20040129112927.00bcbdf0@mail.dalyn.co.nz> Message-ID: <5.2.0.9.0.20040129120800.00bcbb30@mail.dalyn.co.nz> I call each one individually from within my vba code. David At 28/01/2004, Francisco wrote: >glad you got it going... did you stick the sprocs into a 3rd sproc, or >just calling each individually now? > >David Emerson wrote: > >>Finally solved problem by splitting up the sproc into two separate ones - >>the first executing the other sprocs, the second selecting the records >>from the table. >> >>Thanks for all the suggestions. >> >>David >> >>At 21/01/2004, you wrote: >> >>>I have checked all the related sprocs and all have SET NOCOUNT ON. >>>Any other suggestions? >>> >>>David >>> >>>At 20/01/2004, you wrote: >>> >>>>The error handling specified will not work correctly if the actual error >>>>occurs. Also, leave SET NOCOUNT ON in the main procedure and add the >>>>same statement to the procedures that are being called within the loop. >>>>Actually this behavior is typical of a connection object not accounting >>>>for the presence of action queries while being used for data retrieval. >>>>It is a trivial task for a front-end dev. Tool like VB or C#, but >>>>becomes a challenge for something like Access due to the nature of the >>>>underlying architecture of the Jet engine. >>>> >>>>-----Original Message----- >>>>From: dba-sqlserver-bounces at databaseadvisors.com >>>>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of David >>>>McAfee >>>>Sent: Tuesday, January 20, 2004 2:54 PM >>>>To: 'dba-sqlserver at databaseadvisors.com' >>>>Cc: 'David Emerson' >>>>Subject: RE: [dba-SQLServer]Sproc not returning records >>>> >>>> >>>>David, did you try both my and Francisco's advise together? >>>>I believe you need the SET NOCOUNT OFF after your notes, >>>>but following your code it also looks like you end with either >>>>a choice of returning an error or a 0 (if no error). >>>> >>>>Try commenting out that whole block as such: >>>> >>>>/* >>>>If @@Error <> 0 >>>> Begin >>>> Select 'Unexpected error occurred: ', @@Error >>>> Return @@Error >>>> End >>>>else >>>> return 0 >>>>*/ >>>> >>>> >>>>David >>>>-----Original Message----- >>>>From: dba-sqlserver-bounces at databaseadvisors.com >>>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >>>>Emerson >>>>Sent: Tuesday, January 20, 2004 12:00 PM >>>>To: dba-sqlserver at databaseadvisors.com >>>>Subject: Re: [dba-SQLServer]Sproc not returning records >>>> >>>> >>>>Still no joy. >>>> >>>>David >>>> >>>>At 20/01/2004, Francisco wrote: >>>> >just a hunch but try remming these out... >>>> > >> else >>>> > >> return 0 >>>> >-- >>>> >-Francisco >>>> > >>>> >David Emerson wrote: >>>> > >>>> >>Thanks for the response. Tried it and made no difference. David >>>> >>At 19/01/2004, you wrote: >>>> >> >>>> >>>put >>>> >>> >>>> >>>SET NOCOUNT OFF >>>> >>> >>>> >>> before your final select (after your note) which will return the >>>> >>> data >>>> >>> to Access. >>>> >>> >>>> >>>HTH >>>> >>>David McAfee >>>> >>>-----Original Message----- >>>> >>>From: dba-sqlserver-bounces at databaseadvisors.com >>>> >>>[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of David >>>> >>>> >>>Emerson >>>> >>>Sent: Monday, January 19, 2004 5:43 PM >>>> >>>To: dba-SQLServer at databaseadvisors.com >>>> >>>Subject: [dba-SQLServer]Sproc not returning records >>>> >>> >>>> >>>AXP, SQL2000 >>>> >>> >>>> >>>I have a sproc that calls a number of other sprocs to fill in a >>>> >>>table. Then it uses this table to retrieve records. If I run it (by >>>> >>>> >>>pressing the ! button in Access) then the table is filled in, but the >>>> >>>> >>>grid that shows the retrieved records has two column headings Expr<1> >>>> >>>> >>>and Expr<2> (three are expected with proper names). There are the >>>> >>>correct number of records but all the rows are blank. >>>> >>> >>>> >>>If however I run the code to fill in the table first. Then when that >>>> >>>> >>>has stopped run the code for retrieving the records I get a grid >>>> >>>showing the correct column names and data. >>>> >>> >>>> >>>My next attempt was to have a second sproc that executes the first >>>> >>>one (without the final select statement), then runs the select >>>> >>>statement. This had the same effect as if it was one sproc. >>>> >>> >>>> >>>Does anyone have an idea why this is happening? The code is below. >>>> >>> >>>> >>>Regards >>>> >>> >>>> >>>David Emerson >>>> >>>Dalyn Software Ltd >>>> >>>25 Cunliffe St, Churton Park >>>> >>>Wellington, New Zealand >>>> >>>Ph/Fax (877) 456-1205 >>>> >>> >>>> >>> >>>> >>>ALTER PROCEDURE spSalesTransactLoadSummary >>>> >>> ( >>>> >>> @dtmDate1 varchar(20), >>>> >>> @intDate2 int >>>> >>> ) >>>> >>>AS >>>> >>> SET NOCOUNT ON >>>> >>> >>>> >>> DELETE FROM dbo.ttmpLoadAllocateRpt >>>> >>> >>>> >>> DECLARE @intyyyymm int, @charDate varchar(10) >>>> >>> >>>> >>> WHILE (YEAR(@dtmDate1) * 100 + MONTH(@dtmDate1)) <= >>>>@intDate2 >>>> >>> BEGIN >>>> >>> SET @intyyyymm = YEAR(@dtmDate1) * 100 + >>>>MONTH(@dtmDate1) >>>> >>> SET @charDate = CONVERT(nvarchar(20), DATEPART(mm, >>>> >>>@dtmDate1)) + '/' + >>>> >>> CONVERT(nvarchar(20), DATEPART(dd, >>>> >>>@dtmDate1)) + '/' + >>>> >>> CONVERT(nvarchar(20),DATEPART(yy, >>>>@dtmDate1)) >>>> >>> EXEC dbo.spLoadAllocat4 @intyyyymm >>>> >>> EXEC dbo.spLoadAllocat6 @intyyyymm, @charDate >>>> >>> EXEC dbo.spLoadAllocatOther @intyyyymm >>>> >>> SET @dtmDate1 = DATEADD(Month, 1, @dtmDate1) >>>> >>> END >>>> >>> >>>> >>>--Note - up to here works fine. Next statement not work if run at >>>> >>>same time as above. >>>> >>> >>>> >>> SELECT tblNetOwners.NetOwnerName, >>>>ttmpLoadAllocateRpt.YrMth, >>>> >>> SUM(ttmpLoadAllocateRpt.GJ) as GJSum >>>> >>> FROM tblNetOwners INNER JOIN (tblCustomers INNER JOIN >>>> >>>(tblGateStations INNER JOIN >>>> >>> ttmpLoadAllocateRpt ON tblGateStations.GateID = >>>> >>>ttmpLoadAllocateRpt.GateIDNo) >>>> >>> ON tblCustomers.CustomerID = >>>> >>>ttmpLoadAllocateRpt.CustomerID) ON >>>> >>> tblNetOwners.NetOwnerID = >>>>tblGateStations.NetOwnIDNo >>>> >>> GROUP BY tblNetOwners.NetOwnerName, >>>>ttmpLoadAllocateRpt.YrMth >>>> >>> ORDER BY tblNetOwners.NetOwnerName, >>>> >>>ttmpLoadAllocateRpt.YrMth >>>> >>> >>>> >>> If @@Error <> 0 >>>> >>> Begin >>>> >>> Select 'Unexpected error occurred: ', >>>>@@Error >>>> >>> Return @@Error >>>> >>> End >>>> >>> else >>>> >>> return 0 From my.lists at verizon.net Fri Jan 30 09:55:29 2004 From: my.lists at verizon.net (Francisco H Tapia) Date: Fri, 30 Jan 2004 07:55:29 -0800 Subject: [dba-SQLServer]Temporarily Disable Default Constraint Message-ID: <401A7E71.30205@verizon.net> I had created a UDF that spits back some data, I need to alter the UDF but it's listed in more than one table as the default... How do I temporarily disable it? The error I get is: Server: Msg 3729, Level 16, State 3, Procedure udfMYFunction, Line 31 Cannot ALTER 'udfMyFunction' because it is being referenced by object 'DF_tbl_MyTable_MyColumn'. any ideas? I thought I could just do this but it doesnt work.. ALTER TABLE Tbl_MyTable NOCHECK CONSTRAINT DF_tbl_MyTable_MyColumn but that doesn't seem to help because immediately I have my other script alter Function udfMYFunction() AS ... -- -Francisco From my.lists at verizon.net Fri Jan 30 12:35:52 2004 From: my.lists at verizon.net (Francisco H Tapia) Date: Fri, 30 Jan 2004 10:35:52 -0800 Subject: [dba-SQLServer]Temporarily Disable Default Constraint In-Reply-To: <401A7E71.30205@verizon.net> References: <401A7E71.30205@verizon.net> Message-ID: <401AA408.2080607@verizon.net> I always hate to answer my own posts :( but here is a script I came up w/ to facilitate this.. it scrolls through my entire database to remove the Default constraint for a specific column. In my database I have a user stamp that auto-adds them to each record they add/edit.. no deletes, deletes are handled w/ a flag instead...To edit the udf I needed to remove the default constraints and thus was gonna be a challange to type up all the table names (too many really)... the way this script works is you add the name of your default column you are after in this case entryUSER, and then if you make the statement 1=1 (or some other true statment) it will run and drop all constraints that match the criteria, I kept the default naming convention, but if you have your own you can modify those statements to suit your needs... if you make the statment false such as 1=2 then it adds the constraints back. Thanks for taking the time to read and I hope this comes in handy for someone :) btw, this script is a variant from the db_columnHelp from sqlServerCentral.com (a great site for sql scripts) IF EXISTS (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempTables')) BEGIN DROP TABLE #tempTables END DECLARE @colname nvarchar(776), -- object name we're after @colvalue varchar(255) Set @ColName = 'entryUser' -- PRELIMINARY set nocount on declare @dbname sysname declare @table nvarchar(776) declare @tableid int -- INFO FOR EACH COLUMN print ' ' select Table_Name = o.name, Column_name = c.name, Table_ID = c.id into #tempTables from syscolumns c inner join sysobjects o on c.id= o.id where c.name = @colname AND o.xtype = 'U' order by o.name,c.name select * from #tempTables DECLARE tables_cursor CURSOR FOR SELECT table_name, table_id FROM #tempTables OPEN tables_cursor FETCH NEXT FROM tables_cursor INTO @table, @tableid WHILE @@FETCH_STATUS = 0 BEGIN If 1 = 2 --TO DROP Make this TRUE, to ADD make this FALSE BEGIN if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DF_' + @table + '_' + @Colname + ']')) BEGIN exec(' ALTER TABLE ' + @table + ' DROP CONSTRAINT [DF_' + @table + '_' + @Colname + ']' ) END END ELSE BEGIN if NOT exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DF_' + @table + '_' + @Colname + ']')) BEGIN exec(' ALTER TABLE ' + @table + ' ADD CONSTRAINT [DF_' + @table + '_' + @Colname + '] DEFAULT ([dbo].[udfCurrent_User]()) FOR [' + @ColName +']' ) END END FETCH NEXT FROM tables_cursor INTO @table, @tableid END CLOSE tables_cursor DEALLOCATE tables_cursor drop table #tempTables Francisco H Tapia wrote: > I had created a UDF that spits back some data, I need to alter the UDF > but it's listed in more than one table as the default... How do I > temporarily disable it? > > The error I get is: > > Server: Msg 3729, Level 16, State 3, Procedure udfMYFunction, Line 31 > Cannot ALTER 'udfMyFunction' because it is being referenced by object > 'DF_tbl_MyTable_MyColumn'. > > > any ideas? > > I thought I could just do this but it doesnt work.. > > ALTER TABLE Tbl_MyTable NOCHECK CONSTRAINT DF_tbl_MyTable_MyColumn > > but that doesn't seem to help because immediately I have my other script > > alter Function udfMYFunction() AS ... -- -Francisco From jwcolby at colbyconsulting.com Sat Jan 31 19:44:31 2004 From: jwcolby at colbyconsulting.com (John W. Colby) Date: Sat, 31 Jan 2004 20:44:31 -0500 Subject: [dba-SQLServer]SQL Server queries - appending strings Message-ID: In Access I often do things in queries like: [LastName] & ", " & [FirstName] This appears to be bad syntax in SQL Server. Is there an equivalent? John W. Colby www.ColbyConsulting.com