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)
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)