Cumulative Column that starts at Zero every Year

I have data from January 1st 2008 to today ordered by date in the first column of a table Ratio. I have values in the second column. I was able to do a cumulative third column with the following code but I don't know how to make it re-start every J...
more »

2017-05-14 19:05 (1) Answers

Database couldn't select

In 2 lines of my php code ... $link = mssql_connect($DB_HOST, $DB_USER, $DB_PASS); if (!$link || !mssql_select_db($DB_NAME, $link)) { die('Unable to connect or select database!'); } $link connection is established, however, the DB selection...
more »

2017-05-14 16:05 (0) Answers

Using Parameters to Add Columns?

I have a stored procedure which adds a currency record to my exchange rate table but I also need a corresponding column for the added currency. The table structure is as follows: CurrencyID CurrencyName Rupee Euro ...
more »

2017-05-14 15:05 (2) Answers

executing a stored procedure with parameter

consider the following stocked proc: CREATE PROCEDURE Test ( @Table1 NVARCHAR (100), @Table2 NVARCHAR(100)) AS BEGIN SET NOCOUNT ON; DECLARE @sSQL nvarchar(500); SELECT @sSQL = N'SELECT * FROM ' + @Table1+' '+ @Table2 +...
more »

2017-05-14 14:05 (3) Answers

SQL Update Join Multiple Tables (if field exists)

This is my first post to StackOverflow. I've been using this amazing resource for a number of years to answer hundreds of SQL and PowerShell questions, however this one has me stumped for a number of days. I am using SQL Server 2014 SP2 and I am try...
more »

2017-05-14 07:05 (2) Answers

invalid column name '-'

I am using SQL Server express edition on my computer and trying to execute the following query from a vb.net application however I got this error Invalid column name '-'. In the query I use the '-' character in order to perform subtraction bet...
more »

2017-05-13 06:05 (1) Answers

Run exe file with parameter from SQL Server

I have created a console application and now I want to execute this .exe file from SQL Server. Running this query only gets null output. Please help me. DECLARE @CMDSQL VARCHAR(1000), @Reportname VARCHAR(100), @TerminalC...
more »

2017-05-13 01:05 (0) Answers

Entity Framework and Dynamic Schema

I inherited an application that talks to many different client databases. Most of these tables in the client databases have identical schema - but there are a handful of tables that have extra custom columns that contain tax information (ya - bad id...
more »

2017-05-12 19:05 (1) Answers

How to stop a running query?

I use RODBC to send queries to an SQL-Server. Sometimes they take too much time to run, so I need to cancel them. Clicking the red "stop" button in RStudio yields this error message: R is not responding to your request to interrupt processing so...
more »

2017-05-12 19:05 (3) Answers

SSIS Derived Column converting decimals to .00

I'm using SSIS 2012 and trying to get the Derived Column step to calculate and output an accurate percentage. As an example, I have the following equations that includes 2 digits after the decimal: (20177 * 100) / 26032 = 77.50 (3703 * 100) / 2603...
more »

2017-05-12 18:05 (2) Answers

Incorrect syntax near '('. Expecting ID

I've looked through several other questions of this type and have not found one that will help me resolve this issue. What I'm trying to do is this: I want to create a table for all employees for the purpose of assigning an EmployeeID that will be us...
more »

2017-05-12 18:05 (2) Answers

Randomizing select distinct

We use multiple databases at work, at least Oracle and MSSQL. Not sure why we have to use both but this question is about MSSQL. There is a table, let's just call it System..DirectMapping that has a field accountID. I can't guarantee they are all n...
more »

2017-05-12 15:05 (1) Answers

Why is columnstore index not being used

I have a non-clustered columnstore index on all columns a 40m record non-memory optimized table on SQL Server 2016 Enterprise Edition. A query forcing the use of the columnstore index will perform significantly faster but the optimizer continues to...
more »

2017-05-11 14:05 (2) Answers

double inner join in linq/ lambda query?

i got this SQL -query that i want converted to Linq. this is the contect: im making a asp.net api that needs to return values from 3 different tables CREATE TABLE Locatie ( locatieId INT IDENTITY(1,1) not null, postcode ...
more »

2017-05-11 13:05 (2) Answers

Joining Tables with optional conditions/OR

I am trying to do a left outer join with multiple OR conditions. declare @table table (ID char(3)); insert into @table values ('001'), ('001'), ('002'), ('003'), ('004') declare @join_table table (AUX_ID char(3), AUD_ID char(3)); insert into @joi...
more »

2017-05-10 16:05 (4) Answers