How to GROUP BY in one condition and simply SELECT in another in one go?
I need to return payments records from a same table, which must be organised as following:1) All Credit Cards payments must be grouped by 2) All other types of payments should be presented as they are...
View ArticleSelecting a VP from an organizational hierarchy
Hello SQL Gurus!I currently have a CTE that if I plug in the VP, it will show all the employees that roll up to that VP. I need to figure out how to do the opposite and return a VP (Vice president),...
View ArticleOmit selected fields from the GROUP BY clause
Hello,Is it possible for me to omit fields that are in the select statement from the group by clause at the bottom?I have the below SQL which will eventually be a view and the stockdateandtimein and...
View ArticleEditing SSIS packages from SQL Server 2014 with Visual Studio 2017?
I've been asked to reverse engineer and update many SSIS packages created on SQL Server 2014. The target production environment is using SQL Server 2014. However, my work laptop has SQL Server 2012...
View Articleupdating records from a staging table while converting and removing trailing...
I am trying to update a company ID for a table and running into issues. I am wondering if someone can help me with a query. This is what I am using to update values. I have tried multiple methods but...
View ArticleConverting gibberish String to DateTime
Good day fellow colleagues, so I have been querying for a bit, but I still face occasional challenges.So I have an SQL relational db on MS SQL Server 2014, I'm pulling a specific field, which is...
View ArticleNeed Help -- Views
SQL Server 2014 Enterprise Edition 64 bitWindows Server 2012 R2 Enterprise Edition 64 bitThere are two databases A and B. I want to create views in Database B Using Tables in Database A. I am able to...
View ArticleINSERT EXEC statement cannot be nested
I have a requirement to get data from a deep chain of procs. However, there is already an "INSERT EXEC" statement in one of the deeper procs.I am looking for options to overcome the error generated.So...
View ArticleAny way to reduce the execution time for 8mil + rows table with cross join
Dear All,I have following Query in my production. My Table_B has 8mil + rows. If I have 4 role in Table_C, my query result will return 32mil + rows.Current execution time taken is about 1 day. I am...
View ArticleWill temp tables be dropped when Transaction commits?
Hi gurus!It is been a long time since I asked you for your input to clear my self doubt :)I would like to know if a temp table created within a transaction will be dropped automatically after a COMMIT...
View ArticleEnforce Unique Constraint Across Two Tables
I have an interesting problem. An application allows users to "Tag" events with a label. Each user can put a single tag on an event. There is a list of default tags that users can choose from, but...
View ArticleHow to search in database for a specific data... Sometime you are given a...
[code language="sql"]DECLARE
View ArticleQ related to Clustered columnstored index
Hi everyone,1. My table has 8mil+ rows and 350 columns. But our query does not include calculation. It's just to join the tables and extract only. Do you think Clustered Columnstored index is suit for...
View ArticleI need some help with Text data type in SQL Server table.
I am trying to insert into table the approximately 74 thousand characters but Text datatype allows me to insert only 44 thousand characters. The Text data type can store up to 2,147,483,647 bytes. Any...
View ArticleHelp! Stored Proc: Executing Defrag with Indexes Based on Page Locking
Hi all,I am trying to write an EXECUTE statement that runs the following criteria:Call SP once and EXCLUDE indexes that have PAGE_LOCKING=OFF REORG >=5% REBUILD >=30Call SP again, REBUILD for...
View ArticleHow to minimize/avoid data repetition and where to use compound keys ?
Hello everyone !I am absolutely new to database development and i'm trying to build a question bank basically.The questions have to be categorized based on Class, Subject and Topic. Since each Class...
View ArticleHow to Stuff the positions with blanks?
Hi ...I got a format to fill the positions to create a long string.Pos.
View Article