SQL Server index with condition

I have table Range with columns Start (date), RangeTypeId (integer), ChannelId (integer), IsActive (bit) I have this index: CREATE UNIQUE NONCLUSTERED INDEX [IX_Range_Unique] ON [dbo].[Range] ([Start] ASC, [RangeTypeId] ASC, [ChannelId] ASC, [I...
more »

2017-12-03 15:12 (2) Answers

How to combine results of 3 Joins?

I am trying to make a table per employee that will give the information per employee that was present/absent/work from home.For that I am writing a SQL query that is fetching the records using JOINS. However, I am writing 3 Join statements that are r...
more »

2017-12-03 10:12 (3) Answers

Insert database data into listbox C#

Disclaimer: I have no prior experience with querying databases from c# code (so go easy on me) I am trying to insert data from my SQL Server database into my listbox. Right now I am trying this in the form of an array. I first connect to the databas...
more »

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

Searching data for current date in SQL Server

Why is the first query taking less time than the second one in SQL Server? This query takes 4 seconds to complete: select * from salesinvmaster where day(salesdate) = day(getdate()) and month(salesdate) = month(getdate()) and year(sales...
more »

2017-12-02 12:12 (2) Answers

Selecting Top Occurance of Record by Date

Table Structure: ScheduledDate Date Commodity varchar Example Data ScheduledDate | Commodity --------------+------------ 2017-11-27 | KIDNEY BEANS 2017-11-27 | KIDNEY BEANS 2017-11-27 | RED BEANS 2017-11-28 | LARGE GREEN LENTIL 2...
more »

2017-12-01 20:12 (1) Answers

Kerberos Authentication for SQL Server

I am still seeing the following exception while trying to access SQL Server using Kerberos. What am I missing? Connecting to jdbc:sqlserver://SERVER:PORT;databaseName=DB_NAME;integratedSecurity=true;authenticationScheme=JavaKerberos;applicationName...
more »

2017-12-01 20:12 (0) Answers

Duplication of XML namespaces in SQL

I have the following problem, I need to remove the "cfdi_" for "cfdi:" I used the namespaces to solve that but they are duplicated by each node and I can not eliminate them, If you could help me I would appreciate it declare @Mydoc xml; set @Mydoc...
more »

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

Multiple Hyper links in a same cell in SSRS Report

I am working on a SSRS report having hyperlinks to CRM. I need to implement a logic where a single textbox will have multiple CRM links. I have implemented a logic as below =(join(Code.RemoveDuplicates(lookupset(Fields!Deal.Value ,Fields!Deal.Value ...
more »

2017-12-01 10:12 (0) Answers

Retrieve values from dynamic sql

I have a strange setup at a client. The have a table that defines some categories. One of the fields is a view that contains the details for this category. These categories are setup dynamically hence the view column in the table. What I want to acco...
more »

2017-12-01 10:12 (1) Answers

SQL Server Query Error on WHERE

SQL Server 2005 via C# (VS 20015). Any idea why WHERE won't work? SQL statement is: SELECT AA003Employee.idEmployee, AA001Person.LastName, AA001Person.FirstName, AA017JobTitle.JobTitle, AA017JobTitle.Department, AA003Employee.Di...
more »

2017-12-01 03:12 (3) Answers

Order By Then Sum() up to x return only those

For the below data I want to order it by AverageOfTotal then take the top ItemNumbers where the sum of the average is up to x. ItemNumber AverageOfTotal item-1 0.0235 item-2 0.0149 item-3 0.0203 item-4 0.0101 item-5 0.0084 item-6 0.0096 item-...
more »

2017-11-30 17:11 (2) Answers

Drop index in SQL Server

Can I drop all indexes of a schema in SQL Server according a condition? I explain: I want drop all the indexes that contains a columns there types float, in schema XX. I did this script below but I'm not sure of the line of the type of columns: If...
more »

2017-11-30 14:11 (1) Answers

SQL Server unpivot two columns

I'm trying to pivot a table to get 3 columns my example table is like : CREATE TABLE tbl1 (A1 int, cA1 int,A2 int, cA2 int,A3 int, cA3 int) GO INSERT INTO tbl1 VALUES (60,2,30,3,10,5); GO I am using the query below to get tthe results from two ...
more »

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

SSIS expression to SQL statement

I am trying to convert "Derived Columns" Expressions to SQL statements to be able to add and replace column values and names. I am having some issues in finding the correct help to understand nested formulas in SSIS. Formula i have in SSIS is, [...
more »

2017-11-30 08:11 (2) Answers

Use SSIS Foreach loop to loop multiple folders

I have one main folder, which contains 40+ folders. I have created an SSIS package that creates subfolders in 22 of the 40 folders. I want to use a Foreach Loop in my package to loop through only the 22 folders for my script to return the names and d...
more »

2017-11-29 19:11 (1) Answers


I want to see how many rows are affected for each DDL statement that is run by a query, so I set SET NOCOUNT OFF at the start of each query that is run. Sample query: SET NOCOUNT OFF; GO BEGIN TRY BEGIN TRANSACTION UPDATE dbo.tbProvClause ...
more »

2017-11-29 18:11 (3) Answers