How to write an insert statement for a table which has only single column and that column is auto incremented ?

Hello friends,
Recently a question asked to my friend in an interview “How to write an insert statement for a table which has only single column and that column is auto incremented?”
So here is the answer for it with sample
DECLARE @tblTest AS TABLE (id INT IDENTITY)
INSERT INTO @tblTest DEFAULT VALUES
INSERT INTO @tblTest DEFAULT VALUES
INSERT INTO @tblTest DEFAULT VALUES
INSERT INTO @tblTest DEFAULT VALUES
INSERT INTO @tblTest DEFAULT VALUES
SELECT * FROM @tblTest
But I don’t know what will be the use of this table?

Enjoy Query
Thanks & Regards
Rajat Jaiswal

Advertisements

Create Thumbnail on the fly by simple step

Dear All,

 Many times we require thumbnail image on the fly. ASP.Net provides an easy way by which we can create thumbnail.

I am showing basic steps by which we can create thumbnail. Asp.net provides “System.Drawing.Image “namespace which having property “GetThumbnailImage” by which we can get Thumbnail image. It’s a simplest way to get a thumbnail. Below is the code written in VB.NET by which we upload an image, save image & create thumbnail and save thumbnail with thumbnail prefix.

Protected Sub Unnamed1_Click(ByVal sender As Object, ByVal e As EventArgs)

Try

 If Me.FileUpload1.FileName.Trim <> String.Empty AndAlso Me.FileUpload1.FileContent.Length > 0 Then

Dim strUploadPath As String = Server.MapPath(“images”)

Dim strFileName As String = Me.FileUpload1.FileName FileUpload1.SaveAs(strUploadPath & “\” & strFileName)

 Dim img1 As System.Drawing.Image = System.Drawing.Image.FromFile(strUploadPath & “\” & strFileName)

Dim thumbNail As System.Drawing.Image = img1.GetThumbnailImage(100, 100, Nothing, IntPtr.Zero) thumbNail.Save(strUploadPath & “\thubmnail_” & strFileName)

 Me.imgActual.ImageUrl = “~/images/” & strFileName

Me.imgThumb.ImageUrl = “~/images/” & “thubmnail_” & strFileName

End If

Catch ex As Exception

 End Try

End Sub

Thumbnail image by indiandotnet

 Enjoy programming.

Thanks & Regards

 Rajat Jaiswal

Project List on which we will work in future

Dear Friends,

 Merry Christmas!

I Hope you are enjoying  the holidays.

 After seeing the market trend and requirements I am interested in making following projects which will help me and other friends to understand basic project development and use latest technologies with some productive output.

 In coming up sessions i am going to use this project topic and create sample with latest technologies like Silverlight, Windows phone 7, VS 2010 etc.

 So here we go

 1) College Management

 2) School Management

3) Job Portal

 4) Forums

5) Blog

6) Employee Management

7) Bug Tracker

8) Time Sheet

9) Address Book

10) Project Management

11) Survey engine

 12) Stock Manager

13) Property Broker

14) Shop Management

15) Matrimonial

 16) Social Networking

17) Hotel Management

 18) Inventory Management

19) Accounting

20) Transport Management

21) Hospital Management

22) Ecommerce

Etc are the project list on which I will work in future to enhance my knowledge with productive work.

I will share code base and case study also in future

Hope you like it Once again wish you Merry Christmas.

 Thanks

 Rajat Jaiswal



Spell Cheker with VS 2008 ASP.NET OR HTML Application

Dear All,

Although I tried all the times to improve myself in all stream and English communication is one of the key points.

 I know I do lot of mistake in writing most of the time spell mistake. I would like to thank Mikhail Arkhipov who provided spell checker add ins with VS 2008 which help me to reduce spell mistake in my HTML & ASP.NET application. Many thanks to Mikhail Arkhipov. You can read more about VS 2008 spell check Add Ins from below Link http://blogs.msdn.com/b/webdevtools/archive/2008/11/29/spell-checker-update-2-2-full-support-for-vs-2008-sp1-simpler-setup-and-a-few-bug-fixes.aspx

And you can download VS 2008 spell checker Add INS from below link

 http://visualstudiogallery.msdn.microsoft.com/en-us/2f3d691d-8838-4d84-ad64-44a02db37e30

Once again many thanks to Mikhail Arkhipov.

 Thanks & Esteemed Regards

 Rajat Jaiswal

Database designing best Practices

Hello friends,
Designing database is one of the most interesting works but on the same time it should be proper because it is base of any business application. We should follow Microsoft best practices while designing the database. Here I am with a simple database design (Address book) concept. I will try to put my best to use Microsoft best practices while designing database. I know you are thinking Address book is so much easy to design, so my answer is yes you are right you can design database easily but using Microsoft best practices it bit more important and I am trying for those best practices.
So first best practice is
1) Define proper  data type :-
Most of the time we design database but we ignore proper database but it should not because when you talking for very large scale database application (VLSDB)  then wrong data type will give you space problem. According to best practices choose smallest data type first (if it fit in your requirement).We understand this by an example suppose you designed a table with name “seed Data” in which column with name lngId having data type float and float consume 8 bytes and if the seed data cannot exceed more than 10 rows then we should use Tinyint data type instead of float data type because tinyint consume only 1 byte.
2) Define proper Primary & Foreign key:-
According to best practices we should make database normalized and for normalized database we should create proper Primary & Foreign keys. By creating proper primary & foreign keys we get two advantage 1) data anomalies chances reduce we get fast response as well after defining primary key (because cluster index created on primary key)
3) Define proper constraints :-
Microsoft best practices also suggest defining proper constraints for column like not null, unique key constraint on columns so that data anomalies will reduce and we get proper data.
4) Define partition :-
If your database is going to be very large then define proper partition both horizontally & vertically.
5) Normalization: – Database should be proper normalized.
In our Address Book database example we have categorized the data table in 3 categories 
1) Lookup table having prefix “lku”
The lookup table is mainly for seed value or we can say this table contains all the data which just act like pre pop data. We have following tables for our Address book
lkuCountryMaster,lkuStateMaster,lkuCityMaster,lkuPhoneType,lkuAddressType,lkuPrefixMaster,lkuURLType,lkuDesignationType,lkuRelationShipType
2) Link table having prefix “lnk”
By the name it is clear that its main purpose is making relation between main data record and other data. We have used following tables lnkPhoneToPerson,lnkAddressToPerson,lnkAddressToCompany,lnkURLToPerson,lnkPersonToCompany,lnkPersonRelations,lnkPhoneToCompany

3) Main table which start with prefix “tbl”
The main table indicates by “tbl” in our Address book database we have used following tables tblPerson, tblAddresses, tblPhotos and tblCompany.
In the entire lookup table we have preferred tiny int & Small int data type because we know the value in look up table could not go beyond the tiny int & small int max limit.
In similar way we have applied all the not null constraint to require field provide proper data type.
Please see fig below.

SQL Server Database design
Address Book design using Best Practices

For more detail you can download script for Address book.

Thanks & Esteemed Regards
Rajat Jaiswal