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

Temp table and Insert Help

I need some help.I have a dataset with distinct values, I want to insert that query into temp table SELECT DISTINCT T1.C01_CMM_S, T2.C05_CMM_DESC_S Prodname ,T1.C07_CUS_NET_UNTS_D as NetUnit...

View Article


Updating poor data

I am trying to update a database with some poor data.   In the database I have a column for birthdate.  Some dates are formatted 1900 and 2013 others are simply 88 0r 08 for 1988 and 2008 respectively...

View Article


T-SQL question

I am thinking of creating a trigger so that I can get email alert if table schema changes happen mainly the following changes in the database: 1. Table added/deleted 2. Column added/deleted 3. Column...

View Article

Getting records with special characters

Hi,I have a table1 - JOBS with column JobID and JobTitle. Table2 - Character with columnname Spl_char which contains the special characters other than letters (a-z) adn digits (0-9).I want to take out...

View Article

Before Delete Trigger

How to check the constraint before deleting record using triggers?there are two foreign key columns in the table which i have to check if they exist beforedeleting a row.Thanks!ZK

View Article


How can I speed up this date-range intersect query?

In the table below I have 270,000+ rows.There is only one value for Customer, but there will be more later.There are only 42 values for ProductTag, but most are one of only 10 different ones.The update...

View Article

Image may be NSFW.
Clik here to view.

SELECT data from preceding row of result set when the current row has a NULL

The query below produces a result set with two rows of data.  One row of data has nulls for User_Number and User_Name.  The other row has this info.  I need to grab the User_Number and User_Name from...

View Article

Need help with the TSQL.

I have 2 tables and need to check if the record exist in the #diagnose table and meet the rules below than return it. I have the query below but need your help to get the desired output below. SQL 2008...

View Article


Causes for "Snapshot isolation transaction failed"???

What are the possible  causes of a "Snapshopt isolation transaction failed...DDL" message?I have a production database of 250 million row that has been running very well for years.We do use snapshot...

View Article


Lock a row after SELECT and release after UPDATE

Hi All,Here’s what I’m trying to achieve. DDL -IF OBJECT_ID(N'FirstTab', N'U') IS NOT NULL DROP TABLE FirstTab; GO CREATE TABLE FirstTab (Id INT IDENTITY(1,1) PRIMARY KEY , StartVal INT,EndVal INT)...

View Article

Avoid Multiple user select the same row

Dear All,I want to avoid multiple users select the same row at the same time.I have used rowlock concept. its not working.select top(1) * from tablename with (rowlock)

View Article

triggers

premises : i am more of a developer and planner than of a DBA                 i test stranger things in proceduresnow i have a situation in which 1 one temp table has the following schema (grouper int...

View Article

TSQL to find the date difference between two rows of same column

Hello everyone,I have scenario, in which I need to group set of data from table based on ID, price , quantity and if the start date between the records is successive)In the below mentioned record, I...

View Article


Using TOP in a function

I would like to modify this function to concatenate/return just the TOP 6 values. I have tried many things. Can anyone help? Thanks! CREATE FUNCTION [dbo].[Rpt_ConcatSecondaryDxIds] (@VisitNumber...

View Article

SQL Server 2005 \ Subquery help

Hello,Is there a way to combine the 2 select statements pasted below?  I want to use the second select as a NOT IN select statement.  I want to select the data from the first select and be sure to NOT...

View Article


Getting query result set faster from table

Hi Experts,In one table, I've nearly 150,000 records.When I am doing SELECT column1,column2,column3 FROM tableName (NOLOCK)its taking nearly 9 minutes to get the complete result set.I've one clustered...

View Article

mutiple queries in single stored procedure performance

Is it good to have same sp for all features such as filter, getting data, inserting or we should write diferrent sp for all.

View Article


Query Optimization

hi,          Thanks for u r extreme help in advance, please help me in optimizing the below query, the table names are highlighted which...

View Article

Failed conversion from varchar to int for negative decimal "-119.00"

So, if you take a look at the following bit of code it produces the following error:     declare @x varchar(30)=-119.00     select @x     select cast(@x as int)"Conversion failed when converting the...

View Article

Time Hierarchy

Hello,I am trying to create hierarchy for time dimension which I not getting it extactly what I need.Can anyone help me out in creating a simple time hierarchy.Thanks,Mani

View Article
Browsing all 23857 articles
Browse latest View live


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