Select data based on multiple date criteria
Hi Guys,My company are looking at sending out customer satisfaction surveys to our customers. There are two different date criteria that should trigger the survey email.1. StartDate + 3 days (+5 days...
View ArticleStored Procedure to support varying input parameters
Hello, I am working to create a Store Procedure that will need to accept parameters being passed by a web page. Based on the parameters based, my PROC needs to be able to return the desired...
View ArticleCode for 'week to date' DATETIME() mine is displaying previous weeks
[code language="sql"](Invoice_Exceptions.DateTime >= DATEADD(dd, DATEDIFF(dd,'17530101', GETDATE()) / 7 * 7 - 7, '17530101')) AND (Invoice_Exceptions.DateTime <= DATEADD(dd,...
View ArticleExtract to CSV File
I have data something like below for one of the column.ADDRESS2248|("snake") ft NE, FTE 700When I extract this record to csv using SSIS, My column is populating as below:ADDRESS &
View ArticleSQL Query to Split Concatenated Column data Into Multiple Rows
I have a column named Column_Value that has concatenated values such as 5y, 5u, 6h. What I want to do is create one record for each one and copy all the other fields. For instance a row may contain...
View ArticlePlease let me know what is wrong with my code.
I have two tables T_V and T_C. I'm updating T_V's columns with T_C's respective columns. I'm getting an error during compiling the procedure. The error is Msg 156, Level 15, State 1, Procedure...
View ArticleTrying to speed up this 'GetWorkingDays' function.
I'm trying to redesign one of our working days functions. The idea is to calculate weekends (easy enough) but holidays are trickier. The current idea is to simply embed the hard coded date values in a...
View ArticleSelective change tracking in a column
Hi,I have to count how many times a record changed from group 2 to group 1 or 3 per ID ordered by RowIDThis is my table:[code language="sql"]RowID ID GROUP1  
View ArticleColumn-Level Encryption and sys.dm_exec_procedure_stats DMV
I am seeing that when a stored procedure uses column-level encryption, it no longer is in the sys.dm_exec_procedure_stats DMV.Have not been able to find any info on this and hoping someone here might...
View ArticleTsql help - usage of aggregate functions
Hi, I have student marks table. I am calculating Total marks and Avg marks per student.How can I get the same output using built in functions using SUM() and AVG() functions ?CREATE TABLE...
View ArticleSet up job to convert word document to pdf
I'm working on a SQL job to transfer some data along with some word documents. After copying the word documents I need a step to convert them to pdf. The package I have runs fine but when I set it as a...
View Articletsql help
Hi All, I want to understand MERGE behavior. In below example, I am using it for INS-UPD functionality. However, I want to see the values which are getting inserted or updated in destination table....
View ArticlePossible to add a Total for Amount at the end of each day?
[code language="sql"]DECLARE @Yesterday DATETIME = DATEADD(DAY,-1,CAST(GETDATE() AS DATE));DECLARE @PeriodStart DATETIME = DATEADD(DAY,-6,@Yesterday), @PeriodEnd DATETIME = CAST(GETDATE() AS
View ArticleHow to only select 11pm to 7am in DateTime (many months of data) DDM&DDL...
Looking to run a report for a few years but only between 11pm and 7am.[code language="sql"]CREATE TABLE mytable( i_ticket_id INTEGER NOT NULL PRIMARY KEY ,c_grand_total MONEY(6,2)
View ArticleJoin on a Substring
I have a proc that runs nightly that moves data into another table. The procedure joins on multiple tables one of the joins involves two columns in tables that have id numbers. I have no control of...
View Articlecase when LIKE on columns from 2 different tables
hello,need some help with the follow.problem: A.CITY contains a single city per row (i.e. TORONTO), B.CITY contains multiple cities per row (i.e. TORONTO, TOKYO )my statement below returns 0,...
View ArticleObject Level Privileges to File
I am new at SSIS and want to execute the "Object level privilege" query found on the sqlservercentral.com site to a file using SSIS. My ultimate goal is to use SSIS to get the Object level privileges...
View Articledatabase for .net application
We have a situation like below:we have a .net application for students that used the SQL server database as backend, I will call it App1. The database have some tables for the application and also...
View Articledbcc freeproccache for Single stored procedure
Hi Team,please provide the query to clear the cache of single stored procedure.THanksBhanu
View Article