Category "sql-server"

SQL group by: select value where another column has its min/max

I want to group by one column, get both min and max of a second column, and (this is the tricky part!) get the value from a third column where the second column

SQL placement join with student, friend, package

Issue: You are given three tables: Students, Friends and Packages. Students contains two columns: ID and Name. Friends contains two columns: ID and Friend_ID

My SQL query runs perfectly, but when I add the CTE function, I get an error

My SQL query runs perfectly, but when I add the CTE function, I get an error Please check this code and let me know what's wrong with the CTE: WITH Consumption_

Need to retrieve images (Varbinary MAX) from SQL Server 2014 to Xamarin by using C#

I am new to the Xamarin platform, I have a local hosted database in SQL Server 2014 using php (with aid of XAMP server) and the table name ItemProductsDB and sa

SQL Transpose Rows to undefined number of columns

I have a table containing graduate ids, degree titles and graduation years. The table can contain any number of rows for each graduate. I would like to create

Using PHP to connect to a remote MSSQL database

My local environment is WAMP. For a few pages i have to access a remotely hosted MSSQL DB, run queries and get back results. I have been supplied the following

Failed to acquire connection. Connection may not be configured correctly or you may not have the right permissions on this connection

I am getting following error while attempting to execute the package. I can execute individual task successfully. But whenever attempt to execute whole package

SQL Server - join rows into comma separated list

Let's suppose I have a temporary table which looks like this: +----+------+ | Id | Value| +----+------+ | 1 | 1 | | 1 | 2 | | 1 | 3 | | 2 |

Executing an exe in SQL job which generates pdf and mail

I've an windows app in server which collects data from db and renders pdf via another third party .exe and mails the pdf. I scheduled the exe to run on SQL job.

SQL Server Config manager error: Cannot connect to WMI provider

I cant open my SQL server configuration manager getting this error message: Cannot connect to WMI provider. You do not have permission or the server is unreach

Reset Identity Seed ('DBCC CHECKIDENT ... RESEED' is not working)

For my unit tests I have an automated process which builds a copy of a DB, table by table. I first of all run a SELECT INTO and add the primary key and any indi

sql server hint NOLOCK and ROWLOCK

I'm currently investigating an annoying problem on my website. We're giving away prizes regularly on the website, but to enter the competition people have to lo

Removing leading zeros from a string in SQL Server 2008 R2

I have a string representing a batch number of goods, for example "0000AZA001B". I only need the "AZA001B" part. How can I achieve that in SQL Compact?

How to create Temp table with SELECT * INTO tempTable FROM CTE Query

I have a MS SQL CTE query from which I want to create a temporary table. I am not sure how to do it as it gives an Invalid Object name error. Below is the whol

no mssql-jdbc_auth-8.2.1.x64 in java.library.path

I'm trying to connect to SQL DB in my Maven project, but keep getting following exception: "com.microsoft.sqlserver.jdbc.SQLServerException: This driver is no

How can I schedule a SQL job in Microsoft Azure SQL Database?

I have one SQL Agent maintenance job which checks the index fragmentation within a database and rebuilds indexes if required. This is running well in my test se

CREATE VIEW must be the only statement in the batch

I'm trying to make a view. So far, I have written this: with ExpAndCheapMedicine(MostMoney, MinMoney) as ( select max(unitprice), min(unitprice) from

Drop default constraint on a column in TSQL

I have a table with a column like this that is currently live: name NVARCHAR(128) NOT NULL DEFAULT '' I am altering the column like this to make it nullable:

UNDOCUMENTED FEATURE when SELECT in VARCHAR with trailing whitespace SQL Server

I hope this is an interesting puzzle for an SQL expert out there. When I run the following query, I would expect it to return no results. -- Create a table vari

ASP.NET Core: Error while Updating Migration (Database first approach)

I have created an application in .NET Core where I am trying with database first approach. I was able to add Migration using "Add-Migration InitialCreate" but