Thursday, October 14, 2010

Exploring Database Backup Compression in SQL Server 2008

http://www.mssqltips.com/tip.asp?tip=1513

Tuesday, October 12, 2010

Cost Comparison on Cursor Location

Client-Side Cursors

Client-side cursors have the following cost benefits compared to server-side cursors:

Higher scalability:
Faster scrolling:
Highly portable:

Client-side cursors have the following cost overhead or drawbacks:
Higher pressure on client resources:
Support for limited cursor types:
Only one active cursor-based statement on one connection



Server-Side Cursors
Server-side cursors have the following cost benefits:

Multiple active cursor-based statements on one connection:
Row processing near the data:
Less pressure on client resources:
Support for all cursor types:

Server-side cursors have the following cost overhead or disadvantages:

Lower scalability:
More network round-trips:

Cursor Type (SQL Server )

Keyset-Driven Cursors


Dynamic Cursors

Forward-Only Cursors:

1. operate directly on the base table
2. suppport DML operations
3. support forward scrolling only (FETCH NEXT)
4. Fast_Forward (forward_only + read_only cursor)

Static Cursors:

1. operate on the snapshot in the tempdb database.
2. data is retrived from the underlying table(s) when the cursor is opened.
3. support all scrolling options: FETCH FRIST, FETCH PRIOR, FETCH LAST, FETCH ABSOLUT n, and FETCH RELATIVE n.
4. read-only, changes (DML ) made to the underlying table(s) are not reflected in the cursor.

JDBC and JDBC Architecture

Layers of the JDBC Architecture




Type 1 JDBC-ODBC Bridge.



Type 2 JDBC Architecture



Type 3 Java to Network Protocol Or All- Java Driver.



Type 4 Java to Database Protocol.



http://www.roseindia.net/jdbc/jdbc.shtml

http://www.roseindia.net/jdbc/understanding-the-jdbc-architect.shtml

Client-side VS Server-side Cursors in Microsoft world

http://msdn.microsoft.com/en-us/library/aa266531(VS.60).aspx

Friday, October 8, 2010

Alter user with must_change in SQL Server 2005

Open the management studio and connect to the server with sufficient rights
start a blank query
run "ALTER LOGIN X WITH PASSWORD = 'Y' UNLOCK" (replace X & Y with username and password of course)
By following the above steps you should now be able to go back to the user and uncheck the checkboxes without any trouble.

To make the changes without using the management studio you can run the following in a query..

To change the password and keep the MUST_CHANGE flag: ALTER LOGIN X WITH PASSWORD = 'Y' UNLOCK MUST_CHANGE

To uncheck the checkboxes for expiration and/or policy (change "OFF" to "ON" to check): ALTER LOGIN X WITH CHECK_EXPIRATION = OFF ALTER LOGIN X WITH CHECK_POLICY = OFF



Example:

1.ALTER LOGIN afm WITH CHECK_EXPIRATION = on

2.ALTER LOGIN afm WITH CHECK_POLICY = on

3.ALTER LOGIN afm WITH PASSWORD = '1.oracle' UNLOCK MUST_CHANGE

4. To uncheck the checkboes after user change his password

Tuesday, September 21, 2010

Restriction login application trigger of SQL Server 2005/8

Get Host Name from Client:

select HOST_ID(),HOST_NAME(),SUSER_NAME(),SUSER_SNAME()

------------------------------------------------------------------

Get Host Name from Client IP :

SELECT CONNECTIONPROPERTY('net_transport') AS net_transport,
CONNECTIONPROPERTY('protocol_type') AS protocol_type,
CONNECTIONPROPERTY('auth_scheme') AS auth_scheme,
CONNECTIONPROPERTY('local_net_address') AS local_net_address,
CONNECTIONPROPERTY('local_tcp_port') AS local_tcp_port,
CONNECTIONPROPERTY('client_net_address') AS client_net_address

Or

SQL 2005

SELECT *
FROM sys.dm_exec_connections
WHERE session_id = @@SPID

--------------------------------------------

CREATE TRIGGER [RestrictSSMSLogIn]
ON ALL SERVER WITH EXECUTE AS 'AppUser'
FOR LOGON
AS
BEGIN
IF ORIGINAL_LOGIN()= 'AppUser' AND
(SELECT TOP 1 Program_Name
FROM sys.dm_exec_sessions
WHERE is_user_process = 1
AND original_login_name = 'AppUser'
Order By Session_Id Desc)
<>'Microsoft SQL Server Management Studio' and
(SELECT TOP 1 Program_Name
FROM sys.dm_exec_sessions
WHERE is_user_process = 1
AND original_login_name = 'AppUser'
Order By Session_Id Desc)<> 'Microsoft SQL Server Management Studio - Query'

ROLLBACK;

END
GO