Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Browsing index pages (3145 articles)

Using SUM OVER without an Order by

We capture the MPF at a header level and call it TOTAL_MPF.We  also capture Line Level MPF and call it MPF.The sum of the Line MPF should equal the TOTAL_MPF. We have some feed issues and a lot of...

View Article


CTE Group By not grouping results correctly

I have the following CTE that is doing a SUM on the field MERCHANDISE_AMT, seperately from 2 different queries and then I'm joining those results together in the final select. I'm having a problem with...

View Article


Insert to Clustered Index

Hello, I have a stored procedure that consists of a relatively simple INSERT INTO SELECT, the table being inserted into is a Clustered Index. The target table is truncated before being inserted with...

View Article

Stored Procedure and Output value

Hi,I have created a stored procedure with two outputs. The @RowsUpdated works fine, but I am struggling to get a value for @id_user. I have tried using   if EXISTS(SELECT @id_user = id_user from...

View Article

Table data records comparison based on transaction logs?

Hi, We are having a disaster recovery exercise and I need to validate the accuracy of the records in the backup database server against the production database server. Here's what has been done:1....

View Article


Retrieve rows where specific columns are different between columns

I have the following SQL (that I got assistance on her with) to obtain both highest (max) and 2nd highest dated rows. There are some cases in the data where the only difference in the 'OLD ROW' and...

View Article

Change in row values identification

Dear Fellows,How could be find the records where specific values/field changed. In the sample table we need to find those accounts where class has been changed based on date.SQL Code for te

View Article

Get the distinct records which having same date with different time stamp.

Hi Team,Need some on the below requirement.I have the table and data like below.create table trend(keyinstn INT,ratingdate datetime,rating varchar(10))insert into trend VALUES(4000193,'2009-03-19 02:5

View Article


Loading Data from Staging Table to Parent and child tables

Hi,I am trying to load data fro mSTaging table (No Primary Key as it's from the csv file) but in Child table and it's inserting all the Parent Kel column value, just picking up last value, see the code...

View Article


Date Range Consolidation Query

Hi there,I have a table that stores date periods against PersonID's and there should be no overlapping date periods for a given PersonID (a period starting on the same day as another ending is...

View Article

BCP SQL 2014 Incorrect syntax near the keyword 'in'.

Hello,When I try to run below BCP command from SSMS SQL 2014 version or sqlcmd line[code language="sql"]bcp "[db_name].[dbo].[Table]" in "Q:\Table.txt" -c -T[/code]IT gives me this error,Msg 156

View Article

insert to .XLSX fails if len(column) > 255

Error: ERROR MESSAGE:   String

View Article

Selecting different columns of joined tables based on certain criteria

I wanted to retrieve single rows of two columns based on a certain criteria after joining multiple tables. To explain it with example, I've this: [code language="sql"]    SELECT c.colu

View Article


how to set value of variable = variable + string

In subject line of email I want @Subject to return "'Submission at 10/03/2019 22:46:34". Concatenating with + and quotes isn't working. How is it done?[code language="sql"]DECLARE @

View Article

Select latest and 2nd latest date rows per user

I have the following query to select rows where the LAST_UPDATE_DATE field is getting records that have a date value greater than or equal to the last 7 days, which works great.

View Article


Using a local Excel file in an SQL Server query

we keep data in an Excel spreadsheet on a local drive.Can i use that data in an SQL query??I do not have permissions to create tables.  I thought our previous BI Expert did this.THoughts?  We want to...

View Article

which way is better for joins? or are both options popular?

i have a question about joining tables.  I have read online people describing the two methods below..Method 1 - joining tables in a straight line (see below)Method 2- joining both tables from the first...

View Article


SELECT and UPDATE Data

Hi All,We have a table which have high data insert with a status flag column , I want to select data having status=1 and then update the status to 2. The table get inserted very frequently and now what...

View Article

sent SQL query as formatted Excel .xlsx via email

I already have a working stored procedure that exports sql query data set into a .csv file and emails it.  Works great.Now I need to modify it to send dataset as a formatted .xlsx report!   &nb

View Article

Compare Lists

Hi Everyone,Reaching out for some help solving a SQL problem. I have a list of active servers and a list of packages and which servers they were deployed to. I am trying to return a list of missing...

View Article
Browsing index pages (3145 articles)


Latest Images