Thursday, July 5, 2012

How Microsoft Sql Server store pdf files

There are two ways to store pdf files in Microsoft sql Server.

  1. To store pdf file in Microsoft Sql Server, create a column as type ‘blob’ in a table. Read the content of the file and save in ‘blob’ type column in a table.
  2. Store pdf files in a folder and establish the pointer to link them in the database. 

Wednesday, July 4, 2012

Order of Query Execution in Microsoft SQL Server


SQL query is excuted in following order.

The query goes to the shared pool that has information like parse tree and execution plan for the corresponding statement. Then validates the SQL statement and validates the source(table).
Acquire locks.
Checks all the privileges.
Execute the query.
Fetch the values for SELECT statement
Displays the fetched values.
To sum up, the sequence is:
SELECT
FROM
WHERE
GROUP BY
HAVING 


Cross Join and Full Outer Join in SQL Server

Cross Join

There is no join conditions specified in Cross JoinResults will be Cartesian product of two tables participating in joinResults in pairs of rows.


Full Outer Join

It is combination of both left and right outer joins. Results in every row from both of the tables , at least once. It assigns NULL for unmatched fields.

Establish Remote Connection to Microsoft SQL Server Database


Establish remote connection in database using following process.
  • Use SQL Server Surface Area Configuration Tool for enabling the remote connection in database. 
  • Click on Surface Area Configuration for Services and Connections.
  • Click on SQLEXPRESS/Database Engine/RemoteConnections
  • Select the radio button: Local and Remote Connections and select ‘Using TCP/IP only’ under Local and Remote Connections.
  • Click on OK button / Apply button.


Linked Server in Microsoft SQL Server


Microsoft SQL Server supports the connection to different OLE DB on an ad hoc basis. This persistent connection is referred as Linked Server.
To use Linked Server for any OLE DB, follow these steps.

  • Open SQL Server Management Studio in SQL Server 2005
  • Expand Server Objects in Object Explorer.
  • Right-click on Linked Servers. Click on New Linked Server.
  • Select General page in the left pane and  
  • Type any name for the linked server in the first text box
  • Select the Other Data Source option.
  • Click on Microsoft Jet 4.0 OLE DB Provider from the Provider list. 
  • Type the Excel as the name of the OLE DB data source.
  • Type the full path and file name of the Excel file in Data Source box.
  • Type the Excel version no. (7.0, 8.0 etc) in the Provider String. 
  • Use Excel 8.0 for Excel 2000, Excel 2002 or Excel 97.
  • To create a linked server click on OK.