Stopping The Execution Of A Multi-batch Script
May 15, 2008
We have a number of customers using the same database and ASP application. We need to run a script that modifies the database to the latest version. If the script runs twice it will cause problems so we need to build in a fail safe way of stopping it running a second time.
To do this we can update a version table at the end of the script. At the start of the script we check that the version is the previous one. If it isn't then we need to abort the enitre script. The problem is that the RETURN statement will only exit the current batch and execution of the script will continue from the next GO statement.
Is there any way to stop a multi-batch script running if a certain condition is met in one batch in such a way that the remaining batches do not run?
View 10 Replies
ADVERTISEMENT
Oct 21, 1999
Hello:
We have a new sales force automation application for sales rep to log their contacts, etc. It runs on mssql 6.5, sp 4.
They log in and leave their connections on without logging off or leave their coonections idle .
We set the user connections fiarly high but we are concerned that the max amount of user connections weill be consumed and the sql serve becomes locked.
My questions are:
1) Is there any parameter in the sql server configuration that will log off idle users have a certain time and dsiconnect them?
2) A backup of the database will be made each night. If there is no parameter, would it be a good idea to stop and start the sql server every night to release the idle connections?
3) If so, how to stop sql server from the commadn and start it with a command line command and do this in a batch file as a scheduled task?
4) Is there any other way to release these idle connections each night?
Any information you can supply will be appreciated. THanks.
David Spaisman
View 1 Replies
View Related
Jul 13, 2004
Quick question...
I was under the impression that RAISERROR stopped excution in my DTS SQL Task, but it really just passes right over it.
For example:
RAISERROR('test error',19,1) WITH LOG
CREATE TABLE delete_me (data int)
Even though I rasie the error, the table still gets created. Any ideas on how I stop the task from going to the next line?
View 1 Replies
View Related
Sep 27, 2005
We have a console.php which takes in SQL queries and displays them in aresult.php webpage.Sometimes the query takes minutes to execute or crashes the PHPapplication. Is it possible to cancel a query during execution?If yes, how does one go about it.The PHP Console is used by multiple users simultaneously.The queries are executed on a Remote Database.
View 2 Replies
View Related
Jan 25, 2007
Hi,
I am programmatically creating a package and for executing the package i say "Package.Execute()".
Likewise,is there any method exposed which programatically stops the package execution?
Thanks in advance,
Suganya
View 5 Replies
View Related
Oct 17, 2007
I have a data flow task within a package. I want to be able to stop the whole package if I come across a certain condition based on data.
I've got it to the point where I can detect the condition, but all I'm able to do right now is then insert a row into a log table, and the rest of the package continues running. What I really want to do is stop the whole package in its tracks.
How can I tell the package to stop?
View 1 Replies
View Related
Mar 23, 2008
Hello,
How can I stop a report I started by using:
ReportExecutionService rs = new ReportExecutionService()
.
.
.
rs.Render(...)
I need to stop the report when a user clicks a button in my aspx page.
TIA
gad
View 1 Replies
View Related
May 17, 2007
I need to execute around 100 SQL server jobs in a batch. If I execute them in a batch will they get executed linearly or asynchronously?
------------------------
I think, therefore I am - Rene Descartes
View 1 Replies
View Related
Sep 7, 2001
Hi,
I want to know if I can execute a set of batch statements ( basically create statements) during the installation of our product. I have used Access with ADP connected to MS SQL Server 7.0 and I am trying to merge the database and table creations with the installation procedure. Please tell me how I can go ahead with this. (I have tried using the installshield and some other similar products with not of much use).
Thanks in advance,
Mangala
View 2 Replies
View Related
Feb 29, 2008
Is the order of execution guaranteed to go from top to bottom in a transaction that has multiple statements like below?
BEGIN TRAN T1;
UPDATE table1 ...;
UPDATE table2 ...;
SELECT * from table1;
UPDATE table3 ...;
COMMIT TRAN T1;
How about here?
BEGIN TRAN T1;
UPDATE table1 ...;
BEGIN TRAN M2 ;
UPDATE table2 ...;
SELECT * from table1;
COMMIT TRAN M2;
UPDATE table3 ...;
COMMIT TRAN T1;
how can i guarantee that statements will be executed from top to bottom in a transaction batch like above? I am not interested in the errors in statements. I just want whole thing to either execute fully from top to bottom or none executes
View 2 Replies
View Related
Sep 10, 2007
Hi,
I had created 2 packages... one is the parent package and contains a 50 iterations loop running a secondary package for each iteration... i had reached the following conclusion:
My package takes an average of 5 seconds from the time it ends executing one iteration and starts another... after about 30 iterations... my average time between end and start increases significantly to about 12 secs or even more...
All packages have delay validation set to false, and receive several variables from the parent package... Has for the logging, it is done to files based on a path coming from a variable in the parent package.
To execute the parent package i am using dtexecui.exe and i consider this behavior rather strange... had anyone experienced the same? Can anyone test this?
My environment is a 4 x64 processors with 8gb memory, so i guess its good enough to get 0 secs from end to start
I already consider the first 5 seconds weird...
Best Regards,
View 4 Replies
View Related
Aug 2, 2007
Batch execution is terminated because of debugger request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Batch execution is terminated because of debugger request
any solution or cause of this exception
please let me know freindz
View 8 Replies
View Related
Jan 24, 2008
Hi,
The myComplexProc stored proc does the following in sequence:
1. Call a UDF
2. Call another Stored Proc
3. Make a SELECT with 4 joins
4. Make another SELECT 4 joins + aggregate.
Question1: if myComplexProc is executed on 4-CPUs SQL2K Server, does it start and complete with a single SPID?
Question2: Is SQL2K smart enough to do some sort of parallelism behind the scene? If yes, can it spawn some extra SPIDs? How does it handle lock or sequencing? Because in the hypothetic scenario above Step N+1 re-uses the results of Step N so it has to wait for Step N to complete.
Thanks very much in advance for any help.
View 2 Replies
View Related
Sep 11, 2007
Hi,
I need to import an SQL string from MS Excel 2003 to SQL SERVER 2000.
The string I need to import is composed by 5 different several blocks and looks like:
Code Snippet
CommandLine01 = "USE mydb"
CommandLine02 = "SELECT Block ..."
CommandLine03 = "GO
ALTER TABLE Block...
GO"
CommandLine04 = "UPDATE Block..."
CommandLine05 = "SELECT Block..."
The detail of the SQL string is at:
http://forums.microsoft.com/msdn/showpost.aspx?postid=2093921&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1
I am trying to implement OJ's suggestion:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2117223&SiteID=1
to use multi - batch processing to import the string to SQL SERVER, something like:
Code Snippet
Dim SqlCnt, cmd1, cmd2, cmd3
'set the properties and open a connection
cmd1="use my_db"
cmd2="create table mytb"
cmd3="insert into mytb"
SqlCnt.execute cmd1
SqlCnt.Execute cmd2
SqlCnt.Execute cmd3
Below is the code (just partial) I have, and I need help to complete it.
Thanks in advance,
Aldo.
Code Snippet
Function TestConnection()
Dim ConnectionString As New ADODB.Connection
Dim RecordSet As New ADODB.RecordSet
ConnectionString = "Driver={SQL Server};Server=myServer;Database=myDBName;Uid=UserName;Pwd=Password"
ConnectionString.Open
CmdLine01 = " USE " & myDB
CmdLine02 = " SELECT ACCOUNTS.FULLNAME FROM ACCOUNTS" ...
CmdLine03 = "GO
ALTER TABLE Block...
GO"
CmdLine04 = "UPDATE Block..."
CmdLine05 = "SELECT Block..."
RecordSet.Open CmdLine01, ConnectionString
RecordSet.Open CmdLine02, ConnectionString
ConnectionString.Execute CmdLine01
ConnectionString.Execute CmdLine02
'Retrieve Field titles
For ColNr = 1 To RecordSet.Fields.Count
ActiveSheet.Cells(1, ColNr).Value = RecordSet.Fields(ColNr - 1).Name
Next
ActiveSheet.Cells(2, 1).CopyFromRecordset RecordSet
'Close ADO objects
RecordSet.Close
ConnectionString.Close
Set RecordSet = Nothing
Set ConnectionString = Nothing
End Function
View 7 Replies
View Related
Aug 7, 2007
HELP,
I need to take a variable from a tabel in SQL Server pass to a Batch file and execute the batch file. Right now I can exec the batch file with XP_CMDSHELL but how can I pass the variable to the batch file and loop through all the variables.
Please help
Phil
View 4 Replies
View Related
Sep 23, 2014
Disaster Recovery Options based on the following criteria.
--Currently running SQL 2012 standard edition
--We have 18000 databases (same schema across databases)- majority of databases are less than 2gb-- across 64 instances approximately
--Recovery needs to happen within 1 hour (Not sure that this is realistic
-- We are building a new data center and building dr from the ground up.
What I have looked into is:
1. Transactional Replication: Too Much Data Not viable
2. AlwaysOn Availability Groups (Need enterprise) Again too many databases and would have to upgrade all instances
3. Log Shipping is a viable option and the only one I can come up with that would work right now. Might be a management nightmare but with this many databases probably all options with be a nightmare.
View 1 Replies
View Related
Aug 17, 2015
More often than not, I typically don't touch DTC on clusters anymore; however on a project where the vendor states that it's required. So a couple things here.
1) Do you really need DTC per instance or one for all?
2) Should DTC be in its own resource group or within the instance's group?
2a) If in it's own resource group, how do you tie an instance to an outside resource group? tmMappingSet right?
View 9 Replies
View Related
Feb 4, 2008
the stored procedure don't delete all the records
need help
Code Snippet
DECLARE @empid varchar(500)
set @empid ='55329429,58830803,309128726,55696314'
DELETE FROM [Table_1]
WHERE charindex(','+CONVERT(varchar,[empid])+',',','+@empid+',') > 0
UPDATE [empList]
SET StartDate = CONVERT(DATETIME, '1900-01-01 00:00:00', 102), val_ok = 0
WHERE charindex(','+CONVERT(varchar,[empid])+',',','+@empid+',') > 0
UPDATE [empList]
SET StartDate = CONVERT(DATETIME, '1900-01-01 00:00:00', 102), val_ok = 0
WHERE charindex(','+CONVERT(varchar,[empid])+',',','+@empid+',') > 0
TNX
View 2 Replies
View Related
Aug 23, 2007
after moving off VS debugger and into management studio to exercise our SQLCLR sp, we notice that the 2nd execution gets an error suggesting that our static SqlCommand object is getting reused from the 1st execution (of the sp under mgt studio). If this is expected behavior, we have no problem limiting our statics to only completely reusable objects but would first like to know if this is expected? Is the fact that debugger doesnt show this behavior also expected?
View 4 Replies
View Related
Jul 20, 2005
Hello,I am trying to construct a query across 5 tables but primarily 3tables. Plan, Provider, ProviderLocation are the three primary tablesthe other tables are lookup tables for values the other tables.PlanID is the primary in Plan andPlanProviderProviderLocationLookups---------------------------------------------PlanIDProviderIDProviderIDLookupTypePlanNamePlanIDProviderStatusLookupKeyRegionIDLastName...LookupValue....FirstName...Given a PlanID I want all the Providers with a ProviderStatus = 0I can get the query to work just fine if there are records but what Iwant is if there are no records then I at least want one record withthe Plan information. Here is a sample of the Query:SELECT pln.PlanName, pln.PlanID, l3.LookupValue as Region,p.ProviderID, p.SSNEIN, pl.DisplayLocationOnPCP,pl.NoDisplayDate, pl.ProviderStatus, pl.InvalidDate,l1.LookupValue as ReasonMain, l2.LookupValue as ReasonSub,pl.InvalidDataFROM Plans plnINNER JOIN Lookups l3 ON l3.LookupType = 'REGN'AND pln.RegionID = l3.Lookupkeyleft outer JOIN Provider p ON pln.PlanID = p.PlanIDleft outer JOIN ProviderLocation pl ON p.ProviderID = pl.ProviderIDleft outer JOIN Lookups l1 ON l1.LookupType = 'PLRM'AND pl.ReasonMain = l1.LookupKeyleft outer JOIN Lookups l2 ON l2.LookupType = 'PLX1'AND pl.ReasonSub = l2.LookupkeyWHERE pln.PlanID = '123456789' AND pl.ProviderStatus = 0ORDER BY p.PlanID, p.ProviderID, pl.SiteLocationNumI know the problew the ProviderStatus on the Where clause is keepingany records from being returned but I'm not good enough at this toanother select.Can anybody give me some suggestions?ThanksDavid
View 5 Replies
View Related
Dec 5, 2006
I am using the following batch file to execute a script that creates a db and all its objects in the local sql express:
sqlcmd -S (local)SQLExpress -i C:CreateDB.sql
This works fine, but I'm wondering if there's an easy way to put the script in the batch file, so users don't have to worry about putting the script in the C drive. I tried getting rid of the i parameter and pasting the script from the sql file into the batch file, but it didn't work.
Thanks,
Dave
View 1 Replies
View Related
Dec 7, 2005
Hi I am slowly getting to grips with SQL Server. As a part of this, I have been attempting to work on producing more efficient queries. This post is regarding what appears to be a discrepancy between the SQL Server execution plan and the actual time taken by a query to run. My brief is to produce an attendance system for an education establishment (I presume you know I'm not an A-Level student completing a project :p ). Circa 1.5m rows per annum, testing with ~3m rows currently. College_Year could strictly be inferred from the AttDateTime however it is included as a field because it a part of just about every PK this table is ever likely to be linked to. Indexes are not fully optimised yet. Table:CREATE TABLE [dbo].[AttendanceDets] ([College_Year] [smallint] NOT NULL ,[Group_Code] [char] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,[Student_ID] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,[Session_Date] [datetime] NOT NULL ,[Start_Time] [datetime] NOT NULL ,[Att_Code] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ) ON [PRIMARY]GO CREATE CLUSTERED INDEX [IX_AltPK_Clust_AttendanceDets] ON [dbo].[AttendanceDets]([College_Year], [Group_Code], [Student_ID], [Session_Date], [Att_Code]) ON [PRIMARY]GO CREATE INDEX [All] ON [dbo].[AttendanceDets]([College_Year], [Group_Code], [Student_ID], [Session_Date], [Start_Time], [Att_Code]) ON [PRIMARY]GO CREATE INDEX [IX_AttendanceDets] ON [dbo].[AttendanceDets]([Att_Code]) ON [PRIMARY]GOALL inserts are via an overnight sproc - data comes from a third party system. Group_Code is 12 chars (no more no less), student_ID 8 chars (no more no less). I have created a simple sproc. I am using this as a benchmark against which I am testing my options. I appreciate that this sproc is an inefficient jack of all trades - it has been designed as such so I can compare its performance to more specific sprocs and possibly some dynamic SQL. Sproc:CREATE PROCEDURE [dbo].[CAMsp_Att] @College_Year AS SmallInt,@Student_ID AS VarChar(8) = '________', @Group_Code AS VarChar(12) = '____________', @Start_Date AS DateTime = '1950/01/01', @End_Date as DateTime = '2020/01/01', @Att_Code AS VarChar(1) = '_' AS IF @Start_Date = '1950/01/01'SET @Start_Date = CAST(CAST(@College_Year AS Char(4)) + '/08/31' AS DateTime) IF @End_Date = '2020/01/01'SET @End_Date = CAST(CAST(@College_Year +1 AS Char(4)) + '/07/31' AS DateTime) SELECT College_Year, Group_Code, Student_ID, Session_Date, Start_Time, Att_Code FROM dbo.AttendanceDets WHERE College_Year = @College_YearAND Group_Code LIKE @Group_CodeAND Student_ID LIKE @Student_IDAND Session_Date <= @End_DateAND Session_Date >=@Start_DateAND Att_Code LIKE @Att_CodeGOMy confusion lies with running the below script with Show Execution Plan:--SET SHOWPLAN_TEXT ON--Go DECLARE @Time as DateTime Set @Time = GetDate() select College_Year, group_code, Student_ID, Session_Date, Start_Time, Att_Code from attendanceDetswhere College_Year = 2005 AND group_code LIKE '____________' AND Student_ID LIKE '________'AND Session_Date <= '2005-11-16' AND Session_Date >= '2005-11-16' AND Att_Code LIKE '_' Print 'First query took: ' + CAST(DATEDIFF(ms, @Time, GETDATE()) AS VarCHar(5)) + ' milli-Seconds' Set @Time = GetDate() EXEC CAMsp_Att @College_Year = 2005, @Start_Date = '2005-11-16', @End_Date = '2005-11-16' Print 'Second query took: ' + CAST(DATEDIFF(ms, @Time, GETDATE()) AS VarCHar(5)) + ' milli-Seconds'GO --SET SHOWPLAN_TEXT OFF--GOThe execution plan for the first query appears miles more costly than the sproc yet it is effectively the same query with no parameters. However, my understanding is the cached plan substitutes literals for parameters anyway. In any case - the first query cost is listed as 99.52% of the batch, the sproc 0.48% (comparing the IO, cpu costs etc support this). BUT the text output is:(10639 row(s) affected) First query took: 596 milli-Seconds (10639 row(s) affected) Second query took: 2856 milli-SecondsI appreciate that logical and physical performance are not one and the same but can why is there such a huge discrepancy between the two? They are tested on a dedicated test server, and repeated running and switching the order of the queries elicits the same results. Sample data can be provided if requested but I assumed it would not shed much light. BTW - I know that additional indexes can bring the plans and execution time closer together - my question is more about the concept. If you've made it this far - many thanks.If you can enlighten me - infinite thanks.
View 10 Replies
View Related
Aug 3, 2007
Hello :
How to execute a procedure stored during execution of the report, that is before the poster the data.
Thnak you.
View 4 Replies
View Related
Oct 16, 2001
I would like to create a job that wakes up every 5 minutes or so and stops any job that has been running for, say, more than an hour.
Alternatively, when it is a jobs scheduled time to run, if the job is already running, I would like it to stop the previous execution and start over.
Thanks
View 1 Replies
View Related
Dec 3, 2002
Hi, I am unsure whether i can delete some system created tables from a database.
I was testing replication and then used the wizard to disable it all. I am however left with three tables that are replication based that have not been deleted. they are :
MSreplication_subscriptions
MSsubscriptions_agents
MSsubscriptions_properties
these tables are causing problems with some third party software due to the length of their names. I have tried to 'Exec sp_rename' but i get an error saying the objects are not valid for this operation.
Can i just delete them or will this cause problems if i want to start up replication in the future?
View 2 Replies
View Related
Mar 31, 2008
I'm trying to stop a SQL Server Agent Backup job if it is running past 7 a.m. Can you reply with your ideas.
Thanks.
Deb Dawicki
Sansum Clinic
System Administrator III
805-692-6422
View 1 Replies
View Related
Jul 23, 2005
In query analyser, I can stop a script with the "return" statement butif the script contains multiple batches (separated by GO) then thereturn statement only stops the current batch.Is there a way to stop the whole script?
View 2 Replies
View Related
Jul 20, 2005
Hi,Please look at the code at the bottom of this procedure (UPDATECOVENANT PRINT DATE). When I put it at the tope of this section, itdoes the update and fails to return the SELECT results. When I put itat the bottom, the SELECT returns results and the UPDATE fails.Can anyone suggest what might be causing my problem?Thanks/************ SPECIFIC PROGRAM SEARCH ************************/IF @PRG_ID != 0 -- PRG_ID suppliedBEGINSET @strWHERE = 'WHERE PRG.PRG_ID = ' + cast(@PRG_ID as varchar(15))EXECUTE (@strSELECT + ' ' + @strFROM + ' ' + @strWHERE + ' ' +@strORDERBY)RETURN(0)END/************ NON-SPECIFIC PROGRAM SEARCH ************************/IF @ORG_ID != 0 -- Add ORG_ID to whereIF @intAND = 0BEGINSET @strWHERE = @strWHERE + 'ORG.ORG_ID = ' + cast(@ORG_ID asvarchar(15))SET @intAND = 1ENDELSEBEGINSET @strWHERE = @strWHERE + ' AND ORG.ORG_ID = ' + cast(@ORG_ID asvarchar(15))ENDIF @PRG_Closed != 2 -- Add PRG_Closed to whereIF @intAND = 0BEGINSET @strWHERE = @strWHERE + 'PRG.PRG_Closed = ' + cast(@PRG_Closedas varchar(15))SET @intAND = 1ENDELSEBEGINSET @strWHERE = @strWHERE + ' AND PRG.PRG_Closed = ' +cast(@PRG_Closed as varchar(15))ENDIF @strWHERE != 'WHERE '-- if some parameters supplied..BEGIN-- Execute searchEXECUTE (@strSELECT + ' ' + @strFROM + ' ' + @strWHERE + ' ' +@strORDERBY)RETURN(0)END/************ UPDATE COVENANT PRINT DATE ************************/-- Added by JSHAW 02/25/2004IF @PRG_Covenant != 0 -- PRG_Covenant suppliedBEGIN--SET @ORD_Date = GETDATE()UPDATE PROGRAMSSET Covenant_Printed = convert(char(10),@ORD_Date,101)WHEREPRG_ID = cast(@PRG_ID as varchar(15))ENDGO
View 1 Replies
View Related
Mar 27, 2007
I am new to Reporting Services and hope that what I am looking to do is within capabilities :-)
I have many identical schema databases residing on a number of data servers. These support individual clients accessing them via a web interface. What I need to be able to do is run reports across all of the databases. So the layout is:
Dataserver A
Database A1
Database A2
Database A3
Dataserver B
Database B1
Database B2
Dataserver C
Database C1
Database C2
Database C3
I would like to run a report that pulls table data from A1, A2, A3, B1, B2, C1, C2, C3
Now the actual number of servers is 7 and the number of databases is close to 1000. All servers are running SQL2005.
Is this something that Reporting Services is able to handle or do I need to look at some other solution?
Thanks,
Michael
View 5 Replies
View Related
Oct 16, 2006
Hi Forum, I want to stop insert data if value already entered in Column, Im used to .mdb and am new to .mdf much thanks Paul
View 14 Replies
View Related
Dec 13, 2001
Anyone got any "gotchas" or "nightmares" they want to share out of experience where the services have been shutdown without the proper forethought?
I'm trying to put a case in for a SQL DBA to be paged and to be in charge of shutting down the services and/or put together a checklist of things to verify first.
While I realize shutting down the services is supposed to be a graceful shutdown process I'm willing to bet there are a host of considerations.
Appreciate any Input.
Regards
View 1 Replies
View Related
May 29, 2002
How do you start/stop a service within a sql script?
View 2 Replies
View Related
Oct 31, 2000
hi,
i am having sql7 with sp2.
Recently our server got bounced back. No body stopped the server, there are no work load at that time. Server suddenly stopped and started.
It is weired.
Can anyone have any clues , how it happened and why it happened.
Thanks!
__kavira
View 3 Replies
View Related