@@IDENTITY And Thread Safety
Jun 29, 2005
I am currently using @@Identity to retreive the Identity value for the PK field in a table that I am inserting data into. Essentially, my code looks like this:SqlCommand cmd=new SqlCommand("Insert into table(... ;Select @@Identity from table",conn);string identity=cmd.ExecuteScalar();Testing this myself, it works fine, but I am worried as to how thread safe this is in a real-world environment? (i.e. with multiple users clicking at it). Is there a guaranteed way to make this thread safe- wrap it in a transaction maybe?
View 4 Replies
ADVERTISEMENT
Oct 1, 2006
Hello!
I'm reading about database mirroring in High Safety Mode (Synchronous with no witness). I'm a little confused about what happens if the mirror server disappears.
From Books Online
"If the mirror server instance goes down, the principal server instance is unaffected and runs exposed (that is without mirroring the data)."
http://msdn2.microsoft.com/en-us/library/ms179344.aspx
I was to the course [Upgrading your Database Administration Skills to SQL Server 2005] and the course material does not say the same."Scenario: Synchronous mirroring without a witness server. If the mirror server becomes unavailable, the principal server will take the database offline. This action attempts to maximize the protection of the database and ensure the integrity of its contents"
I've made tests that shows that Books Online is right,
but I would like to know if this is a behaviour that has changed.
I also would like to know if it's possible to run in a more secure mode,
where exposed operations is not allowed.
Best regards
Ola Hallengren
View 1 Replies
View Related
Jan 4, 2008
Situation:
We have a backend system which stores our configuration data. In order to pull configuration information from this system our components need to have access to three pieces of data: application name, module name, and the variable to pull.
This same system allows us to log various events. It serves as a central point of configuration, maintenance and monitoring for all of our environments.
Desired Outcome:
We'd like to create a connection manager, log provider, and task "finalizer." We'd like to initialize the variables named above in one location and have all created components pull their required information from that one location.
Assumptions:
* Custom configuration managers are not possible.
* Custom connection managers and logging providers do not have access to the package variables.
* Custom tasks have access to the package variables.
Problems:
Logging Provider: The logging provider does not have access to the package level variables. The only variable that appears to be supported is ConfigString. Currently our component allows configuration of the required data using a "Variable::Variable" format in the ConfigString. We want the logging provider to pull its config data from elsewhere.
Connection Manager: The connection manager does not appear to have access to package level variables. The UI for configuring the connection manager does have access (through the IDtsVariableService). Our current component requires the designer to enter the required data into the component.
We're looking to expand our components to include further integration into our backend. We'd like to resolve the issue of components not having access to the package level variables.
Probed Solutions:
Custom Package Executable: Created as a replacement for DTExec. This fails because we have situations where we may need to run jobs via SQLAgent. Loaded the package, set all the variables and components properly, then executed.
Manual Initialization: Configure each component separately. This fails because we'd like to have a single point of maintenance for these configuration variables.
DTSTask and Static Variables: The heart of this post.
We have created a DTSTask that exists as the first item in the Control Flow and which configures the package level variables and a set of static variables. By "static variables" I refer to the following:
public static class DataStore
{
public static string ApplicationName;
public static string ModuleName;
}
Our components are all capable of accessing these static variables and everything functions wonderfully. (The variables are WORM; the above structure is not what I'm using as I'm aware that SSIS is multi threaded and all appropriate access controls should be used.)
There are concerns over the lifetime of these variables. We depend on the initial task to set these variables; a type constructor is unable to initialize them for us. Static variables are tightly tied to the lifetime of the AppDomain, so I have the following questions:
1. Are AppDomains reused by SSIS? (Is there a chance that a previously configured static variable will be used by a second package?) Research I've done indicates that the SSIS runtime exists in the context of the executing assembly so with DTExec or DTExecUI I'm confident that the AppDomain is not recycled; however, I'm unsure as to the answer in terms of jobs launched by SQLAgent.
2. Are AppDomains ever dynamically created by the SSIS runtime? I know that dynamic creation of AppDomains is explicitly forbidden by the SQL Server 2005 CLR implementation, but I'm not sure about the SSIS runtime. Research has seemed to indicate (but never explicitly state) that this is not done by the current implementation of SSIS.
3. What effect, if any, does "execute out of context" have on static variables? Research has indicated that as long as the package being executed has the appropriate task as the first item that the impact is nil.
Thank you for reading this question, and thank you in advance for any input or comments you may have.
--bms
View 6 Replies
View Related
Jun 1, 2005
Hi.. My Finance user create a microsoft Excel OLAP file that connect to our SQL server. And I have created the same ODBC setting for every PCs.
But for a few PCs, I encountered the following error "Client Safety Options do not allow pass through statement to be issued to the data source" When trying to connect the OLAP file to SQL server after entering the same SQL account.
Any idea what is the isssue ??
View 3 Replies
View Related
Jun 29, 2015
which things(I mean columns/elements) we need to consider to implement crime prediction in an efficient way.Now Using PAST DATA , we are giving prediction for, Location wise + crimes wise how many (count of Incidents) Incidents going to be occur in future.
View 3 Replies
View Related
Apr 9, 2015
We have 2 data centers, site 1 and site 2. Site 1 is generally our primary, and site 2 is our Disaster Recovery (DR) site. I want to setup a SQL instance to have extremely high availability. Therefore I was looking at using DB mirroring, with synchronous data writing, high-safety and auto-failover. This requires the usage of a witness server.My problem with this setup, is that if the witness and principal are both at site 1, if site 1 goes away (power failure, asteroid impact, lol, anything else that would be a *true* DR scenario), then there is no failover to the mirror server at site 2. However, if you put the witness at site 2, anytime the WAN link between site 1 and site 2 has an issue, the DB will auto-failover to site 2. Is the reason for the recommendation of the witness being at the primary site because the thinking is that WAN link failure is likely more common than a *true* DR scenario that takes out all of site 1?
View 3 Replies
View Related
Mar 6, 2008
Hi There
I realise this is a stupid quesiton but i cannot really find any confirmation of this in BOL.
If you are running High Safety with automatic failover, when failover occurs does this automatically change to High Performance mode. SInce for failover to occur something has happen with the primary , it will be impossible to commit transactions on the new primary and mirror asyncronously since 1 of them is no longer available.
So am i correct in assuming that automatic failover also automatically changes the mode to High Performacne for that session?
Thanx
View 4 Replies
View Related
Oct 23, 2003
Hi Everyone,
The sqlserv.exe takes too much CPU utilization on my SQL 2000 on W2K production machine. I am tring to use System Monitor to monitor the Thread/%process time with all Sqlservr instances, and then match the sqlservr instance number to the KPID in sysprocesses table to find out which user is causing the problem. but I can only see the instance number from Sqlservr0 to sqlservr99. From the table sysprocesses table, the KPID is all 3 or 4 digits number. Any one has any idea about this?
Thanks in Advance.
Jason
View 2 Replies
View Related
May 9, 2006
I have this data structure -
Code:
ProductCode - CenterId - Region
13265 - 10 - Asia
13265 - 12 - Asia
13265 - 9 - America
11110 - 10 - Asia
11110 - 9 - America
12365 - 12 - Asia
12365 - 8 - Europe
45620 - 10 - Asia
45620 - 12 - Asia
What I need this query to do is to pull one instance of a product code where the "Asia" appears more than once within the table? Thanks for the help!
View 2 Replies
View Related
Dec 2, 2004
Hey all,
Just wondering if there is any way to kill a thread within an sqlerver process. The thread we are trying to kill is a rollback statement that has been running for a very long time.
Any ideas ?
Thanks in advance,
Kilka
View 7 Replies
View Related
Sep 26, 2007
Hi.
I want to get the current value of culture that my multilanguage application used.
So, i type this line of code :
string getLanguage = "";
getLanguage = Thread.CurrentThread.CurrentUICulture.ToString().Trim();
The thing that I dont understand is, where the thread get the information from? My windows application currently set to "zh-CHS" culture but my pc that running the application is "en-US".
It seems like the thread get the information from my pc. What i want is, getLanguage get the information from the application.
Is that can be achieved? Please explain to me...
View 1 Replies
View Related
Dec 19, 2005
I receive the following errors while browsing the http://server/reports page.Please help me to resolve the issue.
Error1.
Thread was being aborted. 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.Threading.ThreadAbortException: Thread was being aborted. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [ThreadAbortException: Thread was being aborted.] System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +483 System.Web.HttpApplication.ResumeSteps(Exception error) +539 System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +144 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +300
Error2.
The report server cannot decrypt the symmetric key used to access sensitive or encrypted data in a report server database. You must either restore a backup key or delete all encrypted content. Check the documentation for more information. (rsReportServerDisabled) (rsRPCError) Get Online Help Bad Data. (Exception from HRESULT: 0x80090005)
View 15 Replies
View Related
Feb 6, 2008
Hi experts
I have a doubt!
I have identified that one of the instance is taking much more CPU than the other by using the counter process\% processor time in perfmon. So we have decided to monitor only that instance using ID Thread counter to see which process is causing this high usage within this instance.
Now problem... Thread ID is re-used by Windows. We cannot identify which counter is the one causing problem at that point of time just using the ID from a report given to me NEXT DAY because I can never dream of monitoring the server in the real time to see what is the process Thread ID NOW.
Now question.. Is there is any counter that says which process caused the spike in %CPU used at one point of time from the thread id comparing against another counter in perfmon?
I have never worked with this in detail before. If any one can give me the counters and the method to identify which process is related to which thread at that point of time from a report received NEXT DAY MORNING, thanks a lot.
another thanks in advance
Priw
View 1 Replies
View Related
Jan 30, 2007
Hello,
I have built a system, that uses a .dll file for all SQL operations. So a program looks something like this:
using myDLL;
....
SQLDBCON mSQL = new SQLDBCON();
and here comes the rest of the program.
My question is, the dll file has all stored procedures and when you declare mSQL as shown above, then it opens a thread to the database for that user.
Is that thread properly closed when the site has finished loading?
in my .aspx page i dont have a function like mSQL.CloseDB();
and if i try to add something like this to the dll file
~SQLDBCON {
m_local_con.Close();m_local_con.dispose();
}
i get a error message says something that this is not allowed.
Just want to know if my thread in the dll file is properly closed?
View 9 Replies
View Related
Apr 13, 2007
Hi all,
I am having problem with SQL connection at Godaddy where my pool connection gets MAX OUT. When it happens, I cannot access the database.This is the thread about the problem: http://forums.asp.net/thread/1665023.aspx
I just created this with "THREAD". I hope someone who has experiences with thread can give me some advice about my design. This is my first time.
static object Locked = new object();
public object ExecuteCommand(string queryStr, string type){ //*************************************************************************************// // ExecuteCommand: Returns an object // //*************************************************************************************// Thread t = null; lock(Locked) { SQLString = queryStr; switch(type) { case "ExecuteNonQuery": t = new Thread(ExecuteNonQuery); break; case "ExecuteScalar": t = new Thread(ExecuteScalar); break; case "GetDataReader": t = new Thread(GetDataReader); break; } t.Start(); t.Join(); } return null;}
First of, does this work at all? It runs, but is it a good design in term of Thread? Since I use LOCK, do I still need the t.Join() function? The switch with the three cases, is that OKAY? Basically, I'm clueless. If you read my other post, you will get an idea what I'm trying to do. Any feedback would be very very appreciated.
Thank you.
View 2 Replies
View Related
Apr 19, 2001
Any practical suggestions as to how to elminate this error as result of script executions?
Thanks,
Steve Brown
View 1 Replies
View Related
Oct 13, 2004
I'm making a "simple" ASP forum to integrate into a webpage solution. I just recently ran into a problem with sorting threads.
I have a page that displays all threads in a given forum (Threads.ThreadForumID=iForumID) this page will have all pinned threads on top of the list the threads should then be sorted according to when a message last was posted inside the thread (Posts.PostDate)
Sort order:
Threads.ThreadPinned
Posts.PostDate or Posts.LastPostDate if it has been set.
The tables are as follows:
Threads table:
ThreadIDNumber
ThreadNameText
ThreadViewCountNumber
ThreadOwnerIDNumber(Ref to thread owner id, user)
ThreadLockedBoolean
ThreadPinnedBoolean
ThreadForumIDNumber(Ref to ForumID, forum)
Posts table:
PostIDNumber
PostTextText
PostOwnerIDNumber(Ref to post owner, user)
PostLastEditByNumber(Ref to last user that edited, user)
PostThreadIDNumber(Ref to thread)
PostIPText
PostNicknameText
PostDateDate
PostLastEditDateDate
Current "sort":
This is the current SQL statement it is not in any way correct. It's just temporary. I have tried different joins but I can't seem to get it right!
SELECT ThreadID
FROM Threads
WHERE ThreadForumID=" & iForumID & "
ORDER BY ThreadPinned DESC, ThreadID DESC
Could someone please give me a hand here?
View 13 Replies
View Related
Feb 29, 2008
Hello,
I am having a problem with the SQL Server 2005 database of our ERP system. We have a scheduled batch that gets stuck because of a lock on a table. The lock remains overnight and halts all other processes (it seems most of them are waiting for this lock to get solved)
I know which table the lock is on and if I kill the lock manually, the batch continues and finishes without a problem
my question is: can I change this behaviour somewhere?
The piece of code that causes this lock is protected, but in a debug log I was able to see that it happens during following actions:
first a select is performed to fetch a certain record in the file that gets locked
next an update is performed with following syntax:
update ... set.... where current of 'pointername'
this update is waiting for a lock to be released before the batch continues.
My guess is that somehow the pointer that is set with the select statements, locks the row and that's why the update cannot be performed.
The strange part is that this lock does NOT occur everytime that this table needs to be updated. And that's why I am stuck and asking help of the real database people :)
If someone can give me a hint on a setup,property, or just a pointer to where I can find more info on the 'why'-part of the lock, I would be very grateful
database is SQL Server 2005 SP1 on win2k3
View 3 Replies
View Related
Aug 1, 2005
Its way too confusing trying to keep track of multiple reports and people in a single thread.
Thanks!
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
View 1 Replies
View Related
Aug 15, 2007
Newbie question, but is there a way for me to set up a thread in my c# code so as it sleeps until it gets woken up by an event fired by an activation SP?
As in queue sits idle, thread sleeps.
Queue receives a message, activation SP gets fired, activation SP raises an event which gets caught by event handler in code, which wakes up thread to do processing?
View 1 Replies
View Related
Oct 18, 2006
When a query is executed, the tab is split horizontally with the bottom half containing two tabs. The first with the result set(s) and the second with the messages.
How do I hide the bottom half after I have read it and now want the entire column to view my TSQL? Is there some menu item or shortcut key that I can use to accomplish this?
In 2000, there is a configuration option to make these tabs appear at the top of the window. I haven't found this setting in Express.
Another nice feature that I appreciate is to be able to divide the window into independant horizontal or vertical windows (or tabs) each with different files. I have found that I can get there with a mouse click but I could use some guidence in restoring the original layout, expecially without closing the windows.
Thanks,
IanO
View 1 Replies
View Related
Jan 24, 2008
I have been struggling with this error for a while now. Not much when I put it in the search engines. I get the error as follows when I execute this CLR stored procedure:
Msg 10312, Level 16, State 49, Procedure SpPICK00, Line 0
.NET Framework execution was aborted. The UDP/UDF/UDT did not revert thread token.
The code for the stored procedure is as follows. If anybody could offer any advice on what this error means I would appreciate it. I know through debugging that it's erroring out on the ImpContext = ClientID.Impersonate() line.
Dim DbCon As New SqlConnection("context connection=true")
Dim DbSql As New SqlCommand("SELECT TOP 1 * FROM TblTransactions", DbCon)
Dim TransactionID As Int64
DbSql.Connection.Open()
Dim DbRs As SqlDataReader
DbRs = DbSql.ExecuteReader
While DbRs.Read
TransactionID = DbRs("TransactionID")
End While
DbRs.Close()
Dim MenuID As Int16
Dim MONumber As String
Dim LineNumber As String
Dim PTUse As String
Dim SEQN As String
Dim WorkCentre As String
Dim Stock As String
Dim Bin As String
Dim Qty As Double
DbSql = New SqlCommand("SELECT * FROM VwPickList WHERE TransactionID = @TransactionID", DbCon)
DbSql.Parameters.Add("@TransactionID", SqlDbType.BigInt).Value = TransactionID
DbRs = DbSql.ExecuteReader
If DbRs.Read Then
MenuID = DbRs("MenuID")
MONumber = DbRs("MONumber")
LineNumber = DbRs("LineNumber")
PTUse = DbRs("PT_USE")
SEQN = DbRs("SEQN")
WorkCentre = DbRs("WorkCentre")
Stock = DbRs("Stock")
Bin = DbRs("Bin")
Qty = DbRs("Hours")
End If
DbRs.Close()
DbSql.Connection.Close()
DbCon.Dispose()
DbSql.Dispose()
Dim FSClient As New FSTIClient
Dim ClientID As WindowsIdentity
Dim ImpContext As WindowsImpersonationContext
ClientID = SqlContext.WindowsIdentity
ImpContext = ClientID.Impersonate
Shell("NET USE K: \FPTESTFShift", AppWinStyle.Hide)
FSClient.InitializeByConfigFile("K:Mfgsysfs.cfg", False, False)
If FSClient.IsLogonRequired Then
FSClient.Logon("VBS", "visib", "")
End If
If MenuID = 2 Then
Dim Pck As New PICK08
Pck.OrderType.Value = "M"
Pck.IssueType.Value = "I"
Pck.OrderNumber.Value = MONumber
Pck.LineNumber.Value = LineNumber
Pck.PointOfUseID.Value = PTUse
Pck.OperationSequenceNumber.Value = SEQN
Pck.ItemNumber.Value = WorkCentre
Pck.Stockroom.Value = Stock
Pck.Bin.Value = Bin
Pck.IssuedQuantity.Value = Qty
FSClient.ProcessId(Pck)
ElseIf MenuID = 1 Then
Dim Pck As New PICK04
Pck.OrderType.Value = "M"
Pck.IssueType.Value = "I"
Pck.OrderNumber.Value = MONumber
Pck.LineNumber.Value = LineNumber
Pck.PointOfUseID.Value = PTUse
Pck.OperationSequenceNumber.Value = SEQN
Pck.ItemNumber.Value = WorkCentre
Pck.IssuedQuantity.Value = Qty
FSClient.ProcessId(Pck)
End If
FSClient.Terminate()
ImpContext.Undo()
View 12 Replies
View Related
Sep 17, 2007
Hi,
How do we set credentials or contex to a thread.
I create a new thread and within that thread if I am use a connetion string with Integrated Security=True" to talk to the SQL Server, however it seems that the new thread's context/identity is blank and hence failing the SQL Server connection.
Please help.
Thanks
View 2 Replies
View Related
Feb 18, 2005
Hi boys and girls,
all of the sudden two days ago there are error messages started to appear in SQL Log, the server slows down substantially during these errors occurance:
SQL Server could not spawn process_loginread thread.
and
ERROR: Launch of System Task 'OnDemand' failed!
Any ideas of the best way to troubleshoot/reproduce it?
I run SQL2000 Ent on NT Server 2000 Advance. SP3a installed.
3.5Gb memmory allocated to the server with AWE anabled.
Any help appreciated.
Cheers.
Dim
View 2 Replies
View Related
Oct 19, 2005
Sql version
Microsoft SQL Server 2000 - 8.00.818 (Intel X86)
May 31 2003 16:08:15
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
I have dts running 24 X 7 every 5 minutes
I noticed DTS failed few times a day with error
Step Error Source: Microsoft OLE DB Provider for SQL Server
Step Error Description:Transaction (Process ID 74) was deadlocked on thread | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
Step Error code: 80004005
Step Error Help File:
Step Error Help Context ID:0
The is no entry about in Server server log files.
will trace identify deadlock and why deadlock info not entred into log file ?
View 3 Replies
View Related
Feb 12, 2004
Hope I'm not going to annoy anyone here too much but I'm looking for a place to post a job opening and was hoping that someone out there might know of a good site or two.
The job will be in the north Denver area.
Thanks! (And apologies if this is completely inappropriate behavior.)
View 4 Replies
View Related
Jul 23, 2005
Hello all,A software that connects SQL Server via ODBC uses 12 process at the sametime when I look at the process info(panel). Is it possible to increasenumber of process (or thread) for a specific database? Is there anyparameter?Thanks in advance,Do.--Message posted via http://www.sqlmonster.com
View 2 Replies
View Related
Nov 17, 2006
I have a child package that has been run successfully multiple times in the last month +. Each time with roughly the same amount of data, give or take a few thousand rows.
Suddenly, this child package is now giving me the following errors from the log file:
Error: 2006-11-17 12:04:19.98
Code: 0xC0047031
Source: DFLT Primary DTS.Pipeline
Description: The Data Flow task failed to create a required thread and cannot begin running. The usually occurs when there is an out-of-memory state.
End Error
Error: 2006-11-17 12:04:20.03
Code: 0xC004700E
Source: DFLT Primary DTS.Pipeline
Description: The Data Flow task engine failed at startup because it cannot create one or more required threads.
End Error
I tried taking the child out of parent and running it by itself. I still get the same error. There are three other child packages that run on the exact same data and they have no problems. The control flow for the package first runs an SQL command. Then it has a data flow. The data flow grabs records from the source, adds two derived columns, looks up data and then stores to the destination. Relatively easy compared to other packages that are running just fine.
I've had our network people check the both the server running SSIS and the database server (two different machines) and there are no memory spike while the package is running.
Any ideas?
View 1 Replies
View Related
Aug 23, 2007
Hopefully this is the right forum! Im guessing they both are since they return the values pertaining to the current scope. I don't want to use transactions when I dont have to. What do you guys think?
View 4 Replies
View Related
Sep 5, 2007
Assume in a table, I have a table structure which contains parentID and childID.
In my procedure to insert a child for example, I begin a transaction, do a select statement see how many children for the given parentID, if is more than 10 then don't insert , otherwise insert the new child in. Then commit the transaction.
I wonder how thread safe such code would be... Quite worry about data corruption.
If 2 threads both updating this table, and the select statement both return 9 children, so both of them think they can do the insert, so the parent will end up with 11 children. Is such scenario possible to occur? If so, how to solve it and make sure the code is thread safe?
Hope someone can give me some suggestions..
Thank you
View 10 Replies
View Related
Sep 8, 2006
Is there a way to do this? When I have a further question in the same thread, my only option is to reply to the one who answered the last question. How do I put forward that question to everyone? Do I have to start a new thread with the same subject?
thx
Kat
View 4 Replies
View Related
Aug 17, 1998
Anyone have any experience with running MS SQL Server web applications using Java servlets with connection pooling? Any settings/tricks/traps that we should be aware of?
Our basic problem is that under CERTAIN senarios (which we haven`t been able to strictly identify yet), it appears that each browser client has to wait for the last client to finish - only shared locks are being applied to the database.
View 1 Replies
View Related
Sep 27, 2005
My God! What happens if I miss a step, or put it in a different order??? I know I can specify ORDER BY StepID, but what about a missing step? I do have "missing ranges" script, but posting questions filtered through the script process may become a full-time job in itself...What to do, what to do...
View 14 Replies
View Related