Viewing 15 posts - 6,976 through 6,990 (of 10,143 total)
cimbom_kid (11/30/2010)
Many thanks for your help, but the query doesn't return the results i need. The resulting query should be:
linenum, fileline, group_id
1 a, 1
2 b, 1
3 c, 1
4...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 30, 2010 at 6:52 am
DROP TABLE #TMP_LOADER
CREATE TABLE #TMP_LOADER (
linenum int IDENTITY (1, 1),
fileline varchar(max),
group_id int)
INSERT INTO #TMP_LOADER (fileline)
SELECT 'a' UNION ALL
SELECT 'b' UNION ALL
SELECT 'c' UNION ALL
SELECT '------' UNION ALL
SELECT 'd' UNION...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 30, 2010 at 5:41 am
You're welcome Dan, thanks for the generous feedback.
Don't forget in future to always include sample data.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 30, 2010 at 4:30 am
Thanks Dan.
SELECT rn = ROW_NUMBER() OVER(ORDER BY JobNo, Line),
Line, JobNo, PropRef, Cont, RepDate, RepTime, LogDate, LogTime, ShortDesc, Access, JobDesc, ClientJob
FROM (
SELECT Line, JobNo, PropRef, Cont, RepDate, RepTime, LogDate, LogTime,...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 30, 2010 at 4:13 am
Try this, untested of course - no sample data to test against!
DROP TABLE #Table
CREATE TABLE #Table (
JobNo CHAR(5),
...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 30, 2010 at 3:28 am
Dan, if you set up the sample data like I suggested, it will be instantly usable. Not many folks will be inclined to do the formatting for you.
SELECT 'JobNo', 'Ref',...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 30, 2010 at 3:07 am
Dan
Copy the following code and paste it into an SSMS window. Correct the DDL to match your table then amend the INSERT script to provide say 10 rows of data...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 30, 2010 at 2:36 am
darunsurey (11/29/2010)
I need to know whether we can use corelated sub query in case satatements.Arun
Yes you can but it's rarely a good idea.
darunsurey (11/29/2010)
I have a student table, employee table,...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 29, 2010 at 7:15 am
RichardDouglas (11/27/2010)
Duplicate post due to refresh error
Haha! That's how I ended up posting "What's next"!
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 29, 2010 at 2:12 am
Sorry my bad - this matches your original requirement in your first post.
You would benefit from experimenting with the code and understanding how it works:)
DECLARE @Today DATETIME, @nMonths TINYINT
SET...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 25, 2010 at 10:05 am
Which query are you running? If you altered the code, best post it here.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 25, 2010 at 9:43 am
kevin4u06 (11/24/2010)
This is the table and sample data (Attached below)my out put shoud be something like this.
My function does the splitting of the address field .
Thank you in advance
You might...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 25, 2010 at 8:55 am
Kelvin Phayre (11/25/2010)
From your data.
INSERT INTO @Table2 VALUES (01,'P1','01/01/2010',100),
...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 25, 2010 at 6:55 am
-- Make a couple of sample tables
CREATE TABLE #Table1 (wh CHAR(2), item CHAR(2), stock INT)
INSERT INTO #Table1 (wh, item, stock)
SELECT '01','P1',1 UNION ALL
SELECT '02','P1',1 UNION ALL
SELECT '03','P1',1
CREATE TABLE #table2 (wh...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 25, 2010 at 6:53 am
-- use an INNER JOIN if the data permits
-- i.e. if every header has at least one line, and always will.
-- Option 2
SELECT
h.GroupHeaderID,
h.GroupName,
MemberCount = COUNT(*)
FROM table_A h
LEFT JOIN table_B l...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
November 25, 2010 at 6:37 am
Viewing 15 posts - 6,976 through 6,990 (of 10,143 total)