Showing posts with label running. Show all posts
Showing posts with label running. Show all posts

Friday, March 23, 2012

How to reflect base table changes in cursor

I have a small question -

I have a cursor which is running on the table and i am deleting some rows from the same table during the cursor loop but it didnt reflecting it. Is there is any other option i need to sepcify during declare.

declare localshowcursor cursor for
SELECT video_release, programname, network, date_encoded, time_encoded, COUNT(*) AS Number
FROM SigmaStageTemp s
Where program_type = ‘1’
Group by video_release, programname, network, date_encoded, time_encoded
Having count(*) >= 10
Order by video_release, programname, network, date_encoded, time_encoded

Please help

Ashish,

Most likely, you don't need to be using a CURSOR.

Please post the code that executes for the CURSOR position, and perhaps we can help you do the same task in a SET based operation -which will be faster and less disruptive than using a CURSOR.

|||

Below is my complete code. It select the range of records from the base table and insert into a different table and then deletes those records from the base table but when i debuged the cursor i am still getting the value of time_encoede which should be deleted.

declare @.pgname nvarchar(20)
declare @.videorelease nvarchar(40)
declare @.dateaired nvarchar(15)
declare @.dateencoded nvarchar(15)
declare @.timeencoded nvarchar(15)
declare @.network nvarchar(12)
declare @.count int

declare localshowcursor cursor for
SELECT video_release, programname, network, date_encoded, time_encoded, COUNT(*) AS Number
FROM SigmaStageTemp s
Where program_type = ‘1’
Group by video_release, programname, network, date_encoded, time_encoded
Having count(*) >= 10
Order by video_release, programname, network, date_encoded, time_encoded

OPEN localshowcursor

FETCH NEXT FROM localshowcursor INTO @.videorelease, @.pgname, @.network, @.dateencoded, @.timeencoded, @.count

WHILE @.@.FETCH_STATUS = 0
BEGIN

Insert into sigmtemp(Video_release, country, market_rank, Designated_mrkt_area, station, network, date_aired, day_of_week, day_part, half_hour_aired, programname, program_type, start_time, end_time, length_aired, date_encoded, time_encoded, rel_type, VR_CODE1, VR_CODE2, VR_CODE3, VR_CODE4, DMA_CODE, sid_code, station_code)
(Select top(1)
Video_release, country, market_rank, Designated_mrkt_area, station, network, date_aired, day_of_week, day_part, half_hour_aired, programname, program_type, start_time, end_time, length_aired, date_encoded, time_encoded, rel_type, VR_CODE1, VR_CODE2, VR_CODE3, VR_CODE4, DMA_CODE, sid_code, station_code

from sigmastagetemp s1
where s1.video_release = @.videorelease and
s1.programname = @.pgname and
s1.network = @.network and
s1.date_encoded = @.dateencoded and
convert(int,s1.time_encoded) between convert(int,@.timeencoded) -2 and
convert(int,@.timeencoded) +2

Order by video_release, programname, network, date_encoded, time_encoded )

Delete
from sigmastagetemp
where video_release = @.videorelease and
programname = @.pgname and
network = @.network and
date_encoded = @.dateencoded and
convert(int,time_encoded) between convert(int,@.timeencoded) -2 and
convert(int,@.timeencoded) +2

FETCH NEXT FROM localshowcursor INTO @.videorelease, @.pgname, @.network, @.dateencoded, @.timeencoded, @.count
END

CLOSE localshowcursor
DEALLOCATE localshowcursor

|||

You can't achive it on the cursor.

When you use the GROUP BY, all the result will be stored in the temp table and the temp table will be served for your cursor.

The only communication with your table is on the DECLARE & OPEN cursor. After that it will be acted independetly....

The Following query proves this,

Code Snippet

Create table TESTCUR

(

Num Int,

Chr Char

)

Insert Into TESTCUR VALUES(1,'A')

Insert Into TESTCUR VALUES(1,'A')

Insert Into TESTCUR VALUES(1,'A')

Insert Into TESTCUR VALUES(1,'B')

Insert Into TESTCUR VALUES(1,'B')

Insert Into TESTCUR VALUES(1,'B')

Insert Into TESTCUR VALUES(1,'C')

Insert Into TESTCUR VALUES(1,'C')

Insert Into TESTCUR VALUES(1,'D')

Go

Declare TESTCURFUN Cursor DYNAMIC

For Select Count(NUM) C,Chr From TESTCUR Group BY Chr;

Declare @.I as int, @.N Char;

Open TESTCURFUN

Fetch TESTCURFUN INTO @.I,@.N

--Drop the Table

Drop Table TESTCUR

While @.@.FETCH_STATUS = 0

Begin

Select @.I,@.N

Fetch TESTCURFUN INTO @.I,@.N

End

Close TESTCURFUN

DEALLOCATE TESTCURFUN

--Try the same logic without group by you might get error.

sql

How to reduce size of sql.log file

Hi,
I am running database on SQL2000 server and sql.log file
that is associated with the database keeps on growing. I
would like to reduce its size but don't know how. I would
appreciate if someone could tell me what is the way to
reduce the sql.log file size.
Thanks in advance.
I did try to backup database, backup log file and shrink
both database and log file, but these actions did not
reduce size of sql.log file.
My database file is:
D:\pgm_db\OrdersManager_Data.MDF
My database log file is:
C:\Program Files\Microsoft SQL
Server\MSSQL\data\OrdersManager_Log.LDF
sql.log file is ascii file in the same directory as
database file. The contents of the file looks like this:
with_subscribe_ 618-c6c ENTER SQLAllocEnv
HENV * 010FF7B0
with_subscribe_ 618-c6c EXIT SQLAllocEnv with return
code 0 (SQL_SUCCESS)
HENV * 0x010FF7B0 (
0x01111520)
with_subscribe_ 618-c6c ENTER SQLAllocConnect
HENV 01111520
HDBC * 01220890
with_subscribe_ 618-c6c EXIT SQLAllocConnect with return
code 0 (SQL_SUCCESS)
HENV 01111520
HDBC * 0x01220890 (
0x011115c8)
with_subscribe_ 618-c6c ENTER SQLConnectW
HDBC 011115C8
WCHAR * 0x011116D0 [
3] "gms"
SWORD 3
WCHAR * 0x1F7F8B88 [ -
3] "******\ 0"
SWORD -3
WCHAR * 0x1F7F8B88 [ -
3] "******\ 0"
SWORD -3
with_subscribe_ 618-c6c EXIT SQLConnectW with return
code 1 (SQL_SUCCESS_WITH_INFO)
HDBC 011115C8
WCHAR * 0x011116D0 [
3] "gms"
SWORD 3
WCHAR * 0x1F7F8B88 [ -
3] "******\ 0"
SWORD -3
WCHAR * 0x1F7F8B88 [ -
3] "******\ 0"
SWORD -3
DIAG [01000] [Microsoft][ODBC SQL Server
Driver][SQL Server]Changed database context
to 'GasManager'. (5701)
DIAG [01000] [Microsoft][ODBC SQL Server
Driver][SQL Server]Changed language setting to us_english.
(5703)
with_subscribe_ 618-c6c ENTER SQLGetInfoW
HDBC 011115C8
UWORD 81
<SQL_GETDATA_EXTENSIONS>
PTR 01220898
SWORD 4
SWORD * 0x0026F27E
with_subscribe_ 618-c6c EXIT SQLGetInfoW with return
code 0 (SQL_SUCCESS)
HDBC 011115C8
UWORD 81
<SQL_GETDATA_EXTENSIONS>
PTR 01220898
SWORD 4
SWORD * 0x0026F27E (4)
with_subscribe_ 618-c6c ENTER SQLAllocStmt
HDBC 011115C8
HSTMT * 0026EA7CThe log is an ODBC tracing log so you have ODBC tracing
turned on. To turn it off, go to Administrative Tools and
select Data Sources (ODBC). In the ODBC Data Source
Administrator, go to the tracing tab and click on the Stop
Tracing Now button.
-Sue
On Mon, 15 Mar 2004 15:51:25 -0800, "Branko Kovac"
<branko.kovac@.invensys.com> wrote:

>Hi,
>I am running database on SQL2000 server and sql.log file
>that is associated with the database keeps on growing. I
>would like to reduce its size but don't know how. I would
>appreciate if someone could tell me what is the way to
>reduce the sql.log file size.
>Thanks in advance.
>I did try to backup database, backup log file and shrink
>both database and log file, but these actions did not
>reduce size of sql.log file.
>My database file is:
>D:\pgm_db\OrdersManager_Data.MDF
>My database log file is:
>C:\Program Files\Microsoft SQL
>Server\MSSQL\data\OrdersManager_Log.LDF
>sql.log file is ascii file in the same directory as
>database file. The contents of the file looks like this:
>with_subscribe_ 618-c6c ENTER SQLAllocEnv
> HENV * 010FF7B0
>with_subscribe_ 618-c6c EXIT SQLAllocEnv with return
>code 0 (SQL_SUCCESS)
> HENV * 0x010FF7B0 (
>0x01111520)
>with_subscribe_ 618-c6c ENTER SQLAllocConnect
> HENV 01111520
> HDBC * 01220890
>with_subscribe_ 618-c6c EXIT SQLAllocConnect with return
>code 0 (SQL_SUCCESS)
> HENV 01111520
> HDBC * 0x01220890 (
>0x011115c8)
>with_subscribe_ 618-c6c ENTER SQLConnectW
> HDBC 011115C8
> WCHAR * 0x011116D0 [
>3] "gms"
> SWORD 3
> WCHAR * 0x1F7F8B88 [ -
>3] "******\ 0"
> SWORD -3
> WCHAR * 0x1F7F8B88 [ -
>3] "******\ 0"
> SWORD -3
>with_subscribe_ 618-c6c EXIT SQLConnectW with return
>code 1 (SQL_SUCCESS_WITH_INFO)
> HDBC 011115C8
> WCHAR * 0x011116D0 [
>3] "gms"
> SWORD 3
> WCHAR * 0x1F7F8B88 [ -
>3] "******\ 0"
> SWORD -3
> WCHAR * 0x1F7F8B88 [ -
>3] "******\ 0"
> SWORD -3
> DIAG [01000] [Microsoft][ODBC SQL Server
>Driver][SQL Server]Changed database context
>to 'GasManager'. (5701)
> DIAG [01000] [Microsoft][ODBC SQL Server
>Driver][SQL Server]Changed language setting to us_english.
>(5703)
>with_subscribe_ 618-c6c ENTER SQLGetInfoW
> HDBC 011115C8
> UWORD 81
><SQL_GETDATA_EXTENSIONS>
> PTR 01220898
> SWORD 4
> SWORD * 0x0026F27E
>with_subscribe_ 618-c6c EXIT SQLGetInfoW with return
>code 0 (SQL_SUCCESS)
> HDBC 011115C8
> UWORD 81
><SQL_GETDATA_EXTENSIONS>
> PTR 01220898
> SWORD 4
> SWORD * 0x0026F27E (4)
>with_subscribe_ 618-c6c ENTER SQLAllocStmt
> HDBC 011115C8
> HSTMT * 0026EA7C|||Thanks for this Sue. It worked.

>--Original Message--
>The log is an ODBC tracing log so you have ODBC tracing
>turned on. To turn it off, go to Administrative Tools and
>select Data Sources (ODBC). In the ODBC Data Source
>Administrator, go to the tracing tab and click on the Stop
>Tracing Now button.
>-Sue
>On Mon, 15 Mar 2004 15:51:25 -0800, "Branko Kovac"
><branko.kovac@.invensys.com> wrote:
>
would
return
us_english.
>.
>sql

Wednesday, March 21, 2012

How to reduce size of sql.log file

Hi,
I am running database on SQL2000 server and sql.log file
that is associated with the database keeps on growing. I
would like to reduce its size but don't know how. I would
appreciate if someone could tell me what is the way to
reduce the sql.log file size.
Thanks in advance.
I did try to backup database, backup log file and shrink
both database and log file, but these actions did not
reduce size of sql.log file.
My database file is:
D:\pgm_db\OrdersManager_Data.MDF
My database log file is:
C:\Program Files\Microsoft SQL
Server\MSSQL\data\OrdersManager_Log.LDF
sql.log file is ascii file in the same directory as
database file. The contents of the file looks like this:
with_subscribe_ 618-c6c ENTER SQLAllocEnv
HENV * 010FF7B0
with_subscribe_ 618-c6c EXIT SQLAllocEnv with return
code 0 (SQL_SUCCESS)
HENV * 0x010FF7B0 (
0x01111520)
with_subscribe_ 618-c6c ENTER SQLAllocConnect
HENV 01111520
HDBC * 01220890
with_subscribe_ 618-c6c EXIT SQLAllocConnect with return
code 0 (SQL_SUCCESS)
HENV 01111520
HDBC * 0x01220890 (
0x011115c8)
with_subscribe_ 618-c6c ENTER SQLConnectW
HDBC 011115C8
WCHAR * 0x011116D0 [
3] "gms"
SWORD 3
WCHAR * 0x1F7F8B88 [ -
3] "******\ 0"
SWORD -3
WCHAR * 0x1F7F8B88 [ -
3] "******\ 0"
SWORD -3
with_subscribe_ 618-c6c EXIT SQLConnectW with return
code 1 (SQL_SUCCESS_WITH_INFO)
HDBC 011115C8
WCHAR * 0x011116D0 [
3] "gms"
SWORD 3
WCHAR * 0x1F7F8B88 [ -
3] "******\ 0"
SWORD -3
WCHAR * 0x1F7F8B88 [ -
3] "******\ 0"
SWORD -3
DIAG [01000] [Microsoft][ODBC SQL Server
Driver][SQL Server]Changed database context
to 'GasManager'. (5701)
DIAG [01000] [Microsoft][ODBC SQL Server
Driver][SQL Server]Changed language setting to us_english.
(5703)
with_subscribe_ 618-c6c ENTER SQLGetInfoW
HDBC 011115C8
UWORD 81
<SQL_GETDATA_EXTENSIONS>
PTR 01220898
SWORD 4
SWORD * 0x0026F27E
with_subscribe_ 618-c6c EXIT SQLGetInfoW with return
code 0 (SQL_SUCCESS)
HDBC 011115C8
UWORD 81
<SQL_GETDATA_EXTENSIONS>
PTR 01220898
SWORD 4
SWORD * 0x0026F27E (4)
with_subscribe_ 618-c6c ENTER SQLAllocStmt
HDBC 011115C8
HSTMT * 0026EA7CThe log is an ODBC tracing log so you have ODBC tracing
turned on. To turn it off, go to Administrative Tools and
select Data Sources (ODBC). In the ODBC Data Source
Administrator, go to the tracing tab and click on the Stop
Tracing Now button.
-Sue
On Mon, 15 Mar 2004 15:51:25 -0800, "Branko Kovac"
<branko.kovac@.invensys.com> wrote:

>Hi,
>I am running database on SQL2000 server and sql.log file
>that is associated with the database keeps on growing. I
>would like to reduce its size but don't know how. I would
>appreciate if someone could tell me what is the way to
>reduce the sql.log file size.
>Thanks in advance.
>I did try to backup database, backup log file and shrink
>both database and log file, but these actions did not
>reduce size of sql.log file.
>My database file is:
>D:\pgm_db\OrdersManager_Data.MDF
>My database log file is:
>C:\Program Files\Microsoft SQL
>Server\MSSQL\data\OrdersManager_Log.LDF
>sql.log file is ascii file in the same directory as
>database file. The contents of the file looks like this:
>with_subscribe_ 618-c6c ENTER SQLAllocEnv
> HENV * 010FF7B0
>with_subscribe_ 618-c6c EXIT SQLAllocEnv with return
>code 0 (SQL_SUCCESS)
> HENV * 0x010FF7B0 (
>0x01111520)
>with_subscribe_ 618-c6c ENTER SQLAllocConnect
> HENV 01111520
> HDBC * 01220890
>with_subscribe_ 618-c6c EXIT SQLAllocConnect with return
>code 0 (SQL_SUCCESS)
> HENV 01111520
> HDBC * 0x01220890 (
>0x011115c8)
>with_subscribe_ 618-c6c ENTER SQLConnectW
> HDBC 011115C8
> WCHAR * 0x011116D0 [
>3] "gms"
> SWORD 3
> WCHAR * 0x1F7F8B88 [ -
>3] "******\ 0"
> SWORD -3
> WCHAR * 0x1F7F8B88 [ -
>3] "******\ 0"
> SWORD -3
>with_subscribe_ 618-c6c EXIT SQLConnectW with return
>code 1 (SQL_SUCCESS_WITH_INFO)
> HDBC 011115C8
> WCHAR * 0x011116D0 [
>3] "gms"
> SWORD 3
> WCHAR * 0x1F7F8B88 [ -
>3] "******\ 0"
> SWORD -3
> WCHAR * 0x1F7F8B88 [ -
>3] "******\ 0"
> SWORD -3
> DIAG [01000] [Microsoft][ODBC SQL Server
>Driver][SQL Server]Changed database context
>to 'GasManager'. (5701)
> DIAG [01000] [Microsoft][ODBC SQL Server
>Driver][SQL Server]Changed language setting to us_english.
>(5703)
>with_subscribe_ 618-c6c ENTER SQLGetInfoW
> HDBC 011115C8
> UWORD 81
><SQL_GETDATA_EXTENSIONS>
> PTR 01220898
> SWORD 4
> SWORD * 0x0026F27E
>with_subscribe_ 618-c6c EXIT SQLGetInfoW with return
>code 0 (SQL_SUCCESS)
> HDBC 011115C8
> UWORD 81
><SQL_GETDATA_EXTENSIONS>
> PTR 01220898
> SWORD 4
> SWORD * 0x0026F27E (4)
>with_subscribe_ 618-c6c ENTER SQLAllocStmt
> HDBC 011115C8
> HSTMT * 0026EA7C|||Thanks for this Sue. It worked.

>--Original Message--
>The log is an ODBC tracing log so you have ODBC tracing
>turned on. To turn it off, go to Administrative Tools and
>select Data Sources (ODBC). In the ODBC Data Source
>Administrator, go to the tracing tab and click on the Stop
>Tracing Now button.
>-Sue
>On Mon, 15 Mar 2004 15:51:25 -0800, "Branko Kovac"
><branko.kovac@.invensys.com> wrote:
>
would
return
us_english.
>.
>sql

how to reduce DOS attacks

Hello to everyone

I am running MS SQL 2005 Express I get per day 2-4 hackers attacks trying to login from “sa”

Some 37 calls times per second one of attack was continuing 4 days

Is there some setting into MS SQL 2005 to reduce that?

Can you recommend me good firewall for DDOS attacks?

Is it there some legal action that I can take to this people I have their IPs most are from US and Canada?

Thank you in advance

val

Hi Val,

If you are seeing a lot of attacks, the best thing to do would be to move your db server to a different machine behind your firewall entirely. You can restrict external access to your database by using another web or application server to handle any requests.

You can also consider disabling your sa account just to be safe.

I'm not sure what sort of legal actions you can take, perhaps consult with a lawyer? You may have some options available.

=== Edited by Sung MSFT @. 16 Aug 2006 3:01 AM UTC===
Also, you can have your firewall block all the IP addresses that you have identified as hostile. This should hopefully cut down on the number of attacks as well.

Sung|||

To make the connection attempts fail even earlier you could also rename the sa account.

Thanks
Laurentiu

|||

Hi

when I setup first time the server I disable the "sa" account , and I am behind Windows firewall

I am looking something like if there is too many call just server to drop this IP

I have 8-10 MB log file just from fail to access to MS SQL server

I hope there will be way to be droped before that

10x

val

|||

There is no such feature currently in SQL Server, but we have received this suggestion before: http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=124700. You can add your comments to this feedback report or just vote for its importance.

Thanks
Laurentiu

|||I normally recommend that you use a named instance instead of a default instance. Also, do a port redirection from your firewall. Do not use port 1433 or 1434 on your SQL Server. Let the firewall resolve it for the clients.

Monday, March 19, 2012

How to recover the primary sevrer in a cluster?

Hello, everyone:
The two SQL Server 2k (SP4) are running on W2K(SP4) in clustered A/A mode. The seconary server took over successfuly as the primary server crached. How to recover the primary sevrer?
Thanks a lot.Few articles to help:

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/failclus.mspx and http://www.microsoft.com/resources/documentation/sql/2000/all/reskit/en-us/part4/c1261.mspx

HTH

How to recover from mdf file (SQL Server 2000)

Hi,

My database corrupted because when I was running an update query, there is a power failure. After the computer booted, I cannot open the database anymore, it just not responding. Then I stop the sql server service, and tried to rename the .mdf and .ldf. After that it worked normally, but I need the data from the corrupted mdf file, I tried to attach the database but it just hanged. I even tried to attach without the .ldf file but it didn't work either, so I concluded that the problem is with the mdf file.

Is there any way to recover my data ?

Thanks in advance

Regards,

Edwin

Can you rename the mdf,ldf files to their original names and attach them to your SQL Server? (with all SQL Services running)

If that works, try using

DBCC CHECKDB ('DatabaseName' /*,REPAIR_REBUILD*/)
WITH NO_INFOMSGS, ALL_ERRORMSGS, DATA_PURITY

To see what went wrong

A 2nd choice is to restore the mdf,ldf files from a recent backup (if backup exists)

|||

Hi,

We'd tried that but we got no luck. Attaching the file in it's original name didn't work, the computer just hanged, we suspected that the .mdf file corrupted

Unfortunately, we don't have any backup.

Thanks for reply

|||

Can you try this trick:

Create a new 'dummy' database that has the same name as the old database, say 'TEST'

So now you have 2 files: test.mdf and test.ldf files

Stop SQL Server services and delete these files

Copy and rename your corrupted mdf,ldf files in their place

Restart the services and see what error message you get when SQL tries to read from the corrupted files that are now attached to the TEST db.

Then you can start the debugging 'process' based on error number

Cheers

|||Try this undocumented stuff provided by Kevin [MS].

==========
1. Back up the .mdf/.ndf files at first!!!

2. Change the database context to Master and allow updates to system tables:

Use Master
Go
sp_configure 'allow updates', 1
reconfigure with override
Go

3. Set the database in Emergency (bypass recovery) mode:

select * from sysdatabases where name = '<db_name>'
-- note the value of the status column for later use in # 6
begin tran
update sysdatabases set status = 32768 where name = '<db_name>'
-- Verify one row is updated before committing
commit tran

4. Stop and restart SQL server.

5. Call DBCC REBUILD_LOG command to rebuild a "blank" log file based on the
suspected db.
The syntax for DBCC REBUILD_LOG is as follows:

DBCC rebuild_log('<db_name>','<log_filename>')

where <db_name> is the name of the database and <log_filename> is
the physical path to the new log file, not a logical file name. If you
do not
specify the full path, the new log is created in the Windows NT system
root
directory (by default, this is the Winnt\System32 directory).

6. Set the database in single-user mode and run DBCC CHECKDB to validate
physical consistency:

sp_dboption '<db_name>', 'single user', 'true'
DBCC checkdb('<db_name>')
Go
begin tran
update sysdatabases set status = <prior value> where name = '<db_name>'
-- verify one row is updated before committing
commit tran
Go

7. Turn off the updates to system tables by using:

sp_configure 'allow updates', 0
reconfigure with override
Go
============|||

OK.

First off, I don't think I've posted those steps. I've probably posted similar for use in DIRE circumstances (like this one) where there is no backup, and data loss is acceptable.

The procedure above is primarily used for cases where you have only the MDF file and no log.

Attaching the database should not hang the system. It could make it busy for awhile, but not totally hang.

How long did you let the system go before giving up and canceling?

Please look in both the Windows Event Log and in the SQL errorlog files and post any related errors here.

You need to get the database attached to an instance in order to do anything with it. Your best bet is to put the files back in their original locations and just let it run its course. You might try putting the database in emergency mode (using the steps above) before putting the files back in place. Then the database wouldn't run recovery when the instance started up.

You could then run DBCC CHECKDB , and presuming that there are serious problems, you can then re-run the CHECKDB with REPAIR_ALLOW_DATA_LOSS, taking into consideration that the command means what it says: data will be lost.

Monday, March 12, 2012

How to Reboot a Clustered SQL Server Agent


If I am running SQL Server 2005 in a clustered environment, what is the safest way to restart the SQL server agent? It is currently running but I need to restart it for maintenance purposes.

Is the safeway way to restart is to login to the SQL Server Management Studio as the system administrator, select the SQL Server Agent object, right-mouse click and select "Restart?"

When you stop agent, all running jobs will stop. This may not be what you want. Other than that, you can stop the service via services manager or enterprise mgr.

|||

if you run SQL 2005 in a cluster environment .

i think you would better to manage the program via "cluster administrator"

So if you want to stop/restart the services running in cluster .you could choose the "cluster administrator"

Sunday, February 19, 2012

How to query for transaction's isolation level...

Hi all,
Is it any way to query a running transaction to see the isolation level it
is using? I'm debugging a mobile .net application that access a SQL 2K
database and I need to verify if it is running transaction on the desired
isolation level (read uncomitted). My idea is to run a test app that left a
transaction opened, and test the isolation level by running some query from
the QueryAnalyzer.
Any hint is welcomed
Thanks in advance
SammyThis is one of the rows from DBCC USEROPTIONS
"SammyBar" <sammybar@.gmail.com> wrote in message
news:%23Bt97iglGHA.4708@.TK2MSFTNGP04.phx.gbl...
> Hi all,
> Is it any way to query a running transaction to see the isolation level it
> is using? I'm debugging a mobile .net application that access a SQL 2K
> database and I need to verify if it is running transaction on the desired
> isolation level (read uncomitted). My idea is to run a test app that left
> a transaction opened, and test the isolation level by running some query
> from the QueryAnalyzer.
> Any hint is welcomed
> Thanks in advance
> Sammy
>
>|||Hi, Sammy
To determine the transaction isolation level currently set for a given
connection, execute the DBCC USEROPTIONS statement from that
connection.
Razvan|||> This is one of the rows from DBCC USEROPTIONS
but can I make a "DBCC USEROPTIONS" not for my own connection, but for
anoter process or spid?|||>> This is one of the rows from DBCC USEROPTIONS
> but can I make a "DBCC USEROPTIONS" not for my own connection, but for
> anoter process or spid?
Not that I know of. If you're interested in it for a specific procedure,
you could probably jam data into a table based on SPID at the beginning of
the proc, then you can query it for any active spids from other sessions.
However, if you're able to modify the proc to do this, you could probably
just check the proc manually to see if the default isolation level is being
overriden.
A|||In SQL Server 2005, the view sys.dm_exec_sessions (one of the replacements
for sysprocesses) shows the isolation level for every connection.
HTH
Kalen Delaney, SQL Server MVP
"SammyBar" <sammybar@.gmail.com> wrote in message
news:eGfdsQhlGHA.3528@.TK2MSFTNGP02.phx.gbl...
> but can I make a "DBCC USEROPTIONS" not for my own connection, but for
> anoter process or spid?
>

How to query for transaction's isolation level...

Hi all,
Is it any way to query a running transaction to see the isolation level it
is using? I'm debugging a mobile .net application that access a SQL 2K
database and I need to verify if it is running transaction on the desired
isolation level (read uncomitted). My idea is to run a test app that left a
transaction opened, and test the isolation level by running some query from
the QueryAnalyzer.
Any hint is welcomed
Thanks in advance
SammyThis is one of the rows from DBCC USEROPTIONS
"SammyBar" <sammybar@.gmail.com> wrote in message
news:%23Bt97iglGHA.4708@.TK2MSFTNGP04.phx.gbl...
> Hi all,
> Is it any way to query a running transaction to see the isolation level it
> is using? I'm debugging a mobile .net application that access a SQL 2K
> database and I need to verify if it is running transaction on the desired
> isolation level (read uncomitted). My idea is to run a test app that left
> a transaction opened, and test the isolation level by running some query
> from the QueryAnalyzer.
> Any hint is welcomed
> Thanks in advance
> Sammy
>
>|||Hi, Sammy
To determine the transaction isolation level currently set for a given
connection, execute the DBCC USEROPTIONS statement from that
connection.
Razvan|||> This is one of the rows from DBCC USEROPTIONS
but can I make a "DBCC USEROPTIONS" not for my own connection, but for
anoter process or spid?|||>> This is one of the rows from DBCC USEROPTIONS
> but can I make a "DBCC USEROPTIONS" not for my own connection, but for
> anoter process or spid?
Not that I know of. If you're interested in it for a specific procedure,
you could probably jam data into a table based on SPID at the beginning of
the proc, then you can query it for any active spids from other sessions.
However, if you're able to modify the proc to do this, you could probably
just check the proc manually to see if the default isolation level is being
overriden.
A|||In SQL Server 2005, the view sys.dm_exec_sessions (one of the replacements
for sysprocesses) shows the isolation level for every connection.
--
HTH
Kalen Delaney, SQL Server MVP
"SammyBar" <sammybar@.gmail.com> wrote in message
news:eGfdsQhlGHA.3528@.TK2MSFTNGP02.phx.gbl...
>> This is one of the rows from DBCC USEROPTIONS
> but can I make a "DBCC USEROPTIONS" not for my own connection, but for
> anoter process or spid?
>