Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Browsing all 3145 articles
Browse latest View live

DECIMAL vs NUMERIC for ID values

We have ID columns with values with up to 10 digits. Those ID's are usually third (and last) segment in indices on various tables. Normally I define them as NUMERIC(10), but looking into other people's...

View Article


Include the first zero when converting time from datime into INT

I have [quote]declare @t datetime = '2016-11-02 07:22:26.320'SELECT LEFT(CAST(REPLACE(CONVERT(VARCHAR, @t, 108), ':', '') AS INT), 6)[/quote]which gives me INT value of 72226, and I want it to include...

View Article


Using Lag/Lead and OVER() to get growth pattern

Hi Guys,I've got a bit of a query problem that I am not quite getting where to start, to be honest. I think I know what bits I need to use just not sure how to bash all the parts together:I have a...

View Article

WITH INDEX hint

I was recently trying to optimize a big SQL statement (a dozen of JOINs and APPLYs), commenting some joins and filters and looking at execution times and plans until I pinpointed the "culprit" JOIN...

View Article

Is my use case a good fit for Unpivot and Pivot ?

I've been trying to use dynamic unpivot and pivot (thanks to some code examples from someone named "bluefoot" on stackoverflow that was posted in answer to a question three years ago) to solve the...

View Article


Drill down values...

Hi,I've an orders table with customer and supplier (customer_id, supplier_id, order_id, order_date, ...)Is it possible to get the total orders from a customer and drill down to the supplier in the same...

View Article

Dynamic pivot and its effect on the plan cache

We have a heavily used GUI that displays specific business data in a pivot.A stored procedure is used to create the pivot, using dynamic SQL.The SP is using EXEC sp_executesql with parameters in the...

View Article

join two tables on Column where column has value specified more than once

I have two tables with below datatable 1Id name company1 aaa yyy1 aaa bbbtable 2Id designation1 manager1 managerWhen I join these on ID, I get 4 rows but instead I want to get two rows.target table:Id...

View Article


SUM and Group using IN clause

Hi, I am looking for a way to create a query to SUM and Group BY by using IN clause similiar to below.Is this possible or is another method recommended?SELECT CID, SUM(Hours) WHERE CID IN mycodes,FROM...

View Article


how to trace the effected table when a primary table is updated/inserted

Hi,When we update/insert any table how do we know which other tables are effected in sql server? If we are using SQL profiler how do we set it up?

View Article

Questions on filetables

Currently we have a process that dumps 20 million records into regular tables in database every 15 minutes. The data is transitory and we only need to keep it for 24 hours. Since the data is transitory...

View Article

Split Record by Field into Multiple Records

Hello all,I have a table that I need to split up the records into multiple records by and Integer field. Here is what the table is like and what it should look like. Thanks/*** This is the Original...

View Article

Sproc/view/function code parser

Hi - I'm looking for a code parser for SQL Server 2014 - ie something that I can point at a sproc or view or function and get feedback as regards code quality, readability bulletproofing...

View Article


Determine if a table column is used?

Does anyone know if there's any way you can determine if a column in a table is used or not?I have a table with 926 columns (I didn't build this), of which about 850+ of them appear to have NULL values...

View Article

Indexes on Views - with UNION

Hi Team,Want to create a view using below query, and also want to apply indexes on that view.[quote]SELECT NT.ID, U.acc_name FROM dbo.NR_VT NT WITH (NOLOCK), dbo.ACCOUNTS U WITH (NOLOCK)WHERE NT.VT =...

View Article


The financial situations of the various top tier teams.

[url=https://gapp.usc.edu/sites/default/files/webform/HD-Vargas-vs-Pacquiao-Live-Stream-2016-PPV-Big-Fight-results-and-round-by-round-5-Nov-2016.pdf]Vargas vs Pacquiao Live Streaming[/url]

View Article

where condition on same column doesnt return data

i have a question, below query doesn't return any data. application is allowing filters on same column. Is there any other to make it work[code="plain"]/*-------------------------Drop temp...

View Article


How to use a CSV as parameter in a query

I always used a query with an(one) integer parameter, but now it has to change to more integers in the parameter. [u]Before:[/u]DECLARE @Param INT SET @Param = 1SELECT * FROM Trips WHERE TripID =...

View Article

ERROR INSERT with db link 4 partname to oracle

i have somthing strnage.when i run this command in mssql insert into [LinkedSRV]...[xfer_in_order] (seq_id, action_type, action_code)values(2001, 'PTL_TEST', 'M') i get error :OLE DB provider...

View Article

Inserting records failing everyday

We have one schedule job which dropping and inserting records into table on daily basis. But this job is failing due to "Could not allocate space for object 'dbo.SORT temporary run storage:...

View Article
Browsing all 3145 articles
Browse latest View live