Quantcast
Channel: SQLServerCentral » SQL Server 2012 » SQL Server 2012 - T-SQL » Latest topics
Browsing index pages (4901 articles)

Split sting by hypens

Hi Guys,I have one task to derived column values by splitting the string by hypensbelow is the DDL,[code language="sql"]CREATE TABLE #TABLE(COL VARCHAR (100) )INSER

View Article


Recursive CTE Duplication

Hi all,I am working on a system that has Business units and a Parent\Child relationship.I am trying to write a CTE that will show me all of the descendants for any given BU.  I feel i am nearly there.

View Article


deleting duplicates, even though different key values

Is there a way of deleting duplicates, even though different key values? e.g.:123 Mary Kay124 Mary Kay125 Bob Incus126 Bob Incusget rid of only one of the duplicates like leave 123, delete 124

View Article

need help with writing query to retrieve info stored in multiple columns

I need help with creating query to retrieve info stored in multiple columns.  Below you can find sample table/info with current output and the required/preferred output.Tablecreate table...

View Article

Excluding values using NOT IN not working

I posted last week or so about joining results to an existing table and I tried all the responses but nothing worked. I wanted to make a test mockup of data so it might explain it better

View Article


Running out of TempDB when using MERGE Query

Hello,We have a .NET application that executes a stored procedure in SQL that runs a Merge Query for UPDATES, INSERTS, DELETES.  I know the MERGE runs a single batch.  The source table that is being...

View Article

t-sql 2012 sum of several fields

In the t-sql 2012 orig sql listed below, I am trying to determine how to tell if at least 2 or more of the following values are not null:The fields that I am looking for to be not null are the...

View Article

get percentage of sale quantity based on items from same group verses the -12...

So in the example I divide the quantity of each item by the quantity of 230-12. I would like to do this in the QUERY . The results will be a long list of different PartClasses, Partgroup's and PartID's...

View Article


Split strings by space into individual rows

Hi,String operations are one of my weakest areas in SQL. My requirement is to split strings separated by spaces with different lengths. Products column contains product information for each activity...

View Article


Convert xml column data from x and shred the elements into a tabular structure.

I am looking to have the xml column converted into a table. Basically shred the xml into columns. I am not familiar with XML and tried a tad bit of stuff but couldn't make any progress. Any help would...

View Article

Alternative to sp_OACreate, sp_OAMethod, and sp_OADestroy call a url for...

I have created the following sproc for calling a URL to return XML. However, we dont have access to run sp_OAMethod. The call is below. My question is there an alternative way to call a URL to return XML?

View Article

Convert function and omitting the optional length parameter

I'm keen to use the convert function to convert many (100s) of nvarchar columns to varchar columns via creation of a view and an SSIS package.Each column has different length or many of them do.If I...

View Article

Joining a result set to a base table

I have a weird one that is hard to explain.So I am looking for any Providers that are not listed as a Primary.  So I did a select PROVID from PROVSPECIALTY  (#primary) table which gives me about 73000...

View Article


How to return a value if an INNER JOIN isn't satisfied?

Hi,I have Historical T-SQL query as below:SELECT<

View Article

trimming SSNs

I have thousands of social security numbers I need to trim to leave only the last 4 digits... it is in a varchar field as xxx-xx-xxxx sometimes, but others are in xxxxxxxxx format and some scraps are...

View Article


Union with co-related subquery

I am trying to take MAX(date) from the result set of three different tables using a UNION operator. so here is the query I used. But I am getting the error like "The column prefix 'e' doesnot match...

View Article

Issue updating columns for existing rows

Hi there,so I have this table I've added additional columns to. For existing rows I want to update the columns with new values. PK_Time is a Primary Key int and represents the date as YYYYMMDD and SSMS...

View Article


I‌ wanted to run a stored proc over 500 databases in production.

Hello Room,I'm not hundred percent sure on how to program in T-SQL.I wanted to run a stored proc over  500 databases in production.and, the stored procedures will detect the  expensive stored proc on...

View Article

Job Schedule KO / SQL Server 2012R2

Hello everyone.Let me first explain what the job does. Basically it executes a T-SQL query (customer data) puts the data in an excel file then send it by email.This job works perfectly when I run it...

View Article

query regarding compare-object output

Hello ,Can anybody help me with below :compare-object (get-content file1.txt) (get-content file.txt)| where { $_.SideIndicator -eq '<='}InputObject          SideIndicator<

View Article
Browsing index pages (4901 articles)


Latest Images