Ms Sql Server

SQL/XML In MS SQL Server

Tuesday, January 29th, 2008

Microsoft SQL Server allows to return the results of a query in XML format. Let's create a simple table: create table test ( field_a varchar(20), field_b varchar(20) ); insert into test values('Microsoft','SQL Server'); insert into test values('Oracle','Oracle Database'); SQL to XML transformation is very simple to use. It's done by adding following clause at the end of a query: FOR ...

How To Connect From SQL Server Database To Another SQL Server Database

Thursday, September 6th, 2007

In order to do this, you will have to link the second server to your current server. You can do this by using linked servers option in enterprise manager or by using the stored procedure called sp_addlinkedserver. Then in your query you can use tables of the remote server by qualifying ...

Simulating Oracle Synonyms in MS SQL Server

Wednesday, August 29th, 2007

Oracle Synonyms can be easily simulated in SQL Server by using Views. The following example creates a view that returns the CarID and CarPurchaseDate from Cars table. CREATE VIEW vCars AS SELECT CarID, CarPurchaseDate FROM Cars SELECT statement: SELECT * FROM vCars Let's create a view which is Sql Server version of Oracle's TABS synonym or USER_TABLES data ...

SQL SERVER DATEDIFF - T-SQL version of days_between and months_between.

Monday, August 20th, 2007

Returns number of days, months, weeks, hours, minutes etc. between two dates. Syntax: DATEDIFF(datepart_code, startdate, enddate); Date Part | Code -------------------------------- Year | yy, yyyy Quarter | qq, q Month | mm, m Day of year | dy, y Day | dd, d Week | wk, ww Hour | hh Minute | mi, n Second | ss, s Millisecond | ms