Whats New in SQL Server 2008 R2 CTP

September 22nd, 2009 govindsyadav 1 comment

Hi , this post is all about discussing the latest new features being embedded , released up with SQL SERVER 2008 R2 CTP .

We are attaching the complete powerpoint presentation , that we had made to describe all the new features of this 2008 R2 CTP Release .

If you do have any kind of querries regarding the same , feel free to ping us back and we will be more than happy to solve your querries .

VN:F [1.6.3_896]
Rating: 5.0/5 (1 vote cast)

Clearing the SQL Cache when Testing your TSQL in SSMS

September 21st, 2009 Neeraj Mathur No comments

SQL Server uses an intelligent caching system to enhance performance. If you run
frequent queries against a certain table, SQL Server will recognize that fact and
store the source (and result data) of those queries in its internal cache. By doing
so, future matching queries won’t need to look up this data until the next time it changes.

This functionality, while useful, can be confusing if you conduct your tests by running your queries from SSMS — some of your query information may be cached, so your queries will run faster the second time you execute them.

To ensure that you make valid comparisons that don’t return cached information, clear your cache each time you run the query . The following script does just this — first it drops caches, then it calls a CHECKPOINT to flush pending changes from memory to disk, and finally it clears any data that has been stored in memory:

1
2
3
4
5
6
DBCC FREESESSIONCACHE
DBCC FREEPROCCACHE
DBCC FREESYSTEMCACHE('ALL')
CHECKPOINT
DBCC DROPCLEANBUFFERS
GO -- Your query goes here
VN:F [1.6.3_896]
Rating: 0.0/5 (0 votes cast)

FILESTREAM feature is disabled in SQL Server 2008

September 21st, 2009 Sumit Gilhotra No comments

Today when i am working with SQL Server 2008 and doing some RnD … find a new feature FILESTREAM … found really interesting and want to do some testing work…when i tried to enable the FILESTREAM in my SQL Server 2008 ( as bydefault it is not enabled) by running this T-SQL Command

EXEC sp_configure filestream_access_level, 2

GO

RECONFIGURE

GO

Command(s) completed successfully.

After that when tried to create a database.. it shows error “FILESTREAM feature is disabled.”

After lots of attempts finds the resolution of this problem…go to this url

http://blogs.msdn.com/sqlserverstorageengine/archive/2008/03/03/filestream-configuration-and-setup-changes-in-sql-server-2008-february-ctp.aspx

Download filestream_enable.vbs .. enter your machine name & Sql Server Instance Name and run this file…FILESTREAM will enable …

if you required this file pls let me know will provide you.

after that when i try to create Database with Filestream enable access successfully created that with following script

CREATE DATABASE TestFSDB
 
ON
 
PRIMARY (
 
NAME = TestFSDB,
 
FILENAME = 'D:\Tempdb\FS\TestFSDB.mdf'
 
), FILEGROUP TestFSDBFS CONTAINS FILESTREAM(
 
NAME = TestFSDBFS,
 
FILENAME = 'D:\Tempdb\FS\TestFSDBFS')
 
LOG ON (
 
NAME = TestFSDBLOG,
 
FILENAME = 'D:\Tempdb\FS\TestFSDBLOG.ldf')
 
GO

if you still face any problem please let me know will be more then happy to help you.

VN:F [1.6.3_896]
Rating: 0.0/5 (0 votes cast)

Understanding the Null Coalescing Operator

September 21st, 2009 Neeraj Mathur No comments

C# language introduced some new syntax—the ?? operator, which is called the Null Coalescing Operator.

Let’s take a look at this operator in action. The expression z = x ?? y is roughly equivalent to the following code:

string tempX = x;     // Ensures thread safety by
                           // using a local variable.
if (tempX != null)
z = tempX;
z = y;

Note that the coalescing operator is thread-safe—it copies the reference to a local, temporary variable before making the null comparison. If the coalescing operator didn’t perform this step, it would be possible for another thread to modify the original reference between the comparison and the assignment.

VN:F [1.6.3_896]
Rating: 0.0/5 (0 votes cast)

Role Based Access Control (RBAC) Application.

September 21st, 2009 govindsyadav 3 comments

In this post we are going to discuss about creating RBAC applications . Before that , we will have a brief overview of RBAC.

What does R B A C mean .

R-Role

B-Based

A-Access

C- Control

So summing up , its all about implementing role based access control system in application . Now , we will see how to implement

this system and make use of it in our application . As , we all are familiar with Membership , Role , Profile Providers being available

in .Net 2.0 . Those role providers does provide the same functionality , but there are requirements some time to get more of them

so we will achieve those targets by using RBAC .

Say for Example , we are having roles being implemented in our application , like (admin , Hr , Senior HR , Trainee HR etc) ,

now in our application , we do want to implement such a functionality , where a role defined can perform certain access like

Senior HR can edit , update or delete the records while Junior HR can only ADD records and view records . Even going more deep , lets assume a scenario where on a certain form /view we want that a user with specific permission (access rights ) can only view a specific part of form while others cannot , that is a form is being displayed in a different-different way depending on the access rights of the user . So how to attain this .

We will attain this using RBAC Implementation .

For this , first of all we are going to create / define roles .

a. Super Admin

b. Admin

C. Manager

d .Operator

Now as , we do have a predefined set of roles who will be using our application . the next step is to identify objects of our application ex :

a. Invoice Master

b. Product Master

c. Customer Master

and so on …..

Now once object are being identified , the next step is to identify unique  actions ( activities)  which can be performed on all the objects ex:

a. Add

b. update

c. Delete

d. Moderate

e. Publish

and so on ……

The next step is to link these actions to the objects , that is making applicable pairs of objects and activities ex:

A. product master

  1. Add
  2. Update

B. Invoice Master

  1. Add
  2. Update
  3. Publish

and so on….

Here after next step is to define Permissions which is the most important step here , that is assigning the object –activity pair to roles ex:

A. Super Admin

All object – Activity Pair

B. Operator

  1. View Product
  2. Add Invoice

and so on ….

Save these role –object –activity pairs in a database table .

Now , Assign the roles to each user , ex;

John Smith

  1. Manager

Tim Uzzanti

  1. Operator

Jacob Sebastian

  1. Super Admin

and so on ….

So till this step , we do have a clear definition of user , his role and his role permissions . and most important the Object of Application

Now , when you authenticate the user , load its role – object –activity pair data into session, hash table , static object (depending on whatever frontend you use , web , desktop , mobile etc and what ever the best method to load this information as per the performance of your application ).

Here After you are ready to apply RBAC .

Now whenever an object of your application instantiates , just before that give a lookup to the role – object –activity pair corresponding to the object and fetch the permissions and apply them . ex:

The user logged in does not have Add Permission on Invoice Object , disable the Add Button .

btnAdd.Visible=User.HasPermission(Invoice.Add) ;

And it is done , RBAC is implemented .

I will be soon , posting the running code for this implementation  using Asp.net , Sql server 2005 and c# . Keep watching this post .

For any specific queries /suggestions ping me up and i will respond to them.

VN:F [1.6.3_896]
Rating: 5.0/5 (1 vote cast)