Reverse ouput
Hi,I am trying to summarize some rows and do a revese outputHere is my table data[code language="sql"]CREATE TABLE mycompanytable( Companyname &nbs
View ArticleUNION returns null values
I have a Query which works fine but when I convert that query into a dynamic query, I get NULL values after the union. Please help me find the issue and fix it. I need to pass multiple inputs for one...
View ArticleProduce a sql profiler Script
Hi , Instead of running SQL proflier , is there a T-SQL script that can be run manually to get the exact same results that are produced from the proflier? I've come up with the following and but...
View Articlecapturing failed commands and their targets..
So.. I'm working on writing a generic CATCH block what will insert into a log table the following information:The table that was the target of a failed insert/update statement.The command that was...
View ArticleTime zone and time zone offset - xml processing
Our application receives web service messages that contains two elements EffectiveTime and TimeZone. When EffectiveTime is provided as datetimeoffset we should ignore the value provided in TimeZone,...
View ArticleVery minor issue, linked server names aren't resolving in the SSMS code editor
When writing T-SQL code, our Linked server names and objects aren't resolving (there's a squiggly line beneath them in the SSMS editor). Is that normal, or is there something we can do to make that...
View ArticleCalculate percentages based on if condition
Hi, I have a query and I need to implement logic to calculate percentages based on if condition in stored procedure itself. Please help me in this...My existing query:
View ArticleJoin two tables using several criterias
I'm trying to combine two tables using below criterias1. if table 1 referance & amount matched with table 2 referaance & amount join those records2. for the items that were not matched above...
View ArticleCreating temporary tables and declaring tables as variables
Hi everyone,I still consider myself a newbie, so please bear with me.While going through some existing stored procedures, I've noticed that some people create temporary tables (say #MyTable), while...
View ArticleUser-friendly names for constraints
I just noticed that when you create a column with a default value, a constraint is added to the table. However, as it is the case with primary keys, it is not given a user-friendly name:
View ArticlePassword encryption in sql server
Password encryption in sql server Currently I am using encryptionpassbyphrase. But it does not work on different servers and decryption fails.Please suggest me if any alternate solution for this
View ArticleHelp with Performance on select count(*) SQL Server 2014
Have 2 same databases one on test and one on dev in different servers. Whilst trying to run the same query is select * from a view i get 17 minutes on test to run and 6 seconds dev. I have restored...
View ArticleInsert using a view into a table having encrypted columns
Hello All,I have a table that has encrypted columns in it. Currently, I'm using a view to present the encrypted columns using a select statment. I'm working on a view that will insert encrypted columns...
View ArticleCTE and UNION performance issue
I am optimizing an inline table-valued function that performs calculations by heavily using OVER, LEAD and LAG. At one stage, records are doubled by performing a UNION. My statement can be schematized...
View ArticleMultiple Values for Single Parameter in User Defined Function
Did anyone come across this scenario where a developer/analyst comes in and pass multiple values for Parameter so he/she can see the data as a table with bunch of fields.
View ArticleAdd Accounts that have no orders to a SQL view
Hi, Can anyone help ?I have a view, an individual sales view.[code language="sql"]SET QUOTED_IDENTIFIER ONGOCREATE VIEW [dbo].[IndividualSales]ASSELECT
View ArticleGetting Next / Previous Row Record Of Specific User
I've a table where record of different users is saved. I differentiate records based on UserID in the table and have separate mechanism for identifying records uniquely. every user is shown his created...
View ArticleUnable to dynamically delete current cursor record using WHERE CURRENT OF
Hi,I am trying to write a script that will delete data from a given table using cursors. As shown in the script below, if the delete..where current of..cursor script is executed directly, it is...
View ArticleHelp with backup script
All, I have gotten this backup script from the web. It seems to work but it is overwriting to the existing backup file. How do I change the code so it creates a new file instead of overwriting to the...
View ArticleNeed some extra set of eyes for this stored procedure.
Below is the stored procedure which is supposed to return News Article data based on the parameter criteria provided.
View Article