And condition in IN CLAUSE in Sql Server 2008

The equivalent of the MySQL LIMIT clause for SQL Server 2008 is so slow

The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. I looked for an equivalent of the LIMIT clause for SQL server(2008) and found this one : SELECT * FROM (SELECT TOP 30 field1, field2 FROM (SELECT TOP 10 fi

CASE statement for the date comparison in the WHERE clause in SQL Server 2008

I am working with a query which contains CASE statement within WHERE clause inside which I have to compare date column with 2 variables fromDate and toDate if it is not null. But SQL Server 2008 is giving some errors like "Incorrect syntax near '>

How to create and define fields to insert the date and date of last modification in SQL Server 2008?

I'd like to record the insert date and an update date on a table. What is the best way to do this in SQL Server 2008?For Insert Date you can use the following trigger: CREATE TRIGGER INSERT_DATE ON TABLE1 FOR INSERT AS BEGIN SET NOCOUNT ON UPDATE TAB

Division of the full name and write to another table in SQL Server 2008

I have a table, say A, in which there is a column FULLNAME. Values stored under this column are in the format of "surname name middle_name" (with one space between each). And I have another table B, in which I have columns SURNAME, NAME and MIDD

Using if-else in the where clause in SQL Server 2008

I need to implement in the where clause. I tried in case statement but between cannot be used in case statement where if start_mth < end_mth mth_no between start_mth and end_mth else start_mth > end_mth mth_no between start_mth and 12 or mth_no betw

Output value and whether it exists in the SQL Server 2008 database

I am trying to create a query that outputs (1) The value (2) Whether the value exists or not. I tried SELECT CASE WHEN EXISTS ( SELECT [IP_ADDR1_TEXT] FROM [dbo].[V_SEM_COMPUTER] WHERE [IP_ADDR1_TEXT] = '10.10.10.10' ) , [IP_ADDR1_TEXT] THEN CAST(1 A

What is the performance of & ldquo; Merge & rdquo; clause in sql server 2008?

Merge can performs insert, update, or delete operations on a target table based on the results of a join with a source table. For example, you can synchronize two tables by inserting, updating, or deleting rows in one table based on differences found

Best method to create and use client account numbers in SQL Server 2008 SR2

I am not a DBA so I am scratching my head a bit. I am trying to put together an application for the company I work for. I need to provide a unique customer account number for each office location my company conducts business with. In the past, I have

Median and 95th percentile in SQL Server 2008? - Requirement of NHS reports

I have tried to find out 95th percentile and median build in function in SQL server 2008 but I do not know why MS does not give support for them, really annoying... Our work place reports are very complex and wanted a straight forward function or may

The best way to store date / time data in SQL Server 2008 R2 and SQL Server Compact 4

We are developing an application in C# 4 that uses SQL Server 2008 R2 as backend. SQL Server Compact 4 is also used for disconnected clients in a very few rare scenarios. We are wondering what's the best way to store date/time data into these databas

Read and increment the int value in SQL Server

I need to read and increment a value atomically in SQL Server 2008, using c#. For example, I have to insert items of a "lot", for this i need the number of the last lot and be sure, that no one else get this number. So i have a table only with t

SQL Server 2008: Rotate Multiple Columns

Need help with the pivot clause in SQL Server 2008. I have a table with this info: I have a table with 9 columns: ID, Period_1 to Period_4 as dates (i.e. 2013-04, 2013-07, etc.) and Amount_1 to Amount_4 (i.e. 30, 40, etc.). I want all the distinct da

Detect whether SQL Server 2008 is installed

I am using dotNetInstaller as a bootstrapper and I need to detect if SQL Server 2008 or above is installed as a prerequisite. Currently I am using this registry to detect the installation: HKLM\SOFTWARE\Microsoft\Microsoft SQL Server 2008 Redist\Shar

SQL Server 2008 Requirements

I've read a few questions at stackoverflow and some msdn articles too about SQL Server 2008 system requirements but there's something that i'vent understand yet. I've installed the SQL Server 2008 Express. I'm not using the Management Studio, just ru