SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Display ALL rows even if no data exists


Display ALL rows even if no data exists

Author
Message
sgmunson
sgmunson
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17199 Visits: 4634
pwalter83 (8/18/2014)
sgmunson (8/18/2014)
Okay, so now the excuse for not explaining EVERYTHING is that some of the columns aren't in use??? Really? Sorry, but I'm done with this. Every explanation I've seen so far has done little or nothing to make this the slightest bit more clear. This person simply can't be bothered, and seems more interested in leading a chase than actually getting useful answers. I'm simply not willing to help someone that insists on playing this game.


Can you just not reply instead of writing provocatively to discourage others from providing solutions ?



Can you just post what you were asked for repeatedly instead of avoiding it like the plague? I'm absolutely certain it would get better results than what you've provided so far.

Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
J Livingston SQL
J Livingston SQL
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12125 Visits: 37529
pwalter83 (8/18/2014)
sgmunson (8/18/2014)
Okay, so now the excuse for not explaining EVERYTHING is that some of the columns aren't in use??? Really? Sorry, but I'm done with this. Every explanation I've seen so far has done little or nothing to make this the slightest bit more clear. This person simply can't be bothered, and seems more interested in leading a chase than actually getting useful answers. I'm simply not willing to help someone that insists on playing this game.


Can you just not reply instead of writing provocatively to discourage others from providing solutions ?



I, for one, would be happy to consider your problem...but from reading thro this thread...I have to agree that DDL and sample data (and the expected results based on your sample data) would help considerably.

so far all I see is DDL for two tables (out of six?) and no sample data or expected results.

I would expect that if you provide what has been requested that your problem can be resolved quickly and with tried and tested code.

kind regards

edit typos

________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day

ChrisM@Work
ChrisM@Work
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41274 Visits: 20002
J Livingston SQL (8/18/2014)
pwalter83 (8/18/2014)
sgmunson (8/18/2014)
Okay, so now the excuse for not explaining EVERYTHING is that some of the columns aren't in use??? Really? Sorry, but I'm done with this. Every explanation I've seen so far has done little or nothing to make this the slightest bit more clear. This person simply can't be bothered, and seems more interested in leading a chase than actually getting useful answers. I'm simply not willing to help someone that insists on playing this game.


Can you just not reply instead of writing provocatively to discourage others from providing solutions ?



I, for one, would be happy to consider your problem...but from reading thro this thread...I have to agree that DDL and sample data (and the expected results based on your sample data) would help considerably.

so far all I see is DDL for two tables (out of six?) and no sample data or expected results.

I would expect that if you provide what has been requested that your problem can be resolved quickly and with tried and tested code.

kind regards

edit typos


I'm also still in. Paul, can you please provide INSERTs to populate the two tables with say 30 or 40 rows of data? I think it could go a long way to sorting this out. Cheers.

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

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
Exploring Recursive CTEs by Example Dwain Camps
pwalter83
pwalter83
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2754 Visits: 2174

I'm also still in. Paul, can you please provide INSERTs to populate the two tables with say 30 or 40 rows of data? I think it could go a long way to sorting this out. Cheers.


Thank you all for your eagerness to help.

On popular demand :-), please find the DDL and sample data for all the tables used in the query below. Just a humble request, could you please use the query below as the basis for your code as it returns correct resultset in terms of row counts. I mean I wish to use the functionality of my query but at the same time want to show all the listed countries as shown in the attached screenshot (2 examples) if no data exists.

Thanks a lot.



CREATE TABLE [dbo].[MG_OFFICE](
[OFFICE_CD] [varchar](10) NOT NULL,
[COUNTRY_CD] [varchar](2) NULL)


insert into [MG_OFFICE]
values('KBE ANR', 'BE')
insert into [MG_OFFICE]
values('KBE ZEE', 'BE')
insert into [MG_OFFICE]
values('KEU ANR', 'BE')
insert into [MG_OFFICE]
values('KDE DUS', 'DE')
insert into [MG_OFFICE]
values('KDE BRE', 'DE')
insert into [MG_OFFICE]
values('KDE FRA', 'DE')
insert into [MG_OFFICE]
values('KDE HAM', 'DE')
insert into [MG_OFFICE]
values('ESBLR BCN', 'ES')
insert into [MG_OFFICE]
values('ESBLR MAD', 'ES')
insert into [MG_OFFICE]
values('ESBLR SDR', 'ES')
insert into [MG_OFFICE]
values('ESBLR TAR', 'ES')
insert into [MG_OFFICE]
values('EESCR TLL', 'EE')
insert into [MG_OFFICE]
values('KDE GDY', 'DE')
insert into [MG_OFFICE]
values('KRU LED', 'RU')
insert into [MG_OFFICE]
values('LTLIM KLJ', 'LT')
insert into [MG_OFFICE]
values('KEU RTM', 'NL')
insert into [MG_OFFICE]
values('KNL RTM', 'NL')
insert into [MG_OFFICE]
values('KFR BOD', 'FR')
insert into [MG_OFFICE]
values('KFR DKK', 'FR')
insert into [MG_OFFICE]
values('KFR FOS', 'FR')
insert into [MG_OFFICE]
values('KFR LEH', 'FR')
insert into [MG_OFFICE]
values('KFR LIO', 'FR')
insert into [MG_OFFICE]
values('KSE HES', 'SE')
insert into [MG_OFFICE]
values('KSE-JV GOT', 'SE')
insert into [MG_OFFICE]
values('KSE-JV HES', 'SE')



CREATE TABLE [dbo].[MG_COUNTRY](
[COUNTRY_CD] [varchar](2) NOT NULL,
[COUNTRY_DSC] [varchar](35) NOT NULL
)

insert into [MG_COUNTRY]
values('BE', 'BELGIUM')
insert into [MG_COUNTRY]
values('FR', 'FRANCE')
insert into [MG_COUNTRY]
values('SE', 'SWEDEN')
insert into [MG_COUNTRY]
values('ES', 'SPAIN')
insert into [MG_COUNTRY]
values('NL', 'NETHERLANDS')
insert into [MG_COUNTRY]
values('RU', 'RUSSIA')
insert into [MG_COUNTRY]
values('EE', 'ESTONIA')
insert into [MG_COUNTRY]
values('LT', 'LITHUANIA')


CREATE TABLE [dbo].[MG_BOOKING](
[BOOKING_ID] [numeric](10, 0) NOT NULL,
[BOOKING_NUM] [varchar](15) NULL,
[BOOKING_OFFICE_CD] [varchar](10) NULL,
[BOOKING_STATUS_CD] [char](1) NULL,
[POL_LOCATION_CD] [varchar](5) NULL
)

INSERT INTO [MG_BOOKING]
values('1','A1','KBE ANR','F','BEANR')
INSERT INTO [MG_BOOKING]
values('2','A2','KBE ANR','P','BEANR')
INSERT INTO [MG_BOOKING]
values('3','A3','KBE ZEE','I','BEANR')
INSERT INTO [MG_BOOKING]
values('4','A4','KBE ZEE', 'H','BEANR')
INSERT INTO [MG_BOOKING]
values('5','B1','KDE DUS','F','NLRTM')
INSERT INTO [MG_BOOKING]
values('6','B2','KDE DUS', 'I','NLRTM')
INSERT INTO [MG_BOOKING]
values('7','B3','KBE ZEE','P','NLRTM')
INSERT INTO [MG_BOOKING]
values('8','B4','KDE BRE','F','DEBRV')
INSERT INTO [MG_BOOKING]
values('9','C1','KDE BRE','F','DEBRV')
INSERT INTO [MG_BOOKING]
values('10','C2','KSE HES','H','DEBRV')
INSERT INTO [MG_BOOKING]
values('11','C3','KSE HES','I','DEBRV')
INSERT INTO [MG_BOOKING]
values('12','D4','KFR DKK','P','DEBRV')
INSERT INTO [MG_BOOKING]
values('13','D1','KFR DKK','P','CNTAO')
INSERT INTO [MG_BOOKING]
values('14','D2','LTLIM KLJ','I','SGSIN')
INSERT INTO [MG_BOOKING]
values('15','D3','LTLIM KLJ','I','CNSHA')
INSERT INTO [MG_BOOKING]
values('16','E1','ESBLR BCN','P','ESBCN')
INSERT INTO [MG_BOOKING]
values('17','E2','ESBLR BCN','F','ESBCN')
INSERT INTO [MG_BOOKING]
values('18','E3','EESCR TLL','H','ESBCN')
INSERT INTO [MG_BOOKING]
values('19','E4','ESBLR BCN','P','ESVLC')
INSERT INTO [MG_BOOKING]
values('20','E5','EESCR TLL','I','ESVLC')

CREATE TABLE [dbo].[MG_BOOKING_ITINERARY](
[BOOKING_ID] [numeric](10, 0) NULL,
[VESSEL_CD] [varchar](10) NULL,
[VOYAGE_CD] [varchar](12) NULL
)

INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('1','HSMB','22E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('2','JKB','B071S')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('3','CSCEX','005E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('4','GDGB','052E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('5','HJSP','0009E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('6','CSCEX','005E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('7','HNJEUR','0005E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('8','STPAO','016W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('9','HPHO','121W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('10','HPHO','122W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('11','HPHO','121W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('12','CSNGY','034W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('13','COSPRD','009W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('14','COSPRD','009W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('15','HMBB','038W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('16','HMBB','038W')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('17','HKGB','021E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('18','HKGB','021E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('19','YMUPSU','001E')
INSERT INTO [MG_BOOKING_ITINERARY]
VALUES('20','YMUPSU','001E')


CREATE TABLE [dbo].[MG_BOOKING_EQUIPMENT_REQ_DETAIL](
[EQUIPMENT_TYPE_CD] [varchar](5) NULL,
[BOOKING_ID] [numeric](10, 0) NOT NULL
)

insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20T86','1')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('40D96','2')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20T86','3')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('40D96','4')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20T86','5')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('40D96','6')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('40D96','7')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('45T96','8')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('40W96','9')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('45Y96','10')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20W96','11')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20W96','12')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('40W96','13')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20W96','14')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20W96','15')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('45W96','16')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('40W96','17')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20W96','18')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('40W96','19')
insert into [MG_BOOKING_EQUIPMENT_REQ_DETAIL]
values('20W96','20')




CREATE TABLE [dbo].[MG_CONTAINER_CODE](
[CONTAINER_CD] [varchar](5) NOT NULL,
[TYPE_CD] [varchar](3) NOT NULL
)

INSERT INTO [MG_CONTAINER_CODE]
VALUES('20W96','DRY')
INSERT INTO [MG_CONTAINER_CODE]
VALUES('40W96','RFR')
INSERT INTO [MG_CONTAINER_CODE]
VALUES('45T96','RFR')
INSERT INTO [MG_CONTAINER_CODE]
VALUES('40D96','RFR')
INSERT INTO [MG_CONTAINER_CODE]
VALUES('20T86','DRY')


SELECT   booking_num,  CASE 
WHEN mo.OFFICE_CD IN ('KBE ANR','KBE ZEE', 'KEU ANR') THEN 'BELGIUM'
WHEN mo.OFFICE_CD IN ('KDE VIE') THEN 'AUSTRIA'
WHEN mo.OFFICE_CD IN ('KDE BRE', 'KDE BRV', 'KDE DUS', 'KDE FRA', 'KDE HAM', 'KDE MUC', 'KDE STR') THEN 'GERMANY'
WHEN mo.OFFICE_CD IN ('KFR BOD','KFR DKK','KFR FOS','KFR LEH','KFR LIO','KFR MRS','KFR PAR','EXAF PARIS','FRBAL BOD','KEU LEH') THEN 'FRANCE'
WHEN mo.OFFICE_CD IN ('KEU RTM', 'KNL RTM') THEN 'NETHERLANDS'
WHEN mo.OFFICE_CD IN ('KDE PRG') THEN 'CZECH REPUBLIC'
WHEN mo.OFFICE_CD IN ('CHGLS BSL') THEN 'SWITZERLAND'
WHEN mo.OFFICE_CD IN ('KPT LIS','KPT OPO') THEN 'PORTUGAL'
WHEN mo.OFFICE_CD IN ('ESBLR BCN','ESBLR MAD','ESBLR SDR','ESBLR TAR','ESBLR VCL','ESBLR VGO','ESBLR VLC','KES BCN','KES BIO','KES MAD','KES VGO','KES VLC') THEN 'SPAIN'
WHEN mo.OFFICE_CD IN ('IEIRL DUB','IEIRL ORK') THEN 'IRELAND'
WHEN mo.OFFICE_CD IN ('KSE HES','KSE-JV GOT','KSE-JV HES') THEN 'SWEDEN'
WHEN mo.OFFICE_CD IN ('KFI HEL') THEN 'FINLAND'
WHEN mo.OFFICE_CD IN ('KDK AAL','KDK AAR','KDK CPH','KDK EBJ','KDK ODE','KDK-JV AAL','KDK-JV AAR','KDK-JV CPH','KDK-JV EBJ','KDK-JV ODE') THEN 'DENMARK'
WHEN mo.OFFICE_CD IN ('KNO OSL','KNO-JV OSL') THEN 'NORWAY'
WHEN mo.OFFICE_CD IN ('KDE GDY', 'EESCR TLL', 'KRU LED', 'LTLIM KLJ', 'LVKLS RIX', 'RUMET LED', 'RUMET MOW', 'RUMSA LED') THEN 'BALTIC' ELSE 'BUFFER' END AS COUNTRY_DSC,

CASE WHEN POL_LOCATION_CD IN ('DKAAR', 'DKCPH', 'FIHEL','FIKTK', 'IEORK', 'IEDUB', 'NLRTM', 'PTLEI', 'PTOPO', 'PTLIS', 'ESBIO', 'ESVGO', 'SEGOT', 'SEHEL', 'GBBEL') THEN 'NLRTM' WHEN POL_LOCATION_CD IN ('DKFRC',
'FIRAU', 'FIOUL', 'DEBRV', 'NOAES', 'NOBGO', 'NOFRK', 'NOHAL', 'NOHAU', 'NOKRS', 'NOKSU', 'NOLAR', 'NOMSS', 'NOOSL', 'NOTAE', 'PLGDY', 'SEGVX', 'SEMMA',
'SENRK', 'SESTO', 'DEHAM') THEN 'DEBRV' WHEN POL_LOCATION_CD = 'BEANR' THEN 'BEANR' WHEN POL_LOCATION_CD = 'FRLEH' THEN 'FRLEH' ELSE POL_LOCATION_CD END AS POL_LOCATION_CD,
CASE WHEN ber.EQUIPMENT_TYPE_CD LIKE '20%' THEN 1 ELSE 2 END AS TEU, mcc.TYPE_CD, mbi.VESSEL_CD, mbi.VOYAGE_CD

FROM MG_COUNTRY AS mc


right JOIN MG_OFFICE AS mo ON mc.COUNTRY_CD = mo.COUNTRY_CD
left join MG_BOOKING mgd on mgd.BOOKING_OFFICE_CD = mo.OFFICE_CD

left JOIN MG_BOOKING_EQUIPMENT_REQ_DETAIL AS ber ON mgd.BOOKING_ID = ber.BOOKING_ID

right JOIN MG_BOOKING_ITINERARY AS mbi ON

mgd.BOOKING_ID = mbi.BOOKING_ID


JOIN MG_CONTAINER_CODE AS mcc ON ber.EQUIPMENT_TYPE_CD = mcc.CONTAINER_CD

AND mgd.BOOKING_STATUS_CD IN ('H', 'F', 'I', 'P')



WHERE mbi.VESSEL_CD IN (@vessel) AND mbi.VOYAGE_CD IN (@voyage)
ORDER BY COUNTRY_DSC


Attachments
Screenshot.png (9 views, 27.00 KB)
sgmunson
sgmunson
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17199 Visits: 4634
Just a quick FYI to make everyone aware that the posted query doesn't work with the posted table inserts, and that you'll need to add a right paren to one of the table create statements as it's missing in the posted code. The query is looking for mgd.BOOKING_OFFICE_CD, and that table does not contain such a field, nor do any of the other tables. Note also that the OP has STILL NOT EXPLAINED the relevance of the individual tables to the desired result. Thus the posted code, for all practical purposes, is useless.

Some might complain that I had bowed out on this post, so why am I still responding? Simple, really... Between the arrogance of the OP posting the words "On popular demand", as if to indicate they had no intention of posting what was requested, and only did so when pushed into it; and the subsequent failure of the OP to even post usable code. I have to wonder if the OP is even qualified to perform the work at all...

That kind of disrespect in a post is not particularly excusable, and I'm not going to help this poster continue to waste anyone's time any further.

Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
pwalter83
pwalter83
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2754 Visits: 2174
sgmunson (8/19/2014)
Just a quick FYI to make everyone aware that the posted query doesn't work with the posted table inserts, and that you'll need to add a right paren to one of the table create statements as it's missing in the posted code. The query is looking for mgd.BOOKING_OFFICE_CD, and that table does not contain such a field, nor do any of the other tables. Note also that the OP has STILL NOT EXPLAINED the relevance of the individual tables to the desired result. Thus the posted code, for all practical purposes, is useless.

Some might complain that I had bowed out on this post, so why am I still responding? Simple, really... Between the arrogance of the OP posting the words "On popular demand", as if to indicate they had no intention of posting what was requested, and only did so when pushed into it; and the subsequent failure of the OP to even post usable code. I have to wonder if the OP is even qualified to perform the work at all...

That kind of disrespect in a post is not particularly excusable, and I'm not going to help this poster continue to waste anyone's time any further.


If you can see properly, I posted a smiley next to 'On popular demand' as it was intended to be in humour.

Just to make you aware, I reported you yesterday for your provocative post and I am going to report you now again for the similar thing you have done now.

You just CANNOT force members to not reply to a post.

Hope you get banned soon.
sgmunson
sgmunson
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17199 Visits: 4634
I'm pretty sure I can't force anyone to do anything. I don't need to. Clearly, you'd rather complain than actually solve your problem. You need to realize that when you are getting free assistance, biting the hand that feeds you is a bad idea. Continually avoiding providing any useful information is also a pretty good way to stop getting help. I'm pretty sure any lack of assistance coming from other members will be appropriately proportional to your lack of respect for the value of the time of those providing such assistance.

Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
pwalter83
pwalter83
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2754 Visits: 2174
sgmunson (8/19/2014)
I'm pretty sure I can't force anyone to do anything. I don't need to. Clearly, you'd rather complain than actually solve your problem. You need to realize that when you are getting free assistance, biting the hand that feeds you is a bad idea. Continually avoiding providing any useful information is also a pretty good way to stop getting help. I'm pretty sure any lack of assistance coming from other members will be appropriately proportional to your lack of respect for the value of the time of those providing such assistance.


I am not asking for your assistance anymore so stop replying. You have done enough damage now.
ChrisM@Work
ChrisM@Work
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41274 Visits: 20002
Paul, if you wouldn't mind running through your sample script and correcting the errors which Steve kindly pointed out, I'll take a look later today.

“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

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
Exploring Recursive CTEs by Example Dwain Camps
pwalter83
pwalter83
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2754 Visits: 2174
ChrisM@Work (8/20/2014)
Paul, if you wouldn't mind running through your sample script and correcting the errors which Steve kindly pointed out, I'll take a look later today.

Hi Chris,

The sample script is working okay with the SQL query. could you please give some suggestion if you have some time.

Thanks.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search