Merge Statement performance Vs Custom Insert/Update/Delete Statement Vs...
I'm in the process of rewriting a stored procedure at my new job. Currently, it's running another stored proc to generate data, using a function to customize that data, and then inserting it into a...
View ArticleOverriding data precedence in a COALESCE expression
I want to return a BIT from an outer join. I want the result type to be BIT. However, the usage of ISNULL is forbidden by code standards. The first expression returns an INT. Which of the bottom...
View ArticleRestoring a database programatically but not over an existing live database
Hi, Can you help me please? I want to restore a database (from an encrypted .bak file) - but *not* over the live original if you take my meaning. Encryption is the standard AES-256 that comes with Sql...
View ArticleHow to get the number of rows affected message in T-SQL (which is not always...
[code="sql"]CREATE TABLE #t (a int);GOCREATE PROCEDURE dotestASUPDATE #t SET a = 1 WHERE 1 = 0;RETURN @@ERROR;GOEXEC dotest;SELECT @@ROWCOUNT;[/code]If you run the above, there is a single result set...
View ArticleSSIS 2014 Sharepoint List Destination
We are just looking to move to SSIS 2014 from 2008R2 however we have a number of packages which write to Sharepoint lists. The SHarepointDestination doesn't seem to work in VS 2013 has anyone come up...
View ArticleOFFSET is not accepting start index
Hi ,I am having a strange issue not sure if this is MSSQL bug or mine :(I have following simple code in my stored proc. even I have hard coded OFFSET to non zero, but it always return result from...
View ArticleI have a simple data modeling question
H have 2 tables. Table 1 is InterestTable 2 is NoteTable 1 has a composite key build on it with fields (Vendor_ID & Offers)Table 2 has an index on Vendor_ID that I need to have as a foreign key to...
View ArticleHow to check Existing attribute in insert attribute in an xml field
HiI want to insert attibute att1 in field F1 . Value for this attribute is content of another field in this table (F2).My query : update MyTableset F1.modify('insert attribute att1 {sql:column("F2")}...
View ArticleHow to register for SQL server database notifications
I would like to register my C# module for SQL server event notifications. These events are just DB creation and DB deletion.Is there any way wherein we can pass the callback function to SQL SMO , so...
View ArticleEnable Trace Flags on a view
Hi,I need to enable trace flag OPTION(QUERYTRACEON 9481)in one of my views I am having trouble finding where to put it in my existing statement:[code="sql"]USE [pec_prod]GO/****** Object: View...
View Articleis it possible to replace While loop by cte ?
HI Folks,Is it possible to replace while loop by CTE?I will fetch records from table 1 based on tretmentid.get the count of recordsrun the while loop inside loop i will compare the column values with...
View ArticleHow to insert CSV data into DB where some data don't have double quotes
Example of data in CSV are as follows:[code="sql"]"XXX","0001",-990039739 ,0 ,0 ,0 ,0 ,0 ,0"ABC"," ",-3422054702 ,0 ,481385 ,0 ,0 ,0 ,0"JJZ","0001",0 ,0 ,0 ,0 ,0 ,0 ,0[/code]Here's my...
View ArticleSelecting records from Table2 while counting records in Table1
Hi, I am a little rusty at this so wanted to check out if anyone knew a good way to do what I need which is:Table1 contains fields Groupid, UserName,Category, DimensionTable2 contains fields Group,...
View ArticleCheck for linked server - supress messages (TSQL/PHP)
Hello community!I found a script to check if a linked server is online. [code="sql"]ALTER PROCEDURE [dbo].[uspLinkedServerOnline] @isOnline bit OUTPUTASBEGIN SET NOCOUNT ON; DECLARE @serverName SYSNAME...
View ArticleInserting values in the database
Hi Everyone, I am trying to insert a value in the table. Sometimes the value has this symbol at the end. I just want insert the entire value except this symbol. The values can be like this that I am...
View ArticleDynamic SQL
Hi there,Please take a look at the code and help me on the last part --put all together = fail !!!I wanted to generate a string for executing sp_executesql but I'm getting an error at the end I also...
View ArticleMaintenance plan not visible under database engine after import...
Hi, I have a query. Here are the steps:1. I created a maintenance plan using Visual Studio 2013 (nothing fancy pretty basic)2. Using ssms 2014 I imported it (the dtsx file) under the Integration...
View Articleupdate duplicates in a column
How do I append an accumulating number to duplicates in a column? I would prefer to update the tablefor exampleNameJohnJohnTomBobBobBobMiketo look likeNameJohnJohn1TomBobBob1Bob2MikeThanks in advance!
View ArticleCapture THROW for logging
Hi, is it possible to capture the contents of THROW within a CATCH into a variable so that it can be written to a logging table?I can capture ERROR_MESSAGE() to a variable but unfortunately it only...
View ArticleCompatibility issue of SSRS 2008R2 with SQL Server 2014
Currently, Our database system runs with SQL server 2005. Reporting service is SSRS 2008 R2 version which has it's report server database in SQL server 2005.Now, we are upgrading database system from...
View Article