Showing posts with label block. Show all posts
Showing posts with label block. Show all posts

Tuesday, March 27, 2012

Does SQL Server CE support System.Transactions?

Hi,

I've tried to enclose a few database operations in a TransactionScope block but it looks like SQL Server CE RM does ignores ambiental transaction.

Here is the code:

static void TestTxn() {
// Command to insert an integer in a table with a single integer column
string cmdPassText = "INSERT TESTTABLE (INTFIELD) VALUES(1)";
// Command to force field type mismatch exception
string cmdFailText = "INSERT TESTTABLE (INTFIELD) VALUES('Foo')";

using (TransactionScope scope = new TransactionScope()) {
using (SqlCeConnection conn = new SqlCeConnection("DataSource = 'Test.sdf'")) {
try {
conn.Open();
SqlCeCommand cmdPass = new SqlCeCommand(cmdPassText, conn);
returnValue = cmdPass.ExecuteNonQuery();
SqlCeCommand cmdFail = new SqlCeCommand(cmdFailText, conn);
returnValue = cmdFail.ExecuteNonQuery();
}
catch (Exception ex){
Console.WriteLine("Command failed");
Console.WriteLine("Exception Message: {0}", ex.Message);
}
}
scope.Complete();
}
}

After first command suceeds and seccond command failes table still has one affected row after transaction.

Am I doing something wrong or System.Transactions.Transaction is not supported with SQL Server CE RM?

Thanks,
Aleksandar

System.Transactions.Transaction is not supported in SQL Server CE RTM. It will be added in the next release of Visual Studio though.

Thanks

Pragya

Sunday, March 25, 2012

Does Shrinkfile Emptyfile block users?

I read BOL says this can be done online but will it generate blocks.
Is it done in small transactions?
Thanks
Paul
Can you point us to exactly where it stats that? A shrinkfile with or
without Emptyfile will lock the page or extent as it moves it from the back
of the file to the front or from file to file in the case of the empty file.
It should not hold that lock unless you wrapped it in your own transaction.
Andrew J. Kelly SQL MVP
"Paul Cahill" <xyzpaul.xyzcahill@.dsl.pipex.com> wrote in message
news:eLgLMZXiFHA.2644@.TK2MSFTNGP09.phx.gbl...
>I read BOL says this can be done online but will it generate blocks.
> Is it done in small transactions?
> Thanks
> Paul
>
|||Hi Andrew
As follows. If it does it page at a time I should be OK.
Thanks
Paul
DBCC SHRINKFILE
Shrinks the size of the specified data file or log file for the related
database
........
To remove any data that may be in a file, execute DBCC
SHRINKFILE('file_name', EMPTYFILE) before executing ALTER DATABASE.
The database being shrunk does not have to be in single-user mode; other
users can be working in the database when the file is shrunk. You do not
have to run SQL Server in single-user mode to shrink the system databases.
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:OeBukJYiFHA.500@.TK2MSFTNGP09.phx.gbl...
> Can you point us to exactly where it stats that? A shrinkfile with or
> without Emptyfile will lock the page or extent as it moves it from the
> back of the file to the front or from file to file in the case of the
> empty file. It should not hold that lock unless you wrapped it in your own
> transaction.
> --
> Andrew J. Kelly SQL MVP
>
> "Paul Cahill" <xyzpaul.xyzcahill@.dsl.pipex.com> wrote in message
> news:eLgLMZXiFHA.2644@.TK2MSFTNGP09.phx.gbl...
>

Does Shrinkfile Emptyfile block users?

I read BOL says this can be done online but will it generate blocks.
Is it done in small transactions?
Thanks
PaulCan you point us to exactly where it stats that? A shrinkfile with or
without Emptyfile will lock the page or extent as it moves it from the back
of the file to the front or from file to file in the case of the empty file.
It should not hold that lock unless you wrapped it in your own transaction.
Andrew J. Kelly SQL MVP
"Paul Cahill" <xyzpaul.xyzcahill@.dsl.pipex.com> wrote in message
news:eLgLMZXiFHA.2644@.TK2MSFTNGP09.phx.gbl...
>I read BOL says this can be done online but will it generate blocks.
> Is it done in small transactions?
> Thanks
> Paul
>|||Hi Andrew
As follows. If it does it page at a time I should be OK.
Thanks
Paul
DBCC SHRINKFILE
Shrinks the size of the specified data file or log file for the related
database
.......
To remove any data that may be in a file, execute DBCC
SHRINKFILE('file_name', EMPTYFILE) before executing ALTER DATABASE.
The database being shrunk does not have to be in single-user mode; other
users can be working in the database when the file is shrunk. You do not
have to run SQL Server in single-user mode to shrink the system databases.
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:OeBukJYiFHA.500@.TK2MSFTNGP09.phx.gbl...
> Can you point us to exactly where it stats that? A shrinkfile with or
> without Emptyfile will lock the page or extent as it moves it from the
> back of the file to the front or from file to file in the case of the
> empty file. It should not hold that lock unless you wrapped it in your own
> transaction.
> --
> Andrew J. Kelly SQL MVP
>
> "Paul Cahill" <xyzpaul.xyzcahill@.dsl.pipex.com> wrote in message
> news:eLgLMZXiFHA.2644@.TK2MSFTNGP09.phx.gbl...
>

Thursday, March 22, 2012

Does Shrinkfile Emptyfile block users?

I read BOL says this can be done online but will it generate blocks.
Is it done in small transactions?
Thanks
PaulCan you point us to exactly where it stats that? A shrinkfile with or
without Emptyfile will lock the page or extent as it moves it from the back
of the file to the front or from file to file in the case of the empty file.
It should not hold that lock unless you wrapped it in your own transaction.
--
Andrew J. Kelly SQL MVP
"Paul Cahill" <xyzpaul.xyzcahill@.dsl.pipex.com> wrote in message
news:eLgLMZXiFHA.2644@.TK2MSFTNGP09.phx.gbl...
>I read BOL says this can be done online but will it generate blocks.
> Is it done in small transactions?
> Thanks
> Paul
>|||Hi Andrew
As follows. If it does it page at a time I should be OK.
Thanks
Paul
DBCC SHRINKFILE
Shrinks the size of the specified data file or log file for the related
database
.......
To remove any data that may be in a file, execute DBCC
SHRINKFILE('file_name', EMPTYFILE) before executing ALTER DATABASE.
The database being shrunk does not have to be in single-user mode; other
users can be working in the database when the file is shrunk. You do not
have to run SQL Server in single-user mode to shrink the system databases.
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:OeBukJYiFHA.500@.TK2MSFTNGP09.phx.gbl...
> Can you point us to exactly where it stats that? A shrinkfile with or
> without Emptyfile will lock the page or extent as it moves it from the
> back of the file to the front or from file to file in the case of the
> empty file. It should not hold that lock unless you wrapped it in your own
> transaction.
> --
> Andrew J. Kelly SQL MVP
>
> "Paul Cahill" <xyzpaul.xyzcahill@.dsl.pipex.com> wrote in message
> news:eLgLMZXiFHA.2644@.TK2MSFTNGP09.phx.gbl...
>>I read BOL says this can be done online but will it generate blocks.
>> Is it done in small transactions?
>> Thanks
>> Paul
>>
>sql

does showContig Block ?

does DBCC ShowContig Block ?
I want to run this in prod but cant find any documentation that indicates if
this blocks or not
thanks in advance
GAJHi,
Use WITH FAST option along to avoid blocking.
Note:
A fast scan does not read the leaf or data level pages of the index, so will
not create blocks.
Usage:
USE dbname
GO
DBCC SHOWCONTIG ('table_name') with fast
GO
Thanks
Hari
MCDBA
"Jaxon" <GregoryAJackson@.hotmail.com> wrote in message
news:e#rtZkUDEHA.2052@.TK2MSFTNGP11.phx.gbl...
> does DBCC ShowContig Block ?
> I want to run this in prod but cant find any documentation that indicates
if
> this blocks or not
>
> thanks in advance
>
> GAJ
>|||If you run it on a heap, WITH FAST has no effect and it will still take a
table S lock. WITH FAST allows it to take a table IS lock when run on
clustered and non-clustered indexes.
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:uld4HaWDEHA.3280@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Use WITH FAST option along to avoid blocking.
> Note:
> A fast scan does not read the leaf or data level pages of the index, so
will
> not create blocks.
> Usage:
> USE dbname
> GO
> DBCC SHOWCONTIG ('table_name') with fast
> GO
> Thanks
> Hari
> MCDBA
>
> "Jaxon" <GregoryAJackson@.hotmail.com> wrote in message
> news:e#rtZkUDEHA.2052@.TK2MSFTNGP11.phx.gbl...
indicates
> if
>|||crud.
about 80% of our tables are HEAPS (long Story) so running this in prod puts
us on our lips...
Correct ?
Greg J|||Assuming that 'puts us on our lips' is bad, then yes, you don't want to do
it. What are you trying to acheive - there may be another way to do it...
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jaxon" <GregoryAJackson@.hotmail.com> wrote in message
news:OdsxqBdDEHA.2308@.tk2msftngp13.phx.gbl...
> crud.
> about 80% of our tables are HEAPS (long Story) so running this in prod
puts
> us on our lips...
>
> Correct ?
>
> Greg J
>

Wednesday, March 21, 2012

Does RAISERROR cause performance to go down slightly?

I was curious if using RAISERROR in the catch block of a stored procedure does actually causes some hit on performance? I think it would, as compared to simply returning an error code in this sp's output parameter.

It will cause some impact as RAISEERROR will inevitably require some extra resource, where as you rightly say an error code just requires a value to be set within an existing block of memory.