How to change sql server license in Azure VM?

We currently have a VM in Azure which was created from the Azure gallery as a VM with Sql Server Enterprise licensing included on a per-hour basis. This is a very expensive VM. We have MSDN licenses, and this is a dev machine, so we want to change the licensing. How can we change the […]

Joining two tables using a Subquery in the FROM Clause

I’m losing my mind on this question I have on my homework. NO I DON’T WANT YOU TO GIVE ME THE ANSWER! I just want to be pushed into the right direction, because I’ve been struggling with this. Here is the question. Write a SELECT statement that returns three columns: EmailAddress, OrderID, and the order […]

updating multiple columns using case statement in sql server

I would like to update the table using case statement the query is like this… select case(@columnname) when ‘name1’ then begin update table set pay1=pay1* 100 pay2=pay2*20 pay3=pay3* 100 end when ‘name2’ then begin update table set pay2=pay2*20 pay3=pay3* 100 end when ‘name3’ then begin update table set pay3=pay3* 100 end end can u please […]

Search 'AS' alias in SQL Server

I have a sql query that pulls the customers full name from the customers table based on the customer ID in the sales table and binds the info to an asp.net listview. I now want to search the records by the customers full name. I used the query below but it keeps telling me that […]

SQL Query MyGuitarShop Database

Here is the question: 6. Write a SELECT statement that answers this question: What is the total amount ordered for each product? Return these columns: The product name from the Products table The total amount for each product in the OrderItems table (Hint: You can calculate the total amount by subtracting the discount amount from […]

Select max date from sql server table saved as varchar data in “mm-yyyy” format

In a table date data is saved as mm-yyyy format and its datatype is varchar. Now I want to retrieve MAX date. Date is saved in below format and there are thousands of records: 7-1986 10-2012 6-1989 5-1975 7-1974 7-1961 12-1987 10-1975 6-1959 10-2002 12-1991 11-1961 6-1966 12-1959 10-1956 12-1953 6-1999 2-1989 I tried: SELECT […]

How to check a value exists in an integer array – SQL case statement

I’m looking for a solution to check the existence of a value in an array, so that I need to toggle a column based on that values. Here is the table structure ID Name ——————- 1 Alex 2 John 3 Joel 4 Philip 5 Susan 6 Tim 7 Jerry ————————- So the condition is I […]

Linq to Entities: Parameterised Raw Sql query?

I’m writing a WCF service which utilises Entity Framework 6 (EF) to query SQL Server. Most of my query methods are written in LINQ. All good. I need to write a parameterised query. Had a read through this: http://adicodes.com/entity-framework-raw-sql-queries-and-stored-procedure-execution/ This is what I’ve got so far: public string GetLinkItemValue(string linkTable, string linkItem, string linkGUID) { […]

Selective XML index query plan

I am currently exploring the SQL server XML column and Selective indexes for our needs. For doing so I created table called Incidents and created the Selective Index and Secondary selective Indexes (scripts below). When I run the following query it does use the selective index but the query plan does the IS NOT NULL […]

How can I improve the speed of this SQL query?

We have two devices collecting data at roughly 30-second intervals. The devices are located at two widely-spaced sites. The absolute time of each collection for each site can vary +/- 30 seconds. Occasionally, a site will go offline for various reasons. The data from each device represents a different kind of measurement, e.g. temperature from […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.