Query time difference when a column value changes
I have a table where we write part test info from robots. I'm trying to get a list of tool changes within last 5 days.Below a simplified version of my table. I would like to know when PART_NO column...
View ArticleRAISEERROR to stop execution
Sometimes I want to stop execution. Not do a rollback. Just stop execution. These are stored procedures that are either executed individually are several stored procedures included in a single...
View ArticleSQL Replace Function
Hello Everyone!I'm in a fix, I've come across a scenario where simple replace function isn't supporting me in writing good queries. As a result, I've to use Loop or Cursor. Here is the case;I've a...
View ArticleHow to get this result
I want to get result as c1,c2,c3 by modifying the below QueryWITH CTE AS (Select'c1' As A, NULL as B, Null as C UNION ALL SELECT NULL, 'c2',NULL Union ALL SELECT NULL, Null, 'c3' ) SELECT * FROM...
View ArticleInsert Issue
Hi All , Below are the Sql Scriptscreate table Product (ProductID int Primary Key, Product_Name varchar(30)) insert into product values(1'ABC'); insert into product values (2,'ABC1'); create table...
View ArticleLinked Server : Create, Populate & reuse a remote tmp table
Hello,Here's the plan :Perform a Select Query (1) on remote database via linked serverStore results of the Select, into a temporary table (1)Perform another Select Query (2) on same remote database via...
View Articleduplicate value in table
Hi ALLI need to Found duplicate value in Sort column .I used below Query WITH CTE (dd,SortOrder)AS(SELECT Row_number()over(Partition by SortOrder orderby SortOrder),SortOrderFROM ss.Dimtt)SELECT*from...
View ArticleCOMMIT TRAN not committing
I have a very strange situation with which I hope you can provide some insight. I have the following script that I use to activate certain features on our clients' databases:DECLARE @MiscChargeName...
View ArticleGet values for some columns in trigger
I have INSTEAD OF TRIGGER when insert into table. The reason is that I have to get the value for some columns from other tables, before insert (or i will have to update after insert) example: If...
View ArticleNeed Specific Date Range
Hi let's say I have getdate() =FridayNow I need my last Sunday to saturday date Range for this based on todayPlease provide me query
View ArticleManage transactions in multiple stored procedures
HiI have two stored procedures A & B. Stored procedure B is calling from A. I want to implement the transaction in such a way that, if any error happened in A, all the operations from A should be...
View Articledynamic pivot
Here is my intial table t1 and final table t2based on the parameter passed i need to pivot the table t1RECORDER_IDCHANNEL_NOMDATEvalueA1KW11/13/2012 0:001072.8A2KVAR11/13/2012 0:00447.12A1KW11/13/2012...
View ArticleInserting Records From User Defined Function or Using Stored Procedure in...
I have a function as below which I use to insert Staff Code in Queries CREATE function [dbo].[Get_StaffCode](@StaffName varchar(255))returns varchar(10) as begin return (SELECT [STAFF_CODE] FROM...
View ArticleServer 2012 Security Guide
Microsoft has Security Guides with Group Policy templates for Server 2003 and 2008. Is there anything like that for Server 2012? I'm looking for security baseline group policy template.
View ArticleSum two fields on different rows in same table to display as third row in result
Hi All,I'm running version SQL Server 2008R2. I'm trying to add together two items from the same field but from different rows based on the another fields content while at the same time keeping all...
View Articleuse results from view in a where statement
I have a sql server 2008 stored procedure where I want to use the results of a view in a where statement. I want to check to see if the results from the view is not null.The sql looks like the...
View ArticleMicrosoft TechNet Wiki Guru - Winners for August!!
The results for August's TechNet Guru competition have been posted!http://blogs.technet.com/b/wikininjas/archive/2013/09/11/technet-guru-awards-august-2013.aspx Congratulations to all our new Gurus for...
View ArticleUse dynamic sql to 'insert into @table'
I have a sql that needs to be dynamic. The database name changes and so do the conditions.Have the following value that I do a REPLACE for the variables inside the question marks and then use in...
View Articletranslate a query
Hi, someone can help me to translate this query to T-SQL (to run from SQL Server 2005): UPDATE (SELECT IAMeasurement.Imes_ObjectUnit, IAImageMeasurement.Iim_Unit FROM IAMeasurement INNER JOIN...
View ArticleSQL query with like %
i want to find a word in database with ends with kumar... example...if i have rajesh kumar and rameshkumar in database i want to find which ends with kumar and it should return rajesh kumar which has...
View Article