looking for select statement dynamic way?
hello experts,i have below primary table,CREATE TABLE A ( A_Id int NOT NULL PRIMARY KEY, A_NAME VARCHAR(10) NOT NULL )Now, this table has refernce either with one or more table, let say with 2 tables...
View ArticleCalculate YTD and MTD by Period
Hi everyone, I've been beating my head against the wall since last night trying to figure this one out. I know I'm missing something obvious but I can't seem to get it. Here's the scenario: I've got...
View ArticleHigh CPU queries causing resource contention on the Sql Server
Hi All,Can anyone help me for creating a query to display High CPU queries causing resource contention on the Sql Server...Thanks ... Jisha
View ArticleHow to update SQL CLR to .NET 4.0 in SQL SERVER 2008 R2
Hi Techies,I want to use .NET 4.0 class library(i.e. I'm using especially few new futures of 4.0 ) in SQL SERVER 2008 R2. But when ever i try to register assembly in SQLSERVER , getting below...
View ArticleUPDATE Columns
How do I UPDATE multiple columns (Code1, Code2, Code3, Code4) from another table.I have an interim table contain the fields along with Row number, example shown below.Id dob...
View ArticleT-SQL insert data if it is same day ignore if it is same week
I have to insert data into these tables - f_up_msg & then f_up_hst and source table is - nhst. I need T-SQL.I have to pick caseid's from nhst table and chose cas_notify + 7 . If I found same case...
View ArticleValue from Previous Date
Hey guys,I'm new to this discussion board and quite new to BI and MSSQL. Currently I have to solve a problem for homework in university and I don't know how to do it.I have to build reports using Excel...
View ArticleTime formatting TSQL
I'm using SQL server 2012. The query below returns the current time, I'm wanting it to return the time that the jobs actually took place, any help would be appreciated. SELECT InstanceName AS...
View Articlecreate table with dynamic table name.
I'm trying to create a tablelike select x.*, convert(nvarchar(20), getdate(), 101) AS LoadDate into table1_20140512 from ( select c1,c2,c3 from table2_20140512 WHERE(LoadDate = (select...
View ArticleSQL 2012 Trigger bulk insert lock
Hi I have built a proc which basically captures some invalid codes and what I would like to do is use a trigger to fire an email everytime this the table receives information .;WITH MatchesCTE (...
View ArticleSCD type 2 using merge
Hi , I'm trying to impliment SCD type 2 using Merge but unlike typical Merge where you have target and source table, my Inserts come from one table and updates/changes are determined from another...
View ArticleTSQL Help Counting from 2 different tables.
I am trying to Count the number of items from 2 different Tables (A & B) But if I have a count in A and B I get 2 separate records. Id like them to be on the same record. Below is what I currently...
View ArticleSelf Training in SQL Server
Hi All,Is there a way to train myself in the SQL server?. If yes, can anyone please tell me what to do.Regards,Harish
View ArticleThe timeout period elapsed prior to completion with options correctly set
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. SQL Server 2012 BI 64-bit on Windows Server 2008 R2 STD with 16 GB memory. Under Query...
View ArticleHow can I select consecutive date from to
Hi guys, I got a huge table with some missing data that I need to send for a department investigation. What I need to retrieves is a series of consecutive dates or one date. I can explain better with...
View ArticleCalculating the number of Whole/Complete Months between two dates
It sounds easy but all the examples I have found so far have got this wrong.I'm trying to use SQL to calculate the number of months between two dates, but these months must be complete months, partial...
View ArticleCan I use a COLLATE clause in a temp table definition?
Can someone provide an example of using a COLLATE clause when defining a temporary table? My goal is to get the temp table's definition to use the database_default value for collation so I don't get...
View ArticleMemorty optimized table (SQL Server 2014) VS Select INTO
Hi Fellas,Which one would be faster for a 50 Million row table with 70 + fields for insert operation?1. Having a memory optimised table and then INSERT INTO 2. Simple SELECT INTO into a non memory...
View ArticleSSRS - Stored procedure with Dynamic SQL Query
Am calling stored procedure in SSRS report. I have used Dynamic SQL query in stored procedure as I don't know the column name and column count. And I have used like below at end of the stored...
View ArticleDistinct Shows Dupes Instead of Distinct
Select DISTINCT [ADJ COUNT] From [dbo].[SPBMI_Count] Where [Index Key] in ('SPGBBMBMI-USDFF--P-REMS--', 'SPGBBMBMI-USDFF--P-RGUS--', 'SPGBBMBMI-USDFF--P-REMX--', 'SPGBBMBMI-USDFF--P-RGUX--')I keep...
View Article