Skip to main content

Posts

Showing posts from 2015

How to Get a Random Row From a SQL Database?

How to Get a Random Row From a SQL Database? use this Quary select Top 5 Id from YourTable order by NEWID()   NEWID (Transact-SQL)  Applies to: SQL Server (SQL Server 2008 through current version). Creates a unique value of type uniqueidentifier. NEWID() is based on a combination of a pseudorandom number (from the clock) and the MAC address of the primary NIC. However, inserting random numbers like this as the clustered key on a table is terrible for performance. You should consider either NEWSEQUENTIALID() or a COMB-type function for generating GUIDs that still offer the collision-avoidance benefits of NEWID() while still maintaining acceptable INSERT performance.

How to get google map image of area you want

How to get google map image of area you want Hi First you need to take one image control and set it Image URL blank. after on code side set it image url as below. ImgMap.ImageUrl = "http://maps.googleapis.com/maps/api/staticmap?sensor=false&key=AIzaSyA4WZ--vZ1qILKrICJg7MdNKZyv1qkiIOw&zoom=14&size=600x512&maptype=roadmap&markers=color:red|label:A|" + "Bapunagar, Ahmedabad, Gujarat"; on Out put  You can get this image in browser. you can use this in contact us page or any searching area related forms.  Thank You for See this.

What is the difference between ExecuteScalar, ExecuteReader and ExecuteNonQuery?

 ExecuteScalar is typically used when your query returns a single value. If it returns more, then the result is the first column of the first row. An example might be SELECT @@IDENTITY AS 'Identity'.  ExecuteReader is used for any result set with multiple rows/columns (e.g., SELECT col1, col2 from sometable).  ExecuteNonQuery is typically used for SQL statements without results (e.g., UPDATE, INSERT, etc.).

Create Database in SQL Server by Sql script

Put below script in sql Editor and change Database_Name to your Database name IF (NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE ('[' + name + ']' = 'Database_Name' OR name = 'Database_Name'))) Begin CREATE DATABASE [Database_Name] ALTER DATABASE Database_Name MODIFY FILE ( NAME = N'Database_Name' , SIZE = 3048KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) ALTER DATABASE Database_Name MODIFY FILE ( NAME = N'Database_Name' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) End