Skip to main content

Posts

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...

History of SQL Server ...

I suggest all SQL developers to have a look at http://SQLKnowledge.com . The site is rich with information on SQL Server and its really informative. I read the history of SQL Server from that site and here is the summary of it: 1. 1993 - SQL Server 4.21 for Windows NT 2. 1995 - SQL Server 6.0, codenamed SQL95 3. 1996 - SQL Server 6.5, codenamed Hydra 4. 1999 - SQL Server 7.0, codenamed Sphinx 5. 1999 - SQL Server 7.0 OLAP, codenamed Plato 6. 2000 - SQL Server 2000 32-bit, codenamed Shiloh 7. 2003 - SQL Server 2000 64-bit, codenamed Liberty 8. 2005 - SQL Server 2005, codenamed Yukon 9. Next release - codenamed Katmai (not confirmed ) Technorati tags: SQL , Databases , SQL Server , SQL Server 2005

About 'RESOURCE' Database in SQL Server 2005

1. 'Resource' Database is a new DB introduced in SQL Server 2005. Its shortly referred as 'RDB' . 2. Its an 'Hidden' and 'Read-only' DB. 3. You could find its 'mssqlsystemresource.mdf' file here -- C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data (If you have SQL Server 2005 installed in your box) 4. This is the database where all 'System objects' which belongs to ' Sys. ' Schema physically reside. i.e., has definition of all System objects. These 'System objects' (like, sp_help) logically appear in every other DB in the server. Schema -- It is similar to namespaces in .NET, it helps in logical grouping. Sys -- Is newly created schema in SQL Server 2005. All System Objects resides here. 5. If you run this below script from any of your SQL Server 2005 database it would return 1741 rows. Those are 'definitions' of ALL the system objects which actually reside in RDB . Select [name], object_definition(ob...

Creating our own 'Code Snippets' in Visual Studio .NET 2005

Code Snippets are useful in situations where you frequently implement the same code blocks in multiple places within your project. One could find all existing snippets for C# in this folder: C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C# If you want to create your own snippet which is not existing in the above path then do the following: 1. In Visual Studio.NET, Create a New Xml File. 2. Place the following XML code into that file: The root element for an code snippet is <CodeSnippet>. This would have two child elements <Header> and <Snippet> <?xml version= "1.0" encoding="utf-8" ?> <CodeSnippets xmlns = "http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format ="1.0.0"> <Header > <Title> Title of the Code Snippet would come here </Title> <Author> Vadivel Mohanakrishnan </Author> <Description> Describe it in detail here </Des...

SQL Server Configuration Manager ...

Though there are lots of articles on "SQL Server Configuration Manager" I thought I would put down few bulleted points on this topic for easy reference :) 1. In order to access SQL Server Configuration Manager do this: Start >> Programs >> Microsoft SQL Server 2005 >> Configuration Tools >> SQL Server Configuration Manager 2. Services pertaining to SQL Server would be available inside this tool under the heading "SQL Server 2005 Services". This is only for easy access, as these "Services" are still available (as it was all this days!) within Control Panel >> Administrative Tools >> Services . 3. This tool has Server and Client Network configuration services. Net libraries facilitate IPC (Interprocess Communication) exchange of information between Client and Server. In SQL 2005 we have four ways (Protocol names) by which IPC can take place. They are "Shared Memory", TCP/IP", "Named Pipes" and ...

Bill Gates tops again in Forbes 400 richest Americans ...

Forbes updated their list of the 400 richest Americans , and Bill G has maintained his TOP spot for the 13th or 14th continuous year. Few other notables rankings are listed below for quick reference :) #1 - Bill Gates - Microsoft - 53.0 billions #4 - Larry Ellison - Oracle - 19.5 billions #5 - Paul Allen - Microsoft - 16.0 billions #7 - Michael Dell - Dell Computer - 15.5 billions #12 - Sergey Brin - Google - 14.1 billions #13 - Larry Page - Google - 14.0 billions #15 - Steve Ballmer - Microsoft - 13.6 billions #24 - Carl Icahn - Financier - 9.7 billions #32 - Rupert Murdoch - News Corp - 7.7 billions #32 - Pierre Omidyar - eBay - 7.7 billions #38 - Sumner Redstone - Viacom - 7.5 billions #45 - Eric Schmidt - Google - 5.2 billions #49 - Steve Jobs - Apple/Pixar/Disney - 4.9 billions Technorati tags: Bill Gates , Microsoft , Forbes

Free eBook on Visual Studio .NET Tips and Tricks

If you are a .NET developer then you should have a look at this eBOOK which talks about VS.NET tips and tricks. Visual Studio .NET Tips and Tricks explains how to use VS.NET efficiently. Organized into short and easy-to-grasp sections, and containing tips and tricks on everything from editing and compiling to debugging and navigating within the VS.NET IDE, this book is a must-read for all .NET developers, regardless of expertise and whether they program in C#, VB.NET, or any other .NET language. This book covers the Visual Studio .NET 2002, 2003, and 2005 Beta 1 releases. I got registered myself with the site and download the PDF for free. Its really worth our time. Technorati tags: Visual Studio .NET , Microsoft , InfoQ , Tips and Tricks

Suckerfish Dropdowns ...

The original Suckerfish Dropdowns are pretty popular for implementing lightweight, accessible CSS-based dropdown menus that accommodated Internet Explorer by mimicking the :hover pseudo-class. Well now they're back and they're more accessible , even lighter in weight (just 12 lines of JavaScript), have greater compatibility (they now work in Opera and Safari without a hack in sight) and can have multiple-levels. It can be adapted to build menus dynamically. Technorati tags: Suckerfish , CSS , Javascript , Dynamic Menus