20.9.10

My session at Sydney Microsoft Office

"Presenting a session in Microsoft" It's my greates dream in my life.

In one word, “It’s a Marvellous evening”. Interesting part is, Adam Cogan is my fellow speaker. Working in Microsoft as a Technical Architect and as a Microsoft Regional Director too :-)

Presented my session in Microsoft office, Attended Adam’s session, Techie talks with hard core developers and finally my session is recorded and it will published soon in Microsoft portal.

To be frank, No words to express my joy…. In presenting an evening session to the techie experts in Microsoft, Sydney office.

Sydney Microsoft Office


Speaker’s desk


Preparing my laptop for the presentation

Oops, very big screen…


Started my session with the query, “How a DBA can achieve Enterprise wide Compliance standard?”

Practical demos

Adam cogan’s session on Sharepoint 2010 Wiki Vs Sharepoint 2010 Blog


My kid playing in Microsoft office

My wife and Kid…in MS office

Front row : My wife, Myself, Adam Cogan and a 22 year experienced Microsoft developer
Back row : Hard core techies

Cheers,
Venkatesan Prabu .J

19.9.10

My Session in Sydney SQL User group

My presentation @ Greater Sydney.....

At last, it’s my dream evening. I gave a presentation to the SQL Server Gurus in Sydney…
Almost most of the attendees were having more than 15 years of experience in SQL Server :-)

They live with SQL Server technology. It was a pleasant moments and I have learnt a lot on meeting those technology Gurus.

Intro about me by Grant paisley (SQL Server MVP and Director of Angry Koala pty ltd)


My presentations starts with the query…. Can a DBA manage 100 Servers in One go???????


Discussion on Policy Creation and deployment Strategies

Practical demo on Microsoft in-built policies


My favourite pic (With my 2009 MVP Award)… Query section..


Thank You slide



My Fellow speaker Darren Geros (22 years in IT, Director of NSI Technology Pty Ltd, Director AVOGA Pty Ltd)


Got a fantastic response from the audience and it’s too nice to see some smile faces


Thanks and Regards,
Venkatesan Prabu .J

17.9.10

Dotnet and SQL Job in Hyderabad

I got this from one of my email... May be useful to some one... who really need it...

Urgent requirement for ASP.Net professionals with a minimum experience of 3yrs in relevant field in Hyderabad.

Skills
ASP.Net 35 frame work, Ajax, sql.server 2005/2008, WCSF, classic ASP

Package: 2.4L - 3.0L
Location: Hyderabad

If anybody is interested Send your resumes to bobby.simson13@gmail.com

Cheers,
Venkatesan Prabu .J

16.9.10

Steps in loading your web contents - About browsers


Have you questioned yourself, why my browser is too slow ?????

To load the web page, your browser will traverse 11 sub systems or steps to display your web content :-) Interesting right !!! Let’s see,

1. Network – First subsystem which is responsible for client / server interaction. This relies on the hosted server’s performance and individual user’s network traffic.
2. HTML – Followed by the HTML – sub system. This allows you to download the HTML content from the server and structured it back to the client machine.
3. CSS – Cascade Style sheet, this will provide you the customised colouring and structure to the content. The details will be collected and it will be used later (In point 8).
4. Collections – Accessing metadata information related to your HTML. This guy will take care of Segregating your head and body contents separately.
5. Java script – Client side scripts which will execute based on the user’s action.
6. Marshalling – Java script engine can’t directly interact with the browser. Marshalling is a special communication layer between JavaScript engine and your browser.
7. DOM API – Special API’s responsible for interaction between JavaScript engine and your browser.
8. Formatting – All your objects will be formatted based on the CSS information collected.
9. Block building – Your objects will be segregated as separate blocks
10. Lay out formation – Now, depends on your Web parts or Frames or div tag or Table. Your layouts will be formed.
11. Image Rendering – Rendering of images (or) drawing to the screen through CPU or GPU.

Cheers,
Venkatesan Prabu .J

8.9.10

SQL Profiler InputBuffer events in SQL Server

As a DBA, sometimes you need to identify the last execution happened or happening in your server. What you will exactly do?
1. Start your profiler and check it.
2. Check the process info for the server processes running.
3. In SQL Server 2008, you can opt Activity Monitor.

What else?????????

Here is another method using queries? If you got the spid then DBCC Inputbuffer command will provide you the last execution command of your user. Let's see how?????


Get the current session id

SELECT @@SPID
The output is, 51

Let's execute the below query now,

CREATE TABLE VENKAT_TABLE (Col1 int)
GO
DECLARE @i int;
SELECT @i = 0
BEGIN TRAN
SELECT @i = 0
WHILE (@i < i =" @i">



Now, open another session or connection, and execute the command

DBCC INPUTBUFFER (51);

You will get the last statement executed by the particular session user.

Usually, we will get confused on seeing the sequence of below statements in our profiler.

create table #tmpDBCCinputbuffer ([Event Type] nvarchar(512), [Parameters] int, [Event Info] nvarchar(512))
insert into #tmpDBCCinputbuffer exec ('DBCC INPUTBUFFER(51)')
select [Event Info] from #tmpDBCCinputbuffer


It's nothing but the in-house or profiler query itself. The above statements were used to fetch the latest statements of your server processes.

Cheers,
Venkatesan Prabu .J

Like operator on a column name in SQL Server

To: jvprabhusanthi@gmail.comSubject: Help...Urgent
Hi Prabhu,

i need urgent help from you for sql script.
i have field called "Notes" in table ABC and have another table called XYZ.
XYZ table has five fields 1,2,3,4,5
the requirement is :

select * from abc
where 1=1
and abc.notes like '%xyz.1%'
and abc.notes like '%xyz.2%'
and abc.notes like '%xyz.3%'
and abc.notes like '%xyz.4%'
and abc.notes like '%xyz.5%'

did you understand?
notes field has some long strings... xyz table clumns string should match with that notes from the abc table.
how do i write the sql script.
becoz i have nearly 2000 records in the table.. can you help out plz....
its urgent.
thanks in advance
pinky


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

It's a very usual question. How to use "Like operator on a column" -> We should use inner join on TableA.Column_Name like TableB.Column_Name


Let's see a small example to understand a little bit.


DROP TABLE PINKY1
DROP TABLE PINKY2

GO
CREATE TABLE PINKY1(NOTES VARCHAR(100))
INSERT INTO PINKY1 VALUES('VENKAT')
INSERT INTO PINKY1 VALUES('VENKATESAN PRABU')
INSERT INTO PINKY1 VALUES('rENKAT')
INSERT INTO PINKY1 VALUES('AENKAT')
INSERT INTO PINKY1 VALUES('AENKAT')
INSERT INTO PINKY1 VALUES('zxNKAT')
INSERT INTO PINKY1 VALUES('zxNKAT')
INSERT INTO PINKY1 VALUES('zxNKAT')
INSERT INTO PINKY1 VALUES('VERESEAEz')

GO
CREATE TABLE PINKY2(VAL1 VARCHAR(100),VAL2 VARCHAR(100),VAL3 VARCHAR(100),VAL4 VARCHAR(100),VAL5 VARCHAR(100))
INSERT INTO PINKY2 VALUES('VE%','%RE%','%SE%','%AE%','%E_')
INSERT INTO PINKY2 VALUES('BE%','%RE%','%SE%','%AE%','%E_')
INSERT INTO PINKY2 VALUES('SE%','%RE%','%SE%','%AE%','%E_')
INSERT INTO PINKY2 VALUES('DE%','%RE%','%SE%','%AE%','%E_')

GO

SELECT * FROM PINKY1 INNER JOIN PINKY2 ON NOTES LIKE VAL1
WHERE NOTES LIKE VAL2 AND NOTES LIKE VAL3 AND NOTES LIKE VAL4 AND NOTES LIKE VAL5


Cheers,

Venkatesan Prabu .J

7.9.10

All about user creation in SQL Server

Creating a new user in SQL Server:


Goto SSMS -> New User. Provide your user name, in my case its sample_user

Choose the authentication and choose the default database.



Default database indicates the database to which the user is having the access. In the next page, you can specify the level of access to the user. The next drop down is Default language -> I have made it as default and it's English.

Arabic, Brazilian, British English, Bulgarian, Croatian, Czech, Danish are some of the languages listed.




In the next window, you can specify the role of the user and it's server role. I have informed that, this person is a sysadmin and public too.


Next option is "User Mapping", here all the database will be listed. You can specify the level of access to be provided to this user for each database.


I do not want to provide any other access to this user except "VenkatDB".
Next screen is securables, you will have list of objects like Server, Endpoints and Logins.
You can choose the object on which you want to provide or deny access.
For example, I have selected Server -> Select an option "Create any database" and -> Select deny option. Here, we have restricted the user to create any database. Still, he is a sysadmin but he can't create any database.
The final page is status. It will define the current state of the user.

Now, let's move to our actual topic.
How to prevent access to a database for a particular SQL Login user????
Consider am having a user who is having access to multiple databases? I want to restrict the user not to use "VenkatDB" - > A specific database.
Now, you need to first make the user as public.



Provide necessary access level in the database level. Make the user as public for that specific database. Now click "OK". Reopen the login page for that particular user. "VenkatDB" is disappeared.

Now, I am trying to access the objects in the database. Below is the message received.
" The server principal "venkat" is not able to access the database "VenkatDB" under the current security context. "
Cheers,
Venkatesan Prabu .J

Database size in Express editions

SQL Server 2005 Express editions - Database size is 4 GB
SQL Server 2008 Express editions - Database size is 4 GB
SQL Server 2008 R2 Express editions - Database size is 10 GB

Cheers,

Venkatesan Prabu .J

http://venkattechnicalblog.blogspot.com/

Check the Updates in our machine

This one is pretty interesting findings, I found the check box "Show Updates" in the Add or Remove Program.

On selecting the check box, you will see a fantastic difference in listing the installed softwares.
It's a tree nature display which will give the information like which one is the master one and what all the patches applied on it.


It's a fantastic feature and I found it today!!!!! Eurekhaaaaaaaaaaaaaaaa
Cheers,
Venkatesan Prabu .J

Select Statements to access stored procedures

Is it possible to use the select statement to access stored procedures?????

In one of the difference between functions and stored procedures is, we can use the "select"
statement in functions whereas we can't use the same in stored procedures.

Can we make this statement false????? Not completely but a little bit.

Before that, am trying to create a Linked server.

Goto SSMS -> Your DB Server -> ServerObjects -> Linked Server - > Create new Linked Server.


You will get a message box to type your Linked server. You need to provide the servername.

Specify whether it's SQL Server or not. If it's not SQL Server, provide necessary details to connect it.

The second window is authentication, you need to specify the credentials used to access the Linked Server.


The third window specifies the options to be provided for the Linked server. If everything is good. Click "Ok" button.

Now, your Linked Server is created.

Now, you can see your catalogs listed under the Linked Server.

Now, am trying to access the Linked Server's table,
SELECT * FROM LinkedServer.VENKATDB.dbo.VENKAT_TABLE
Awesome,

Am able to see my data.


Goto your Linked Server query window and create a procedure (use the below code)

DROP TABLE VENKAT_TABLE_LINKED
CREATE TABLE VENKAT_TABLE_LINKED (ID INT)
INSERT INTO VENKAT_TABLE_LINKED VALUES (1)
INSERT INTO VENKAT_TABLE_LINKED VALUES (2)
INSERT INTO VENKAT_TABLE_LINKED VALUES (3)
INSERT INTO VENKAT_TABLE_LINKED VALUES (4)
GO

DROP PROCEDURE VENKAT_PROCEDURE
GO
CREATE PROCEDURE VENKAT_PROCEDURE
AS
BEGIN
SELECT * FROM VENKAT_TABLE_LINKED
END
GO
EXEC VENKAT_PROCEDURE
GO

Now, your procedure is created in the Linked server and am trying to access that procedure from the actual server using select statement. Le's see how to do it.

This can be achieved using OpenQuery statement.

SELECT * FROM OPENQUERY ([LinkedServerName],'MASTER.DBO.VENKAT_PROCEDURE')

So, the statement is wrong :-)
The actual statement is, "Stored procedures can't use Select statement in it's own server"
Hope, you all agree with my statement.
Cheers,
Venkatesan Prabu .J

6.9.10

Linked servers in SQL Server

Linked Server -

It's quite a different area, which I would like to concentrate more. What's this???? linked server......

Accessing the resource in the other server can be achieved using Linked server. Considering am having a server named "ServerA" and I would like to grab some data from the remote server named "ServerB". In that case, we need to create a linked server. In our scenario, the linked server is "ServerB".

Let's see, How to link it? How to access the data?

Goto SSMS -> Your DB Server -> ServerObjects -> Linked Server - > Create new Linked Server.

You will get a message box to type your Linked server. You need to provide the servername.

Specify whether it's SQL Server or not. If it's not SQL Server, provide necessary details to connect it.

The second window is authentication, you need to specify the credentials used to access the Linked Server.



The third window specifies the options to be provided for the Linked server. If everything is good. Click "Ok" button.


Now, your Linked Server is created.


Now, you can see your catalogs listed under the Linked Server.




Now, am trying to access the Linked Server's table,
SELECT * FROM LinkedServer.VENKATDB.dbo.VENKAT_TABLE

Awesome,
Am able to see my data.


Cheers,
Venkatesan Prabu .J

SQL Server installation issue with Windows XP sp3

I happened to install SQL Server in Windows XP sp3 version. Oops, I couldn't make it out.

1. Am facing issue with MSXML6.

2. Because of the above point, workstation components and Database services were not installed in my machine.

Reason for this issue:

MSXML6 is trying to change the language settings of WindowsXP sp3 which it couldn't succeed. So the installation is failing. Looks like, it's a well know bug.

Just checking for the workaround, I found the below blog which may be useful for you. Please check it out,

http://sqlblog.com/blogs/aaron_bertrand/archive/2009/02/20/the-xp-sp3-msxml6-sp2-sql-server-debacle.aspx

Cheers,
Venkatesan Prabu .J

5.9.10

Format files in SQL Server

For many years, I used to think about writing an article on Format files. I got shocked on seeing a procedure which is using format file and I am not aware of this area. Anyway, Learning starts or goes only if we don't know something right!!!!

Come one........Let's learn something...........

BCP - Bulk copy program

1. It's a utility to copy the data in bulk.

2. Data from files (or) to files in a specific format can be achieved using this BCP.

Format file:

1. If we want to read a file, it's very hard for SQL Server to read the file and store it in the database. Yes, we can store it but it will varchar field in the database.

2. To inform SQL Server about the datatype in the files. We use the Format file.

3. The Format file will tell you that, the file holds integer value, datetime field value with length 10 etc..,

How to create a Format file????? Let's see the below example to understand it.

Am having a table named Venkat_table



Below is the command to get the Format file,

bcp Venkat_Table format nul -S servername -T -n -f C:\Venkat_TableFormat.fmt

The Syntax is like, BCP DatabaseName.Ownername.ObjectName format nul -S servername -T -n -f formatfilename

nul - If there is no data file name to load. Here, we are fetching data from the table.
-T - Indicates trusted authentication or else -U and -P should come (SQL Server authentication)
-n - Indicates native data type. We will discuss more below.
-f - Informing the format file

We should go to the Windows command prompt and execute the above command, a file will be generated in the desired location.

On opening the Format file, you will get the below details.


Here is a generic details to understand the format file.
bcp Venkat_Table format nul -S servername -T -c -f C:\Venkat_TableFormat.fmt
-C indicates the type of columns to be assumed. C indicates the char type. In the below pic, you can see the datatypes were located as character datatype. If it's -n, then the datatype is native datatype.
Cheers,
Venkatesan Prabu .J

My T-SQL Gallery @code.msdn.microsoft


Created my own T-SQL Gallery in Microsoft site. Do visit the same and share your feedback,

http://code.msdn.microsoft.com/VenkatSQLSample/Thread/List.aspx

Thanks and Regards,
Venkatesan Prabu .J

SQL Server Interview questions - Part 1

What is the significance of NULL value and why should we avoid permitting null values?
Null means no entry has been made. It implies that the value is either unknown or undefined.We should avoid permitting null values because Column with NULL values can't have PRIMARY KEY constraints. Certain calculations can be inaccurate if NULL columns are involved.

What is SQL whats its uses and its component ?
The Structured Query Language (SQL) is foundation for all relational database systems. Most of the large-scale databases use the SQL to define all user and administrator interactions. It enable us to retrieve the data from based on our exact requirement. We will be given a flexibility to store the data in our own format.


The DML component of SQL comprises four basic statements:
* SELECT to get rows from tables
* UPDATE to update the rows of tables
* DELETE to remove rows from tables
* INSERT to add new rows to tables


What is DTS in SQL Server ?
Data Transformation Services is used to transfer the data from one source to our required destination. Considering am having some data in sql server and I need to transfer the data to Excel destination. Its highly possible with dialogue based tool called Data Transformation services. More customization can be achieved using SSIS. A specialized tool used to do such migration works.


What is the difference between SQL and Pl/Sql ?

Straight forward. SQL is a single statement to finish up our work.Considering, I need some data from a particular table. “Select * from table” will fetch the necessary information. Where as I need to do some row by row processing. In that case, we need to go for Procedural Logic / SQL.

What is the significance of NULL value and why should we avoid permitting null values?
Null means no entry has been made. It implies that the value is either unknown or undefined.We should avoid permitting null values because Column with NULL values can't have PRIMARY KEY constraints. Certain calculations can be inaccurate if NULL columns are involved.

Difference between primary key and Unique key?
Both constraints will share a common property called uniqueness. The data in the column should be unique. The basic difference is,
· Primary key won’t allow null value. Whereas, unique key will accept null value but only one null value.
· On creating primary key, it will automatically format the data inturn creates clustered index on the table. Whereas, this characteristics is not associated with unique key.
· Only one primary key can be created for the table. Any number of Unique key can be created for the table.

Select Statement in SQL Server

Select Statement in SQL Server

String Functions in sql server

String Functions in sql server
Substring/Len/replace/Ltrim/Rtrim

SQL Server Interview Question - Part 2

What is normalization?

Normalization is the basic concept used in designing a database. Its nothing but, an advise given to the database to have minimal repetition of data, highly structured, highly secured, easy to retrieve. In high level definition, the Process of organizing data into tables is referred to as normalization.


What is a stored procedure:
Stored procedures are precompiled T-SQL statements combined to perform a single task of several tasks. Its basically like a Macro so when you invoke the Stored procedure, you actually run a set of statements. As, its precompiled statement, execution of Stored procedure is compatatively high when compared to an ordinary T-SQL statement.


What is the difference between UNION ALL Statement and UNION ?
The main difference between UNION ALL statement and UNION is UNION All statement is much faster than UNION,the reason behind this is that because UNION ALL statement does not look for duplicate rows, but on the other hand UNION statement does look for duplicate rows, whether or not they exist.

Example for Stored Procedure?
They are three kinds of stored procedures,1.System stored procedure – Start with sp_2. User defined stored procedure – SP created by the user.3. Extended stored procedure – SP used to invoke a process in the external systems.Example for system stored proceduresp_helpdb - Database and its propertiessp_who2 – Gives details about the current user connected to your system. sp_renamedb – Enable you to rename your database


What is a trigger?

Triggers are precompiled statements similar to Stored Procedure. It will automatically invoke for a particular operation. Triggers are basically used to implement business rules.


What is a view?
If we have several tables in a db and we want to view only specific columns from specific tables we can go for views. It would also suffice the needs of security some times allowing specfic users to see only specific columns based on the permission that we can configure on the view. Views also reduce the effort that is required for writing queries to access specific columns every time.


What is an Index?
When queries are run against a db, an index on that db basically helps in the way the data is sorted to process the query for faster and data retrievals are much faster when we have an index.


What are the types of indexes available with SQL Server?

There are basically two types of indexes that we use with the SQL ServerClustered -

1. It will format the entire table, inturn physically sort the table.

2. Only one clustered index can be created for a table.

3. Data will be located in the leaf level.

4. By default, primary key will create clustered index on the table.

Non-Clustered Index

1. It wont touch the structure of the table.

2. It forms an index table as reference to the exact data.

3. A reference to the data will be located in the leaf level.

4. For a table, we can create 249 non clustered index.

Happy Learning!!!
Regards,
Venkatesan Prabu .J

SQL Interview question

Extent Vs Page?

Pages are low level unit to store the exact data in sql server. Basically, the data will be stored in the mdf, ldf, ndf files. Inturn, pages are logical units available in sql server.The size of the page is 8KB.

Eight consecutive pages will form an extent 8 * 8KB = 64KB.

Thus I/O level operation will be happening at pages level.The pages will hold a template information at the start of each page (header of the page).

They are,

1. page number,

2. page type,

3. the amount of free space on the page,

4. the allocation unit ID of the object that owns the page.

Extents will be classifed into two types,

1. Uniform extents

2. Mixed extents

Uniform Extents:It occupied or used by a single object. Inturn, a single object will hold the entire 8 pages.Mixed

Extents:Mulitple objects will use the same extent. SQL Server will allow a max of eight objects to use a shared extent.

Property of SQL Server :Initally if an object is created, sql server will allocate the object to the mixed extent and once if the size reaches 8 pages and more... immediately, a new uniform extent will be provided for that particular object.

Herecomes, our fragmentation and reindexing concepts.

Best Joke - Enjoy it

Best Joke - Enjoy it