Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query issue

Status
Not open for further replies.

ace333

Programmer
Jul 12, 2005
105
CH
The following query wont work because GO needs to be on a separate line, is there a way I can force a new line in there. I can use a stored proc because I am joining a few tables together.... I want to force sql server to treat SET ANSI_NULLS OFF
GO
SELECT.... on separate lines

SET ANSI_NULLS OFF GO select '1' as CommentId, 'RCRF' as DacType, R.Id as SheetId, R.AmendmentInstructions as Comments, 'Comment' as TypeOfComment, D.ExternalID as [RiskId\ExternalId],D.AmendedByUserId as UserId, (select FullName from SecurityUsers where UserId = D.AmendedByUserId) FullName, D.AmendedDateTime from dbo.ITRR_RCRFDetailComments R, RCRFDetail D where R.Id *= D.Id and R.AmendmentInstructions *=D.AmendmentInstructions and R.AmendmentInstructions not in ('', NULL) union select '1' as CommentId,'RCRF' as DacType, R.Id as SheetId, R.ApproverComments as Comments,'RejectedComment' as TypeOfComment,D.ExternalID as [RiskId\ExternalId], D.AmendedByUserId as UserId, (select FullName from SecurityUsers where UserId = D.AmendedByUserId) FullName,D.AmendedDateTime from ITRR_RCRFApproverComments R, RCRFDetail D, SecurityUsers S where R.Id *= D.Id and R.ApproverComments *=D.ApproverComments and R.ApproverComments not in ('', NULL) union select '1' as CommentId,'DAC' as DacType, R.Id as SheetId, R.Comments, 'Comment' as TypeOfComment,D.RiskId, D.AmendedByUserId as UserId, (select FullName from SecurityUsers where UserId = D.AmendedByUserId) FullName,D.AmendedDateTime from ITRR_DacDetailComments R, DacDetail D where R.Id *= D.Id and R.Comments *=D.Comments and R.Comments not in ('', NULL) union select '1' as CommentId,'DAC' as DacType, R.Id as SheetId, R.RejectedComments as Comments,'RejectedComment' as TypeOfComment,D.RiskId, D.AmendedByUserId as UserId, (select FullName from SecurityUsers where UserId = D.AmendedByUserId) FullName,D.AmendedDateTime from ITRR_DacDetailRejectedComments R, DacDetail D where R.Id *= D.Id and R.RejectedComments *=D.RejectedComments and R.RejectedComments not in ('', NULL) union select '1' as CommentId,'CAP' as DacType, R.CapId as SheetId, R.Comments, 'Comment' as TypeOfComment, D.CurrentRiskId,D.AmendedByUserId as UserId, (select FullName from SecurityUsers where UserId = D.AmendedByUserId) FullName, D.AmendedDateTime from dbo.ITRR_CAPDetailComments R, CapDetail D where R.CapId *= D.CapId and R.Comments *=D.Comments and R.Comments not in ('', NULL) union select '1' as CommentId,'CAP' as DacType, R.CapId as SheetId, R.RejectedComments as Comments,'RejectedComment' as TypeOfComment,D.CurrentRiskId, D.AmendedByUserId as UserId, (select FullName from SecurityUsers where UserId = D.AmendedByUserId) FullName,D.AmendedDateTime from ITRR_CapDetailRejectedComments R, CapDetail D where R.CapId *= D.CapId and R.RejectedComments *=D.RejectedComments and R.RejectedComments not in ('', NULL) union select '1' as CommentId,'MODAC' as DacType, R.Id as SheetId, R.MiddleOfficeComments as Comments, 'MiddleOfficeComment' as TypeOfComment, D.RiskId, (select FullName from SecurityUsers where UserId = D.AmendedByUserId) FullName,D.AmendedByUserId as UserId, D.AmendedDateTime from ITRR_MODacDetailComments R, MODacDetail D where R.Id *= D.Id and R.MiddleOfficeComments *=D.MiddleOfficeComments and R.MiddleOfficeComments not in ('', NULL) union select '1' as CommentId,'MODAC' as DacType, R.Id as SheetId, R.RequestorComments as Comments,'RequestorComment' as TypeOfComment,D.RiskId, D.AmendedByUserId as UserId, (select FullName from SecurityUsers where UserId = D.AmendedByUserId) FullName,D.AmendedDateTime from ITRR_RequestorComments R, MODacDetail D where R.Id *= D.Id and R.RequestorComments *= D.RequestorComments and R.RequestorComments not in ('', NULL)
 
Ace,

Cut and paste this into QA and then use carriage return between each line. Include the "Create Procedure as <name>" line before all of this. Then run it and QA will create the procedure. (Although I'm pretty sure the GO will need to be taken out of your SP and I'm not sure setting Ansi_Nulls will work from within an SP).

What program are you using, anyway, that's causing you such problems with putting things on seperate lines?



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
For starters, this looks like memory dump redirected to stdout. :E

Plz post the same code again with TGML tags ([ignore]
Code:
....
[/ignore]). For more info click on link below message textarea.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top