Thursday, January 26, 2012

To know the databse version in SQl Server

To know the version of the Database by query:


Select @@version as x


another query for a more specific results, we can execute

Select SERVERPROPERTY('productversion') As [Version],
SERVERPROPERTY('productlevel') As [Level],
SERVERPROPERTY('edition') As [Edition]

To save new line to vachar field of SQL Database Table

For various purposes we are in need to multi-line text in the database fields. It differs from OS to OS or databases to databases. Generally to save a multi-line text to a varchar field of a table in sql server database, we can use just two special characters:

char(13)+char(10)

This bondage of 13 years old boy and the 10 years old girl make a new position of the parent's line(Just love story to remember!!!!)



INSERT INTO [TestDB].[dbo].[testTable]
([TestID]
,[TestName]
)
VALUES
('ROW 2',
'Everybody should love his God'
+CHAR(13)+CHAR(10)+'No matter which one he believes'
+CHAR(13)+CHAR(10)+'God loves us so much.'
+CHAR(13)+CHAR(10)+'He is the almighty of this world')





If we execute the above query the table will accepts and holds the 2nd field with the 3 new line also. And the Select query with return them as intact.



Sunday, January 22, 2012

Performance issues for Web Development

Performance is the main concern to develop website or web application. Web developers may follow the following steps for that.
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires or a Cache-Control Header
4. Gzip Components
5. Put Stylesheets at the Top
6. Put Scripts at the Bottom
7. Avoid CSS Expressions
8. Make JavaScript and CSS External
9. Reduce DNS Lookups
10. Minify JavaScript and CSS
11. Avoid Redirects
12. Remove Duplicate Scripts
13. Configure ETags
14. Make Ajax Cacheable
15. Flush the Buffer Early
16. Use GET for AJAX Requests
17. Post-load Components
18. Preload Components
19. Reduce the Number of DOM Elements
20. Split Components Across Domains
21. Minimize the Number of iframes
22. No 404s
23. Reduce Cookie Size
24. Use Cookie-free Domains for Components
25. Minimize DOM Access
26. Develop Smart Event Handlers
27. Choose over @import
28. Avoid Filters
29. Optimize Images
30. Optimize CSS Sprites
31. Don’t Scale Images in HTML
32. Make favicon.ico Small and Cacheable
33. Keep Components under 25K
34. Pack Components into a Multipart Document
The items above has been reference from Yahoo’s Developer Nework. Full details on each of these items is available at:
http://developer.yahoo.com/performance/rules.html

Friday, January 6, 2012

Copy table to a different database on a different SQL Server

Easily information from t table to another table can be copied. If these tables are from two different database on the same server it also be possible to perform query using the following:



INSERT INTO bar.tblFoobar( *fieldlist* )
SELECT *fieldlist* FROM foo.tblFoobar



or

SELECT *
INTO DestinationDB.MyDestinationTable
FROM SourceDB.MySourceTable



The problem arise when we want to copy information from he table of one database to that of another database. And in sqo server this can be performed by a technique known as linked server.
------------------------


Yes. add a linked server entry, and use select into using the four part db object naming convention.

select * into targetTable from [sourceserver].[sourcedatabase].[dbo].[sourceTable]




................
We can add a linked server entry following the below information


1. Click Start, click All Programs, click Microsoft SQL Server 2005 and then click SQL Server Management Studio.


2.In the Connect to Server dialog box, specify the name of the appropriate SQL Server, and then click Connect.


3. In SQL Server Management Studio, double-click Server Objects, right-click Linked Servers, and then click New Linked Server.


4. In the New Linked Server dialog box, on the General page, in Linked server, enter the full network name of the SQL Serveryou want to link to.

5.This procedure often refers to the server you are linking to as the remote server. This is for convenience only, to indicate the relationship of the linked (“remote”) server to the local server. Do not confuse this usage with the obsolete remote server functionality in SQL Server.



Under Server type, click SQL Server.

6. In the left pane of the New Linked Server dialog, under Select a page, choose Security.


7.You will need to map a local server login to a remote server login. On the right side of the Security page, click the Add button.


8. Under Local Login, select a local login account to connect to the remote server. Check Impersonate if the local login also exists on the remote server. Alternatively, if the local login will be mapped to a remote SQL Server login you must supply the Remote User name and Remote Password for the remote server login.

To use impersonation, your SQL Server configuration and login accounts must meet the requirements for delegation. For more information about impersonation and delegation, see http://go.microsoft.com/fwlink/?LinkID=132854.



9. In the left pane of the New Linked Server dialog, under Select a page, choose Server Options. Set the Rpc and Rpc Out parameters to True, and then click OK.

Saturday, November 19, 2011

Case Sensative Database Query

Normally, the information kept in a cell of a database is not case sensative. For the query as below


Select * from tblShopInfo where shopName='bata'
Select * from tblShopInfo where shopName='batA'
Select * from tblShopInfo where shopName='Bata'



we will get same results for the all of the above queries. But if we are in need to get the information of case sensative partameter. Then we need to make the query as below:


Select * from tblShopInfo where shopName COLLATE Latin1_General_CS_AS ='baTa'



The above query will return only the specific info we need.