Skip to main content

Posts

Showing posts from October, 2006

Copying Database Diagram from DB server to another ...

For some, working with Databases is fun and for others, it could possibly be a nightmare. Understanding the structure of a Database schema from the available documentation could spell doom for many developers. A picture is worth a thousand words. This golden saying applies aptly to Databases! Yes, often, a pictorial representation of a Database conveys more meaning about the Database Schema than the SQL scripts generated or other documentation that may be available. One of the first thing developers wants to do when starting work on a new project is to understand the Database schema. Sometimes, understanding a complex database schema can be simplified largely by a relationship diagram. The Database diagram tools in the SQL Server enable administrators and developers to create Database diagrams very easily. This article demonstrates an efficient way to move DB diagrams from one Database to another. We are going to use two sample Databases for this purpose. They are named PlayDB and Play

Do you think I will make it?

Approximately 20-25 days back I came to know about Community-Credit site and I started participating in it actively. See the below screenshot to know where I stand. FYI, Lorenzo Barbieri is maintaining his lead from day 1. For the past 10+ days I am maintaining the second position and just 4 days left to know who is the winner of this month. Do you think I can make it to the top? Technorati tags: Community-credit

Listing / Dropping ALL stored procedures from a database in SQL Server 2005

This was the question asked by a member here http://www.dotnetspider.com/qa/ViewQuestion.aspx?QuestionId=59232 Though I have answered there itself, thought I would document it here also for future reference. I) List all Stored procedures in a database: Select * from sys.procedures where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%' OR Select * from sys.objects where type='p' and is_ms_shipped=0 and [name] not like 'sp[_]%diagram%' Please note that I have added the 'NOT LIKE' part to get rid of stored procedures created during database installation. II) Delete all [user created] Stored procedures in a database: Select 'Drop Procedure ' + name from sys.procedures Where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%' This would list down all the user defined Stored procedure as 'Drop Procedure procedureName' in the result pane. Just copy-paste it into the query window

Brief Theoretical Knowledge about Table Partitioning

1. Partitioning is fully depended on Filegroups. 2. Start table partitioning as early as possible. So that huge data movement can be avoided later. 3. A file would be grouped to one and only Filegroups. Actually Filegroups improves database maintenance, performance and Online restore. 4. For your information, default Filegroup is always “primary filegroup“. If at all you don’t believe me! Create a dummy table something like this, Create Table Test ( sno int ) Go Now in your SQL Mgmt Studio, right click on that table and check the properties yourself. 5. All “System Objects” have to belong to PRIMARY Filegroup. 6. It’s recommended, to have all “User Objects” created in another Filegroup. 7. In SQL Server 2000, any user object can’t belong to more than one Filegroup. But it’s possible now in SQL Server 2005. That is, a table data can be partitioned and stored into multiple Filegroups. 8. If you have two large tables, put them into different Filegroups. Filegroups are recommended being on

Accessing a table in SQL Server 2005 (Schema related)

Recently in a discussion forum I came across this question "I have a small Doubt in SQL server. The database name is 'AdventureWorks' and the table name is 'Production.Culture'. What is the query to fetch records from that table." The answer to this is : Select cultureid, [name], modifiedDate from AdventureWorks.Production.Culture There was another member of the forum who was saying that we need to only use the below query: Select * from AdventureWorks. dbo.Production .Culture Please note that he has mentioned two Schema names (dbo and Production) in a single query. This query wouldn't work and I thought I would explain the concept of "Schemas" in SQL Server 2005 to him. In short, a) Schema is similar to Namespaces in .NET b) It helps in logical grouping of tables. c) To view all existing schema in a database, for example within AdventureWorksDB :: 1. Open ur SQL Mgmt studio 2. Go to AdventureWorks DB and expand it 3. Expand the Tables 4. Now jus

Find out the Second (2nd) Highest Salary ...

For past 15 days I am actively participating in the discussion forums of dotnetspider. Yesterday there was a question relating to SQL Server which seems to be asked in interviews very often. i.e., How to find out the 2nd highest salary of an employee? Thought I would give out an sample for those who are yet to find an answer for this. For that purpose I have given a table structure with few sample records inserted to it. -- Table Structure Create table employee ( [Name] varchar(20), Sal int ) Go -- Populate Sample Records Insert into employee values ('Vadivel', 80000) Insert into employee values ('Vel', 70000) Insert into employee values ('xxx', 40000) Insert into employee values ('Sneha', 60000) The Solution: Select top 1 [Name], Sal from ( Select Top 2 [Name], Sal from employee order by Sal Desc ) AS A1 Order by Sal Technorati tags: SQL , Databases , SQL Server , SQL Server 2005

Desi Search Engine ...

Guruji.com - India's local search engine! has been launched in Bangalore on 12th of this month. The site seems to be focused on Indian consumers. May be they wanna become Google of India! I tried out few searches - the results and performance are really impressive. The search strings which i tried are as follows: 1. Pizza Adyar 2. Verizon Guindy Quite a few of my search strings also failed. Its understandable as they are still in Beta! But I feel its definitely a good start. Guys use it and share your experience .... If you like to know more about the Investors, Management Team etc., check out this. Extract from TechTree : Gaurav Mishra, co-founder and coo, guruji.com explains, "90% of Internet search queries are local in nature, and guruji.com will deliver better search results than any other search engine in these instances. For example, if a user types a search "Pizza in Koramangala, Bangalore " or "Chinese restaurant Juhu, Mumbai" the user will be able

Google I'm Feeling Lucky :)

From a fellow MVP ( Harish Ranganathan ) I came to know about this interesting fact. Old News: If you search for "Failure" in Google and click on "I'm feeling lucky" button it would take you to President Bush's homepage :) Latest News: Now, interestingly, if you search for the word "Search" in Google and click on "I'm feeling lucky" button, it goes to Windows Live Search Page. Technorati tags: Google , Microsoft , Windows Live

Tip to prepare for interview -- Part II

This post is written having final year students in mind. The first part of this series! is here . So if at all you haven't read it before, I suggest you have a look at it also. Apart from your regular preparation for the final year exams and projects, it’s always better to do the following: 1. Spend time on group discussions 2. Work on Quantitative aptitude and reasoning questions again and again. Some of the famous authors in this topic are listed below for your easy reference. a. George Summers b. Shakuntala Devi c. R.S. Agarwal d. P.S. Agarwal e. Barrons GRE 3. Spend time on websites to know more about Interviews. For example: www.freshersworld.com 4. If you are informed by the company for an interview, collect data regarding the company (visit their website first without fail) 5. Prepare a write-up on your own vernacular. Try to translate it. Practice it in-front of your friends or your lectures or mirror and fine tune it. 6. Prepare a neat CV. Interview Telephonic: 1. Provide

Finding the File Size of Attachment in Javascript

<html> <head> <title>Check the Size of a File -- Javascript</title> <script language="JavaScript"> function CheckFileSize() { var objSize = new ActiveXObject("Scripting.FileSystemObject"); var strFileName = objSize.getFile(document.frmFileUpload.strFile.value); var SizeOfFile = strFileName.size; alert(SizeOfFile + " bytes"); } </script> </head> <body> <form name="frmFileUpload"> <input type="file" name="strFile"> <input type="button" name="btnSize" value="Show file size" onClick="CheckFileSize();"> </form> </body> </html> The above code snippet will work only if ActiveX is supported @ the client end.

Paging in SQL Server 2000 and 2005?

Abstract In this article I have discussed in detail about the easier way of paging records using SQL Server 2005. In the due course I have introduced the nuances of using TOP keyword and the cool enhancements added to it. Along with that I would show you how to use TOP command to do paging in SQL Server 2000, albeit at a performance loss, then show how the same result can be achieved with higher performance thanks to new features in SQL Server 2005. Introduction Databases products always attract me for many reasons. One simple reason is, .NET framework 1.0 was released and then in a short time its “version 1.1” has been released. If at all you are watching the market you would know by this time, few months back .NET Framework 2.0 has also been released. So what’s the point I am trying to make? The application layer or the front end layer changes very frequently and we need to be updating our self on a daily basis. That’s the pace of the technology either keep up or be left out :) On th