Trying To Use TransactionScope For The First Time..................

Jan 31, 2008

I am writing my first distributed transaction application, using C# and running against SQL Server 2005 on a Windows 2003 Server. Both Windows 2003 Server and SQL Server 2005 have their respective service pack 1's applied on this server. I am using Visual Studio 2005 Pro for development.       I am using the TransactionScope object in the System.Transaction namespace, and as I understand it, if the SystemTransaction object detects that a connection to a second SQL Server 2005 database is about to be opened, then it will promote the transaction from a lightweight transaction manager to a distributed transaction. I have stepped through the application in the debugger and found that it opens the connection just fine to the to the database, executes the stored procedure like a champ, but when it attempts to execute the second stored proc  it generates the following error messages (which I copied out of the output window):       ? ex.Message      "Communication with the underlying transaction manager has failed."      ? ex.InnerException      {"Error HRESULT E_FAIL has been returned from a call to a COM component."}        [System.Runtime.InteropServices.COMException]: {"Error HRESULT E_FAIL has been returned from a call to a COM component."}        Data: {System.Collections.ListDictionaryInternal}        HelpLink: null        InnerException: null        Message: "Error HRESULT E_FAIL has been returned from a call to a COM component."        Source: "System.Transactions"        StackTrace: "  at System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32 propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier, Guid& transactionIdentifier, OletxTransactionIsolationLevel& isolationLevel, ITransactionShim& transactionShim)
  at System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(Byte[] propagationToken)"        TargetSite: {Void ReceiveTransaction(UInt32, Byte[], IntPtr, System.Guid ByRef, System.Transactions.Oletx.OletxTransactionIsolationLevel ByRef, System.Transactions.Oletx.ITransactionShim ByRef)} 
The  Distributed Transaction Coordinator is started on the development machine and the SQL Server 2005/Windows 2003 server machine.
Any ideas?

 

View 1 Replies


ADVERTISEMENT

TransactionScope

Oct 20, 2007

 I am at a loss here.    Sub Main()        Dim sqlConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("db").ToString)        Dim dbCommand As New SqlCommand("test", sqlConnection)        dbCommand.CommandType = CommandType.StoredProcedure        Using ts As New TransactionScope            Using sqlConnection                sqlConnection.Open()                Try                    dbCommand.ExecuteNonQuery()                    Console.WriteLine("Success")                Catch ex As SqlException                    Console.WriteLine(ex.Message)                Finally                    dbCommand.Dispose()                End Try                ts.Complete()            End Using        End Using        Console.ReadKey()    End Sub  BEGIN    Insert    dbo.Table_2        (Column1)        Values        (newid())    Insert    dbo.Table_1        (Column1)        Values        ('123456')End The Try block catches the exception in the second insert statement as it should, but I still get this exception "The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION." at the last End Using. I have tried placing Begin Transaction/Commit Transaction around the insert statement, but I get the same exception. What I am doing seems to match all the examples for the TransactionScope class.

View 1 Replies View Related

Want To Use TransactionScope But Not Getting It.......................................

Feb 2, 2008

Transaction/TransactionScope
When a user signs up on our site we use Microsofts Membership and Roles Framework. We also have some of our own tables that need to be updated. I have tried to wrap the whole thing into TransactionScope but it is not working. Looking at some samples it might not be possible to do what I am trying to do. We have a Data Access Layer to get the data from or into the database. Here is some mock up code:
using (System.Transactions.TransactionScope transaction = new System.Transactions.TransactionScope()){MembershipUser newUser = Membership.CreateUser(userName, password, email, question, answer, isApproved, out status);Roles.AddUserToRole(userName, Enumerations.Role.Basic.ToString());DAL.Group.Save(user);DAL.UsersInGroup.Save(userID, GroupID)transaction.Complete}
This code is simplified a lot but you get the idea. All these inputs have to complete succesfully to commit the transaction otherwise we have to roll it back. Can I use TransactionScope in this scenerio? The connection to the database happens in the DAL. Lost - help please, newbie
 

View 2 Replies View Related

TransactionScope

Feb 19, 2007

Hi, I'm trying this feature like:

Using tScope As New System.Transactions.TransactionScope

intRet = ta.Insert(dr.X, dr.Y, .....)

tScope.Complete()

End Using

Works fine without the TransactionScope, but with the above code I will end up with "The timeout period elapsed prior to completion of the operation or the server is not responding." I'm running the development server on my PC and the SQL-2000-server is a machine on the LAN. (Same domain)



View 1 Replies View Related

TransactionScope

Apr 5, 2006

Hi,

I am trying to use transactions as below:

using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
{


//some code here

// Throw an exception to roll back the transaction.

// Call the Complete method to commit the transaction


}

I can't seem to get it working though. Have trided several things like Security Configuration on the MSDTC tab, restarted €śDistributed Transaction Coordinator€? Service, iisreset, different constructors on the transactionscope etc. I haven't tried running it from the same domain since this won't work with the source safe. Is it really suppose to be this "hard" to get it right??

I use Windows XP Professional 2002 service pack 2 and microsoft SQL server 2005.

Thanks for any answers on the matter...

//R

View 6 Replies View Related

TransactionScope Error

Jan 2, 2007

I am required to insert an xcel file that may contain more than 1000 records into the databse in a single transaction.
I have used Transaction scope for the same.
The code works fine on my machine, Where the database is on a win 2k machine and the application is on Win XP machine. Tha database is Sql server 2000.
When the same code is deployed at Win2k3 server, I recieved following errors,

Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.
Import of MSDTC transaction failed: XACT_E_NOTRANSACTION.
Ther error occured randomly, sometimes after 900 records and sometime after 1500 records.Many times the application successfully insert 1900 records,
 Can anybody help me? I think i am required to make some MSDTC settings.
I have checked for the firewall settings. I have increased the timeout of transactionscope as TimeSpan.Max

View 1 Replies View Related

TransactionScope Limitations And MS DTC

Nov 15, 2007

I am receiving an error message while using the System.Transactions.TransactionScope class.  The error message that I am receiving is "Communication with the underlying transaction manager has failed".  This error seems to only appear when I have my web application one server, Server1,  and my database on a second, Server2.  When I run the web app on the same server as the database (i.e., web site and database on Server2), I don't receive this error.  So, this leads me to believe this has something to do with MS DTC.   Is there a limit to how much data MS DTC can manage for a given transaction?  If so, is it configurable? When I run my code, the application fails after a certain number of steps (this is repeatable). See sample code below.  When I execute the code below, the error occurs on UpdateBody2();.  If I comment out UpdateBody2(), the error will now occur on UpdateBody3();, and so on.  This leads me to believe that I have hit some upper limit. My code follows a pattern similar to this:using {TransactionScope scope = new TransactionScope()){    UpdateHeader();    UpdateBody1();    UpdateBody2();    UpdateBody3();    UpdateFooter();}Where each of the classes follows a pattern of:UpdateHeader(){    using (SqlConnection conn = new SqlConnection())    {    conn.Open();    // Do something     conn.Close();     } } Environment:ASP.NET 2.0SQL/2005 StandardWindows Server 2003  Thanks.Steve 

View 3 Replies View Related

TransactionScope And TableAdapter

Jul 30, 2007

This thread has also been posted under '.NET Data Access and Storage'. However, I have realized that the same code contruction using SQL Server connection- and tableadapter objects work fine so I am trying to get answers here also.

I am attempting to do transactional updates to SQL Compact Edition database using TableAdapter and TransactionScope like this:


using (TransactionScope ts = new TransactionScope())

{


SqlCeConnection sqlConn = new SqlCeConnection(connectionString);

myTableTableAdapter ta = new myTableTableAdapter();

ta.Connection = sqlConn;

ta.Update(dsmyTable.myTable);
ts.Complete();

}


dsmyTable is a strongly typed dataset created through the Dataset Designer and populated with data from the database prior to the code sample above.

This all works fine. However, when removing the call to 'ts.Complete()' to simulate the transaction rolling back, data is still stored into the database.

Am I missing something here or does TransactionScope not support SQL Compact Edition? Any help is appreciated!

Regards.

View 3 Replies View Related

Question About TransactionScope And DTC

Jul 27, 2007

My Code :



Code Snippet
using (TransactionScope scope = new TransactionScope())
{
using (SqlConnection sqlConn = new SqlConnection(connStr))
{
sqlConn.Open(); //throw exception:The transaction has already been implicitly or explicitly committed or aborted




//do delete,update
}
scope.complete();
}



My clientsystem is winxp sp2, dbserver is win2003


Err: The transaction has already been implicitly or explicitly committed or aborted.


Type: TransactionException
StackTrace:
Server stack trace:
at System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMException comException)
at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)
at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
at System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)
at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()

Please help!


I have enable "Network DTC Access", allow both "Inbound" and "Outbound" TM communication, set it to "No Authentication Required" in DTC

I had been puzzled for servral days!
I can't find the answer and read many-large-hurge topics and blogs!

Help me,thk u!

View 3 Replies View Related

Connection Won't Enlist In TransactionScope

Nov 11, 2007

I'm getting the following stack trace when trying to use TransactionScope with multiple newly created connections. The exact same code works perfectly in MSSQL 2005. Is there something that I'm missing, or (hopefully) is this going to be fixed for release? Thanks much.

System.InvalidOperationException: The connection object can not be enlisted in transaction scope.
at System.Data.SqlServerCe.SqlCeConnection.Enlist(Transaction tx)
at System.Data.SqlServerCe.SqlCeConnection.Open()
at TransactionScopeBugs.DAO.get_Connection() in DAO.cs:line 35
at TransactionScopeBugs.DAO.Insert(String query) in DAO.cs:line 51
at TransactionScopeBugs.Class1.InsertRecord() in Class1.cs:line 38
at TransactionScopeBugs.Class1.TestTxScope() in Class1.cs:line 54

Class1



Code Block
[TestFixture]
public class Class1
{
protected TransactionScope scope;

[SetUp]
public void Initialize()
{
scope = new TransactionScope();
}

[TearDown]
public void TearDown()
{
scope.Dispose();
}

private int GetRowCount(DAO d)
{
using (DbCommand cmd = d.NewCommand("SELECT COUNT(*) FROM TxScope", d.Connection))
{
return (int)cmd.ExecuteScalar();
}
}

private void InsertRecord()
{
DAO d = new DAO();
int num1 = GetRowCount(d);
string id = d.Insert("INSERT INTO TxScope (name) values ('txscope')");
Assert.IsNotNull(id);
Console.WriteLine(id);
int num2 = GetRowCount(d);
Assert.AreEqual(num1 + 1, num2);
}

[Test]
public void TestTxScope()
{
InsertRecord();
}
}





DAO



Code Block
public class DAO
{
private static readonly DbProviderFactory providerFactory;

static DAO()
{
providerFactory = DbProviderFactories.GetFactory("System.Data.SqlServerCe.3.5");
}

public DbConnection Connection
{
get
{
DbConnection conn = providerFactory.CreateConnection();
if (conn.State == ConnectionState.Closed)
{
conn.ConnectionString = "DataSource="txscope.sdf"";
conn.Open();
}
return conn;
}
}

public DbCommand NewCommand(String query, DbConnection conn)
{
DbCommand cmd = providerFactory.CreateCommand();
cmd.CommandText = query;
cmd.Connection = conn;
return cmd;
}

public string Insert(String query)
{
using (DbConnection con = Connection)
{
using (DbCommand cmd = NewCommand(query, con))
{
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT @@IDENTITY";
object val = cmd.ExecuteScalar();
return val.ToString();
}
}
}
}

View 2 Replies View Related

Managing Distributed Transactions With ADO.NET 2.0 Using TransactionScope Gives Error Message

Nov 14, 2007

 Hi, I am working  on vs2005 with sql server 2000. I  have used TransactionScope class. Example Reference: http://www.c-sharpcorner.com/UploadFile/mosessaur/TransactionScope04142006103850AM/TransactionScope.aspx   The code is given below.  using System.Transactions;   protected void Page_Load(object sender, EventArgs e)    {  System.Transactions.TransactionOptions transOption = new System.Transactions.TransactionOptions();         transOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;         transOption.Timeout = new TimeSpan(0, 2, 0);         using (System.Transactions.TransactionScope tranScope = new System.Transactions.TransactionScope(TransactionScopeOption.Required,transOption))         {            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["nwConnString"].ConnectionString))            {                int i;                con.Open();                SqlCommand cmd = new SqlCommand("update products set unitsinstock=100 where productid=1", con);                i = cmd.ExecuteNonQuery();                if (i > 0)                {                    using (SqlConnection conInner = new SqlConnection(ConfigurationManager.ConnectionStrings["pubsConnString"].ConnectionString))                    {                        conInner.Open();                        SqlCommand cmdInner = new SqlCommand("update Salary set sal=5000 where eno=1", conInner);                        i = cmdInner.ExecuteNonQuery();                        if (i > 0)                        {                            tranScope.Complete(); // this statement commits the executed query.                        }                    }                }            }            //  Dispose TransactionScope object, to commit or rollback transaction.        } } It gives error like
 "The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)" The database I have used is northwind database and pubs database which is by default in sql server 2000. So, Kindly let me know how to proceed further.  Thanks in advance,Arun. 

View 1 Replies View Related

Select With (nolock) OR TransactionScope With Option Read Uncommitted Data

May 29, 2007

Hi Sql gurus :))I've got a question that I couldn't find a satisfying answer on the net.What is the difference between:1) running sql query (select from sth with nolock) with no transaction2) running sql query (select from sth) withing a TransactionScope with option Read Uncommitted dataBasically, both should do the same work. However is anyone aware of any potential problems using any of both approaches ?We use 1) to improve our web application scalability since the system works in such a way that any selects and updates on that table (sth) do not interfere with one another.However, updates are done in a TransactionScope. And when having simultaneous select with nolock and update in a Transaction scope (the select statement has a where clause and returns records that are not updated by the update statement). However sometimes ( we still cannot figure it out when) the select statement returns some records twice.For example, the select should return 1000 records , but (sometimes) it returns 1002 records ( the extra 2 records are copies of some of the original 1000 records).Removing the nolock, makes the problem does not appear - but i want to be 100% sure that nolock is our troublemaker. And if it is - why ?We also have a problem that this particular nolock select sometimes return even less records than it should.I know it sounds impossible but it happens.So anyone who has experience with select with nolock, please share :)Thanks in advance, Yani 

View 4 Replies View Related

How To Convert UTC Time (retrieved From SQL) To Local Time In Reporting Services Based On Time Zone

Aug 7, 2007



Hi all,

I have created a report in SSRS 2005 which is being viewed by users from different Time Zones.

I have a dataset which has a field of type datetime (UTC). Now I would like to display this Date according to the User Time Zone.

For example if the date is August 07, 2007 10:00 AM UTC,

then I would like to display it as August 07, 2007 03:30 PM IST if the user Time Zone is IST.


Similarly for other Time Zones it should display the time accordingly.

Is this possible in SSRS 2005?

Any pointers will be usefull...

Thanks in advance
sudheer racha.

View 5 Replies View Related

SQL 2012 :: Accurate Sorting Data Each Time With Millions Of Records Without Time Field?

Apr 25, 2014

Sample Table

USE [Testing]
GO
/****** Object: Table [dbo].[Testing] Script Date: 4/25/2014 11:08:18 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON

[Code] ....

It seems to work fine with one million records.

Each primary key is unique, but the begindate is non-unique, and i guess even if i use datetime2 and add nanoseconds, from what i have read, there is a chance that i could have a duplicate datetime since the date is imported via XML from multiple sources.

View 7 Replies View Related

SQL Server 2014 :: Gathering Stored Procedure Execution Time In Real Time?

Jun 11, 2015

Is there a way to keep track in real time on how long a stored procedure is running for? So what I want to do is fire off a trace in a stored procedure if that stored procedure is running for over like 5 minutes.

View 5 Replies View Related

Integration Services :: Exclude Time In Date Time Variable In SSIS For Loop?

Oct 22, 2015

I am trying to load previous days data at 3 am via a SSIS job.

The Date variable is initiated as DATEADD("dd",-1, GETDATE()) in the for loop.

Now, as this job runs at 3 am, and I set the variable as GETDATE() - 1, it excluded the data from 12 am to 3 am in the resultset as Date is set as YYYY-MM-DD 03:00:00:000 I need this to be set as YYYY-MM-DD 00:00:00:000

How can i do this? 

View 2 Replies View Related

Transact SQL :: Update Time Portion Of DateTime Field With Time Parameter

Oct 3, 2015

I hope to update a DateTime column value with a Time input parameter.  Poor attempt below but it looks like the @ApptTime param is coming in as 10:45:00.0000000 and I might have an existing @SendOnDate as: 2015-10-05 07:00:00.000...I hope to end up with 2015-10-05 10:45:00.000

ALTER PROCEDURE [dbo].[SendEditUPDATE]
@QuePoolID int=null
,@ApptTime time(7)
,@SendOnDate datetime

[code]...

View 14 Replies View Related

It Takes A Long Time To Insert The First Record Each Time When The Program Start

Dec 15, 2006

I am using VS2005 (VB) to develop a PPC WM5.0 Program. And I am using SQLCE 3.0. My PPC Hardware is in 400MHz.

The question is when the program try to insert the first record into sdf database after each time the program started. It takes a long time. Does anyone know why and how can I fix it?

I will load the whole database into a dataset when the program start and do all the "Insert", "Update", "Delete" in this dataset and fill it into database after each action.

        cn.Open()
        sda = New SqlCeDataAdapter(SQL, cn) 'SQL = Select * From Table
        scb = New SqlCeCommandBuilder(sda) 
        sda.Update(dataset)
        cn.Close()

I check the sda.update(), it takes about 0.08s for filling one record into database normally. But:

1. Start the PPC Program

2. Load DB into dataset

3. Create a ONE new record in dataset

4. Fill back to DB

When I take this four steps everytime, the filling time is almost 1s or even more!

Actually, 0.08s is just a normal case. Sometimes, it still takes over 1s to filling back a dataset which only inserted one record when the program is running. (Even all inserted records are exactly the same in data jsut different in the integer key)

 However, when I give up the dataset and using the following code:

            cn.Open()
            Dim cmd As New SqlCeCommand(SQL, cn) ' I have build the insert SQL before (Insert Into Table values(XXXXXXXXXXXXXXX All field)

           cmd.CommandType = CommandType.Text
            cmd.ExecuteNonQuery()
            cn.Close()
            StartTime = Environment.TickCount

 I found that it is still the same that the first inserted record takes more time, but just about 0.2s. And the normal insert time is around 0.02s. It is 4 times faster!!!

View 1 Replies View Related

Transact SQL :: Converting 24hrs Time To 12 Hours Time Query Format?

Apr 21, 2015

SELECT 
    CONVERT(VARCHAR(10),attnc_chkin_dt,101) as INDATE,
    CONVERT(VARCHAR(10),attnc_chkin_dt,108) as TimePart
FROM pmt_attendance

o/p
indate   04/18/2015
time part :17:45:00

I need to convert this 17:45:00 to 12 hours date format...

View 8 Replies View Related

Problem With Getdate() In Transaction Takes The Insert Time Instead Of The Commit Time

Nov 12, 2007

Hi,

We need to select rows from the database that have been recently inserted/updated. We have a main primary table (COMMIT_TEST) and a second update table (COMMIT_TEST_UPDATE). The update table contains the primary key and a LAST_UPDATE field which is a datetime (to tell us when an update occurred). Triggers on the primary table are used to populate the update table.

If we insert or update the primary table in a transaction, we would expect that the datetime of the insert/update would be at the commit, however it seems that the insert/update statement is cached and getdate() is executed at the time of the cache instead of the commit. This causes problems as we select rows based on LAST_UPDATE and a commit may occur later but the earlier insert timestamp is saved to the database and we miss that update.

We would like to know if there is anyway to tell the SQL Server to not execute the function getdate() until the commit, or any other way to get the commit to create the correct timestamp.

We are using default isolation level. We have tried using getdate(), current_timestamp and even {fn Now()} with the same results. SQL Queries that reproduce the problem are provided below:


/* Different functions to get current timestamp €“ all have been tested to produce the same results */
/*
SELECT GETDATE()
GO
SELECT CURRENT_TIMESTAMP
GO
SELECT {fn Now()}
GO
*/
/* Use these statements to delete the tables to allow recreate of the tables */
/*
DROP TABLE COMMIT_TEST
DROP TABLE COMMIT_TEST_UPDATE
*/
/* Create a primary table and an UPDATE table to store the date/time when the primary table is modified */
CREATE TABLE dbo.COMMIT_TEST (PKEY int PRIMARY KEY, timestamp) /* ROW_VERSION rowversion */
GO
CREATE TABLE dbo.COMMIT_TEST_UPDATE (PKEY int PRIMARY KEY, LAST_UPDATE datetime, timestamp ) /* ROW_VERSION rowversion */
GO
/* Use these statements to delete the triggers to allow reinsert */
/*
drop trigger LOG_COMMIT_TEST_INSERT
drop trigger LOG_COMMIT_TEST_UPDATE
drop trigger LOG_COMMIT_TEST_DELETE
*/
/* Create insert, update and delete triggers */
create trigger LOG_COMMIT_TEST_INSERT on COMMIT_TEST for INSERT as
begin
declare @time datetime
select @time = getdate()

insert into COMMIT_TEST_UPDATE (PKEY,LAST_UPDATE)
select PKEY, getdate()
from inserted
end
GO
create trigger LOG_COMMIT_TEST_UPDATE on COMMIT_TEST for UPDATE as
begin
declare @time datetime
select @time = getdate()

update COMMIT_TEST_UPDATE
set LAST_UPDATE = getdate()
from COMMIT_TEST_UPDATE, deleted, inserted
where COMMIT_TEST_UPDATE.PKEY = deleted.PKEY
end
GO
/* In our application deletes should never occur so we don€™t log when they get modified we just delete them from the UPDATE table */
create trigger LOG_COMMIT_TEST_DELETE on COMMIT_TEST for DELETE as
begin
if ( select count(*) from deleted ) > 0
begin
delete COMMIT_TEST_UPDATE
from COMMIT_TEST_UPDATE, deleted
where COMMIT_TEST_UPDATE.PKEY = deleted.PKEY
end
end
GO
/* Delete any previous inserted record to avoid errors when inserting */
DELETE COMMIT_TEST WHERE PKEY = 1
GO
/* What is the current date/time */
SELECT GETDATE()
GO
BEGIN TRANSACTION
GO
/* Insert a record into the primary table */
INSERT COMMIT_TEST (PKEY) VALUES (1)
GO
/* Simulate additional processing within this transaction */
WAITFOR DELAY '00:00:10'
GO
/* We expect at this point that the date is written to the database (or at least we need some way for this to happen) */
COMMIT TRANSACTION
GO
/* get the current date to show us what date/time should have been committed to the database */
SELECT GETDATE()
GO
/* Select results from the table €“ we see that the timestamp is 10 seconds older than the commit, in other words it was evaluated at */
/* the insert statement, even though the row could not be read with a SELECT as it was uncommitted */
SELECT * FROM COMMIT_TEST
GO
SELECT * FROM COMMIT_TEST_UPDATE


Any help would be appreciated, we understand we could make changes to the application/database to approximate what we need, but all the solutions have identified suffer from possible performance issues, or could still lead to missing deals (assuming the commit time is larger than some artifical time window).

Regards,

Mark

View 8 Replies View Related

DB Engine :: Time Testing Azure Point In Time Database Restores?

Sep 21, 2015

I need to do a time test for restoring an Azure SQL database from a point in time. Can I automate this through PowerShell.

View 3 Replies View Related

SQL 2012 :: Converting Time String In Temp Table To Military Time Then Cast As Integer?

Dec 26, 2014

I need to take a temporary table that has various times stored in a text field (4:30 pm, 11:00 am, 5:30 pm, etc.), convert it to miltary time then cast it as an integer with an update statement kind of like:

Update myTable set MovieTime = REPLACE(CONVERT(CHAR(5),GETDATE(),108), ':', '')

how this can be done while my temp table is in session?

View 2 Replies View Related

SQL Server 2008 :: Displaying Transaction Time Punch Data In A Time Card Form?

Oct 7, 2015

I have a table called employee_punch_record that we use to store employee time clock punches.

The columns are:

employeeid,
punch_timestamp,
punch_type (In / Out),
closed (bit used as status for open or closed pay periods),
ident

Here are some examples of a record:

bkingery62015-10-06 16:59:04.000In0
bkingery72015-10-06 16:59:09.000Out0
bkingery82015-10-06 16:59:13.000In0
bkingery92015-10-06 18:22:44.000Out0
bkingery102015-10-06 18:22:46.000In0
bkingery112015-10-06 18:22:48.000Out0
bkingery122015-10-06 18:22:51.000In0
tfeller52015-10-05 17:00:05.000In0

We are using SQL Server 2008 as our database and use Access as a GUI. I am looking to create a form in Access where employees can access their time card and request changes from management. I want to use the format from the attached screen shot for the form. I pretty much know how to do it all, the only point of complication is trying to figure out the easiest way to get the transaction punch record data on employee_punch_record into a format where I can easily populate the form in the horizontal format you see in the screen shot.

I am not super strong in SQL, but figure I can do it using a formatting table of some sort. quick and easy way to move transaction records into a more horizontally oriented record?

View 0 Replies View Related

A Time Series Prediction Was Requested With A Start Time Further In The Past Than The Internal Models Of The Mining Model

Feb 19, 2008

Hi all,

I have a very simple time series model which processing works fine without any problem. However when I run the following query

SELECT

[TimeSeries].[PriceChange],

[TimeSeries].[Symbol],

PredictTimeSeries(PriceChange, -3, 2)

From

[TimeSeries]

WHERE

[TimeSeries].[Symbol] = 'x'


I get the following error:

TITLE: Microsoft SQL Server 2005 Analysis Services
------------------------------
Error (Data mining): A time series prediction was requested with a start time further in the past than the internal models of the mining model, TimeSeries, specified in the HISTORIC_MODEL_GAP and HISTORIC_MODEL_COUNT parameters can process.

The following is the excerpt of the minding model script related to the two parameters:


<AlgorithmParameters>

<AlgorithmParameter>

<Name>MISSING_VALUE_SUBSTITUTION</Name>

<Value xsi:type="xsdtring">Previous</Value>

</AlgorithmParameter>

<AlgorithmParameter>

<Name>HISTORIC_MODEL_GAP</Name>

<Value xsi:type="xsd:int">1</Value>

</AlgorithmParameter>

<AlgorithmParameter>

<Name>HISTORIC_MODEL_COUNT</Name>

<Value xsi:type="xsd:int">10</Value>

</AlgorithmParameter>

</AlgorithmParameters>


These HISTORIC_MODEL_GAP (1) and HISTORIC_MODEL_COUNT (10) should accommodate PredictTimeSeries(PriceChange, -3, 2). Could anyone shed some light on this?



View 3 Replies View Related

Reporting Services :: SSRS Loses Ability To Delegate User Credentials To Database Time To Time?

Apr 30, 2015

we have problems with our SQL Reporting Service 2012 (SSRS) server . We have setup Kerberos delegation between SSRS and the database server (SQL Server Always-on cluster) so users are authenticated down to the database. The issue occurs from time to time that SSRS loses the ability to delegate the user credentials to the database. At this point in time the Report Server logs contain rejected database connections because of ANONYMOUS logon. After restarting SSRS the problem is gone.

View 2 Replies View Related

Help Writing Query (find The Entry With The Closest Time Given A Time)

May 26, 2005

Hi,

I have a table which has a few fields, one being "datetime_traded". I need to write a query which returns the row which has the closest time (down to second) given a date/time. I'm using MS SQL.

Here's what I have so far:


Code:


select * from TICK_D
where datetime_traded = (select min( abs(datediff(second,datetime_traded , Convert(datetime,'2005-05-30:09:31:09')) ) ) from TICK_D)



But I get an error - "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.".

Does anyone know how i could do this? Thanks a lot for any help!

View 2 Replies View Related

Optimization Advice (CPU Time = 15203 Ms, Elapsed Time = 8114 Ms.)!!

Aug 17, 2007

Ok, so I have some horribly convuluted SQL that I would love to optomize. I'm not happy leaving it in it's current state, that's for sure!

I'm currently working on our test bed servers, so obviously my stats are out because of the "crap-ness" (yes, that's the technical term) of the hardware, but still, it should NEVER need to take this long!!

Basically, the issue arises in the nasty join to the career table (one employee can have multiple career lines). Just to make things complicated, employees can have any number of career records on any given date, these can even be input for future career events. The following SQL picks out the latest-current career date for each employee based on the career_date being <= GetDate() and the date of entry for this date being the greatest.

E.g.
career_date | datetime_created
2009-01-01 | 2006-05-05 13:55:21.000
2007-01-01 | 2006-05-05 13:54:18.000
2007-01-01 | 2006-05-05 13:52:55.000

From the above we want to return
2007-01-01 | 2006-05-05 13:54:18.000

SET STATISTICS IO ON
SET STATISTICS TIME ON

SELECT a.sAMAccountNameAs 'sAMAccountName'
, a.userPrincipalNameAs 'userPrincipalName'
, 'TRUE'As 'Modify'
, RTRIM(e.unique_identifier)As 'employeeID'
, RTRIM(e.employee_number)As 'employeeNumber'
, RTRIM(e.known_as)
+ CASE WHEN RTRIM(e.surname) IS NOT NULL THEN
' ' + RTRIM(e.surname) ELSE NULL ENDAs 'displayName'
, RTRIM(e.known_as)As 'givenName'
, RTRIM(e.surname)As 'sn'
, RTRIM(c.job_title)As 'title'
, RTRIM(c.division)As 'company'
, RTRIM(c.department)As 'department'
, RTRIM(l.description)As 'physicalDeliveryOfficeName'
, RTRIM(REPLACE(am.dn,'\',''))As 'manager'
, t.full_mobile
+ CASE WHEN RTRIM(t.mobile_number) IS NOT NULL THEN
' (DD: ' + RTRIM(t.mobile_number) + ')'ELSE NULL END
As 'mobile'
, t.mobile_numberAs 'otherMobile'
, ad.address_ad_countryAs 'c'
, ad.address_ad_address1
+ CASE WHEN ad.address_ad_address2 IS NOT NULL THEN
', ' + ad.address_ad_address2 ELSE NULL END
+ CASE WHEN ad.address_ad_address3 IS NOT NULL THEN
', ' + ad.address_ad_address3 ELSE NULL END
+ CASE WHEN ad.address_ad_address4 IS NOT NULL THEN
', ' + ad.address_ad_address4 ELSE NULL END
+ CASE WHEN ad.address_ad_address5 IS NOT NULL THEN
', ' + ad.address_ad_address5 ELSE NULL ENDAs 'streetAddress'
, ad.address_ad_poboxAs 'postOfficeBox'
, ad.address_ad_cityAs 'l'
, ad.address_ad_CountyAs 'st'
, ad.address_ad_postcodeAs 'postalCode'
, RTRIM(ad.address_ad_telephone) +
CASE WHEN RTRIM(a.othertelephone) IS NOT NULL
AND RTRIM(ad.address_ad_telephone) IS NOT NULL THEN
' (Ext: ' + RTRIM(a.othertelephone) + ')'
ELSE
CASE WHEN RTRIM(a.othertelephone) IS NOT NULL
AND RTRIM(ad.address_ad_telephone) IS NULL THEN
'Ext: ' + RTRIM(a.othertelephone)
ELSE NULL
END
ENDAs 'telephoneNumber'
FROM employee e
LEFT
JOIN career c
ON c.parent_identifier = e.unique_identifier
AND c.career_date =(
SELECTmax(c2.career_date)
FROMpwa_master.career c2
WHEREc2.parent_identifier = c.parent_identifier
ANDc2.career_date <= GetDate()
)
AND c.datetime_created =(
SELECT max(c3.datetime_created)
FROMpwa_master.career c3
WHEREc3.parent_identifier = c.parent_identifier
ANDc3.career_date = c.career_date
)
LEFT
OUTER
JOIN AD_Import am
ON am.employeeNumber = c.manager_number
INNER
JOIN AD_Import a
ON a.employeeID = e.unique_identifier
LEFT
JOIN AD_Telephone t
ON t.unique_identifier = e.unique_identifier
LEFT
JOIN AD_Address ad
ON ad.address_pwa_location = e.location
LEFT
JOIN xlocat l
ON l.code = c.location
WHERE (a.employeeNumber IS NOT NULL
OR a.employeeID IS NOT NULL)


SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 0 ms.

(1706 row(s) affected)

Table 'AD_Import'. Scan count 4, logical reads 106, physical reads 0, read-ahead reads 0.
Table 'AD_Address'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0.
Table 'AD_Telephone'. Scan count 2, logical reads 10, physical reads 0, read-ahead reads 0.
Table 'Worktable'. Scan count 868, logical reads 956, physical reads 0, read-ahead reads 0.
Table 'xlocat'. Scan count 2, logical reads 8, physical reads 0, read-ahead reads 0.
Table 'career'. Scan count 5088, logical reads 2564843, physical reads 0, read-ahead reads 0.
Table 'people'. Scan count 1697, logical reads 5253, physical reads 0, read-ahead reads 0.
Table 'Worktable'. Scan count 826, logical reads 914, physical reads 0, read-ahead reads 0.


SQL Server Execution Times:
CPU time = 15203 ms, elapsed time = 8114 ms.

Any advice on what I can do to optomize?

Oh judt to point out that "employee" is a view on the "Table 'people'."
EDIT: I know it's pointing out the obvious, but I'm pulling out the managers "DN" from AD_Import based on the manager_number and employeeNumber matching.

View 14 Replies View Related

Calculate Elapsed Time Between Dates And Exclude A Time Span.

Dec 18, 2007

I need a formula to calculate the time (let's say in minutes) between two dates/times.
The problem is that I have to exclude the time between 06 PM and 06 AM and also exclude the time in the weekend (Saturday and Sunday).
I will use this in a couple of reports made in Reporting Services.
If anyone have an algoritm that could be modified for this and is willing to share this I would be very grateful.
Many thanks!
/Per Lissel

View 3 Replies View Related

Global Temp Tables Getting Dropped Form Time To Time

Apr 10, 2007

Hi all,

I have created several global temp tables to cache some intermediate results ...
However, it seems that after a while those tables will be dropped by SQL Server 2005 automatically (I have not restarted the server and no drop table statement ever executed against those tables). Is this a feature by design? How to make those global temp tables persistence to next service restart?

Thanks,
Ning

View 5 Replies View Related

Handle Time Zones And Daylight Savings Time In SQL Server

Dec 19, 2006

I wanted to know how we can handle Time Zones and Daylight Savings Time in SQL Server 2000 as well as 2005.

Any pointers would be helpful.

Pranav

View 1 Replies View Related

Reporting Services :: Parameter Filters - Start Time And End Time

Sep 14, 2015

At the moment I already added the DataSet I'm gonna be using. I have 2 date parameters Start Time and End Time.

What I would like to do  for the report is to only pull results greater than 48 hours to the report

How can I accomplish this?

View 4 Replies View Related

How To Find Point In Time Or Last Committed Time In Log Backup

Jun 25, 2015

I am reading about the RESTORE command to a point in time using logs, I would like to know the minimum point in time recovery for a backup image using T-SQL command before applying a log restore and what are the log ranges needed for the restore during restore.

 My Version 2008 R2

View 7 Replies View Related

A Key Time As A Split Variable In Microsoft Time Series?

Jul 4, 2007

Hello,

I was working with Microsoft Time Series model (MTS) with some data, when in the mining model viewer, decision tree tab, I realized that the key time variable that I define, it was acting like a split variable.

So, I ask you, this is possible?, because, for me, this should not happen€¦.

After, I review the Data Mining Tutorial by Seth Paul, Jamie MacLennan, Zhaohui Tang and Scott Oveson, and I found, in the Forecasting part, that the key time variable (Time Index) it was acting like a split variable too, in for example, M200 pacific:Quantity and R250 Europe:Quantity.

So people, it€™s possible that a key time variable act like a split variable in a MTS model?

Thanks

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved