SQL: Convert Data For One Column To Multiple Columns

I have tried looking for a solution to my problem using things such as Pivot, but they do not seem to give the output for which I am looking as they appear to map specific values in a row to a column. I have two columns, the first which contains a “key” field and the […]

Excel use VBA to connect to SQL using Windows Authenication

I’m working in an environment where users have two separate accounts. One logs them into their host machine, and then they use a separate one to access a VM with special software. One of the VMs has an SQL database that records alarms that they would like to be able to access from excel installed […]

How to show NULL value using GridView in asp.net?

I am using gridview to fetch the data from sqlserver. there are few values which are NULL. How to show these values using Gridview?

LINQ Using ROW_NUMBER() function?

I have a table that shows a list of sync’s from our mobile users back to our database. This means that each user could have thousands of sync records. I have written a query that uses the ROW_NUMBER() function to pull the most recent sync for every user and only active users, as I don’t […]

How to get the average in SQL with conditional parameter

I have to get the average of collection of data and i have the idea but don’t know how to execute this query: SELECT AVG(successRate) FROM usb_compliance WHERE ATC = ‘CMB’ ORDER BY date DESC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY Like this I want to get the average of successRate using the […]

Reading XML into SQL tables

I am reading the xml and writing it into sql tables Want to insert below xml into table Declare @MainXml XML = ‘<Parent> <Root> <Admin>admin1</Admin> <Data number=”1″> <Type value=”100″></Type> <Type value=”200″></Type> </Data> </Root> <Root> <Admin>admin2</Admin> <Data number=”1″> <Type value=”300″></Type> <Type value=”400″></Type> </Data> </Root> </Parent>’ I am trying to insert into table like this Insert Into […]

Login failed for user 'IIS APPPOOL\myAppPoolName' and cannot add new user for this

I am getting the following error while asp.net app trying to connect database. Login failed for user ‘IIS APPPOOL\myAppPoolName’. I use ms SqlServer 2008 r2, windows server 2008 r2. This happened when I’ve just moved the application and database from one server to another. I thought adding a new user to database named ‘IIS APPPOOL\myAppPoolName’ […]

Difference between EF.SqlServer and EF.SqlServerCompact

I want to install Entity Framework in my ASP.NET 5 MVC project using project.json. In the dependencies section I start typing EntityFramework and I only see “EntityFramework.SqlServerCompact”: “6.1.3” instead of “EntityFramework.SqlServer”: “6.1.3”. What is the reason for this and what effects will this have? Are there limitations in the compact version? If I create a […]

SQL server command line: abort instead of GO

I am in SQL server command line utility (sqlcmd.exe) and I type: 1> UPDATE usercache SET TargetUri = NULL WHERE name=’Alexander’; 2> GO (5 rows affected) But consider the case where I forgot the WHERE statement: 1> UPDATE usercache SET TargetUri = NULL; 2> How would I now abort the execution? As of now, I […]

merge two tables with partial relationship

I have some messy data in text files (2 tables). I’d like to merge it into 1 table but there are duplication issues. My data looks like the following: Status table +————————–+ | | Last Name | Status | | +————————–+ | | Jones | On Time | | | | Jones | On Time […]

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