Quantcast
Channel: Transact-SQL forum
Browsing all 23857 articles
Browse latest View live

TSQL - To Remove Overlap between 2 sets of records and give priority to 1 set

Hello,I have two sets of records in a table namely ACTIVITY and DELAY for a particular machine in a particular shiftdate and shift.  During some shiftdates and shifts OVERLAP occurs between Acitivty...

View Article


Updating 350 Million Records from other table taking too long

Hi,I have a table1 with new column that needs to be populated from table 2. Table1 has 350 million records in it.Below is the code i am using... But it takes too long even to update the 1 million...

View Article


error in union all

tried to do aunionallwith twotablesseethe error.how do I fix?All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.

View Article

How to tell/display when a row changes

Hi All,Hopefully this is a simple question. I have a table of 1 million records that is an audit table. Whenever a file is moved from one location to another, it creates 2 records in this audit table....

View Article

Using Alter Statemement to add a constraint to set a column 'Date' to be less...

Trying to add the following constraint using ALTER Statement ( with ADD CHECK):ALTER TABLE Table_Name WITH NOCHECKADD CHECK (Column_Date <= Today)Need to get the property to "Date should never be...

View Article


Max over partition by excluding certain values

I have two tablestable1:Messagethread,opendate,closedate,threadsectiontable2:Messageid,Messagethread, messagetitle,messagedate,messageparent.I would like to dispaly the following columnsthreadid,...

View Article

Sorting (Ordering)

I have an account number field with data as follows161All141I want ALL at the top and the remaining account numbers in descending order. I ORDER them by account number DESC and I get:All161141that is...

View Article

Are you a technology guru? Show us your solutions and become the T-SQL Guru...

TechNet Wiki is looking for and celebrating the best of the best!Is that you? Do you consider yourself an expert, or authority on T-SQL?Show us your forum solutions and become MICROSOFT TECHNOLOGY GURU...

View Article


Update with CASE and multiple WHEN conditions executing only one condition

I have a temporary table named SheetData. When an Excel sheet data is passed as XML to a stored procedure, the data is stored in this SheetData table.There is no reason to have Primary Key and other...

View Article


Best Practices - SQL Code in Application Code or Not?

I have recently started a new position, where the main project is written mostly in FoxPro.  There is some (increasing) effort going on to move it to .NET.  As the project is still in the early stages,...

View Article

Problem with SUM() with varbinary data

Hello everybody,I have a problem, my information in BD is encrypted. but i need to desencryte and convert to numeric and then get a SUM()I'm trying to do it, egSELECT @TOT =...

View Article

Image may be NSFW.
Clik here to view.

join tables

please helpdeclare @tab1 table  ( id int, subid int, date2 date)insert into @tab1 values (1,1,'05/06/2013'), (1,2,'05/03/2013'),(1,3,'05/05/2013'),(1,4,'05/6/2013')...

View Article

Matching Records and Other Conditions T-SQL

Hi Friends,I have a small issue.I was writing one storeprocedure.... I have a table and on this I was writing couple of conditions.Condition 1:If three are mataching then display the recordsSelect *...

View Article


Replication on timestamp column

I have table with timestamp column. If I create UPDATE on some column, I always get "KeyLookup(clustered)" operation to get timestamp column at the beginning of execution plan.Should i include this...

View Article

indexes

Hi,Can anybody please tell me that on which columns we can have clustered index and non clustered index in a table with example.

View Article


[Help] How to get data of OrderID and the maximum-priced product of each Order

Hi everyone! I have a question:How to select the orderID, order date and the maximum-price product of each order in the below tables in 2 ways:1-using correlated sub-query 2-not using correlated...

View Article

Image may be NSFW.
Clik here to view.

Help with complex CTE expression

Hi all,I was recently (and very kindly) helped by Jesus under the following thread Common Table Expression Help.Being a complete newbie to CTE's, I was at a loss on how to achieve my goal and whilst I...

View Article


Contains Funtion In full text Search

Hi, i have created the full text index on the table candidates.I am Storing candidates resume in c_resume text filed. Presently I am passing Only Technologyselect * from candidates WHERE...

View Article

How to convert a datetime to a string with time in am/pm with leading zeros

I thought I was pretty familair with convert and format but I can't seem to find a way to convert a date time field to a string field in the following format:04/30/2013 03:31:00 PMI can get really...

View Article

Error converting data type nvarchar to numeric. error hidden in stored procedure

I'm running a program that throws this error when it executes a stored procedure.  The stored procedure runs without error when I run it from SSMS.  If I take the queries out of the stored procedure I...

View Article
Browsing all 23857 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>