The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
26 views

CROSS APPLY on Scalar function

I have this type of Code SELECT A ,B ,dbo.Func(C) ,dbo.Func(D) ,dbo.Func(E) ,F FROM abcdef WHERE 0 = dbo.Func(C) + dbo.Func(D) I read that this is not good practice because function is called ...
0
votes
1answer
866 views

Pivoting some row data into columns (SQL Server 2008 R2)

Sorry if this has been answered before but I'm exhausted and on a time line. Maybe I'm just an idiot. I'm designing a data export from One application to import into another. Full-Disclosure: I did ...
3
votes
2answers
2k views

Outer Apply vs Left Join Performance

I am Using SQL SERVER 2008 R2 I just came across APPLY in SQL and loved how it solves query problems for so many cases, Many of the tables I was using 2 left join to get the result, I was able to ...
3
votes
0answers
330 views

CROSS APPLY giving 'incorrect syntax' error on one SQL Server 2008 R2 database, with compat level = 100? [closed]

I'm copying a stored procedure from a test database to a production one. Both are on SQL 2008 R2 servers, but test has SP 2 installed and prod is still RTM. The same CREATE PROCEDURE code will run ...
4
votes
1answer
523 views

NEWID() In Joined Virtual Table Causes Unintended Cross Apply Behavior

My actual work query was an inner join, but this simple example with cross join seems to nearly always reproduce the problem. SELECT * FROM ( SELECT 1 UNION ALL SELECT 2 ) AA ( A ) CROSS JOIN ...
4
votes
1answer
345 views

How Can the Same Query in Two Nearly Identical Instances Generate Two Different Execution Plans?

Server A and Server B have identical hardware and instance configurations (A is Production, B is QA). B's DBs were restored from A's backups from one week ago. I was provided this query by the ...
2
votes
2answers
335 views

Cross Apply without a function

I would like to run a query very similar to this on one of my production databases: -- Setup the table (Already there in my real scenario) create table dbo.MyTable(MyValue int, MyGroup varchar(5)) ...
0
votes
3answers
121 views

How to convert query results into groups of common results

I have a query that returns results like this: MyValue MyGroup _______________|_______________ 56 | I _______________|_______________ 12 | I ...
5
votes
1answer
456 views

Build a three table join with a recusive table in the middle?

I have three relevant tables: Parts, PartGroup, and MarkupGroup. Parts is simple. PartID artificial primary key Part part number PartGroupID Foreign key sample data: 1 ...
3
votes
1answer
1k views

CROSS APPLY-ing a parameterised function

Given the following definitions: CREATE TABLE MyTable ( col1 int, col2 int, col3 int, col4 int ) CREATE FUNCTION fn_MyFunction ( @Param1 int, @Param2 int ) RETURNS TABLE AS ...
2
votes
0answers
784 views

how to split the column with cross apply in sql server 2008 [closed]

I have a table like this VM1 SPLA - WINSVRSTD #P19-9999 QTY 1 VM2 SPLA - WINS ST #P29-9 9 QTY 2 : SPLA - WINSVRENTAAA #P39- 9 9 99 QTY 3:SPLA - WINS ST #P29-9 9 QTY 2 : SPLA - WINSVRENTAAA ...