Link to home
Start Free TrialLog in
Avatar of robynum
robynum

asked on

View will not save

I have created a view with the folowing code:

SET              CONCAT_NULL_YIELDS_NULL OFF;
                          SELECT     RMALineItems.RMANo AS [RMA #], MiradorClient.Client AS Customer, RMAs.RMANumber AS [Original Invoice #], RMAs.DateAuthorized,
                                                  MiradorOrders.ClientPO, (clientsku + ' ' + subpartnum) AS SKU, RMAs.NumberPieces, RMAs.Amount
                           FROM         ((MiradorClient INNER JOIN
                                                  ((RMALineItems INNER JOIN
                                                  RMAs ON RMALineItems.RMANo = RMAs.RMANo) INNER JOIN
                                                  Products ON RMALineItems.ProductID = Products.ProductID) ON MiradorClient.ClientID = RMAs.ClientID) INNER JOIN
                                                  Invoice ON RMAs.RMANumber = Invoice.InvoiceID) INNER JOIN
                                                  MiradorOrders ON Invoice.Morder = MiradorOrders.ClientOrderID
                           WHERE     (((RMAs.DateAuthorized) > Dateadd(mm, - 6, CURRENT_TIMESTAMP)) AND ((RMAs.Complete) = 0))
                           ORDER BY RMAs.DateAuthorized

When I go to save it, it gives me an error near "SET". I have to turn NULL YIELDS OFF or all of my data comes back NULL in that combined field.

Can someone help?

Thanks,
R
Avatar of Aneesh
Aneesh
Flag of Canada image

You can't specify SET inside the view
remove that line SET              CONCAT_NULL_YIELDS_NULL OFF
Avatar of robynum
robynum

ASKER

I have to use something like it to have the View work properly.
use the query analyser to run the CREATE VIEW statement:

SET              CONCAT_NULL_YIELDS_NULL OFF;
CREATE VIEW yourviewname
AS
                          SELECT     RMALineItems.RMANo AS [RMA #], MiradorClient.Client AS Customer, RMAs.RMANumber AS [Original Invoice #], RMAs.DateAuthorized,
                                                  MiradorOrders.ClientPO, (clientsku + ' ' + subpartnum) AS SKU, RMAs.NumberPieces, RMAs.Amount
                           FROM         ((MiradorClient INNER JOIN
                                                  ((RMALineItems INNER JOIN
                                                  RMAs ON RMALineItems.RMANo = RMAs.RMANo) INNER JOIN
                                                  Products ON RMALineItems.ProductID = Products.ProductID) ON MiradorClient.ClientID = RMAs.ClientID) INNER JOIN
                                                  Invoice ON RMAs.RMANumber = Invoice.InvoiceID) INNER JOIN
                                                  MiradorOrders ON Invoice.Morder = MiradorOrders.ClientOrderID
                           WHERE     (((RMAs.DateAuthorized) > Dateadd(mm, - 6, CURRENT_TIMESTAMP)) AND ((RMAs.Complete) = 0))
                           ORDER BY RMAs.DateAuthorized
Avatar of robynum

ASKER

I get the message that:

"Create View" must be the first statement in a Query Batch.

:(
Avatar of robynum

ASKER

Any other ideas? I am really stumped on this one.

Thanks
SET              CONCAT_NULL_YIELDS_NULL OFF;
GO
CREATE VIEW yourviewname
AS
                          SELECT     RMALineItems.RMANo AS [RMA #], MiradorClient.Client AS Customer, RMAs.RMANumber AS [Original Invoice #], RMAs.DateAuthorized,
                                                  MiradorOrders.ClientPO, (clientsku + ' ' + subpartnum) AS SKU, RMAs.NumberPieces, RMAs.Amount
                           FROM         ((MiradorClient INNER JOIN
                                                  ((RMALineItems INNER JOIN
                                                  RMAs ON RMALineItems.RMANo = RMAs.RMANo) INNER JOIN
                                                  Products ON RMALineItems.ProductID = Products.ProductID) ON MiradorClient.ClientID = RMAs.ClientID) INNER JOIN
                                                  Invoice ON RMAs.RMANumber = Invoice.InvoiceID) INNER JOIN
                                                  MiradorOrders ON Invoice.Morder = MiradorOrders.ClientOrderID
                           WHERE     (((RMAs.DateAuthorized) > Dateadd(mm, - 6, CURRENT_TIMESTAMP)) AND ((RMAs.Complete) = 0))
                           ORDER BY RMAs.DateAuthorized
Avatar of robynum

ASKER

OK...when I run this in the Analyzer it does create the view I want, but it drops the: SET              CONCAT_NULL_YIELDS_NULL OFF; portion of the view. I have to be able to turn the NULL Yields Off to make the field work properly.

Any ideas?

Thanks,
R
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
change your sql database setting to have CONCAT_NULL_YIELD_NULL off instead of doing it for each connection.


ALTER DATABASE YourDatabaseName SET CONCAT_NULL_YIELDS_NULL   OFF
GO
Avatar of robynum

ASKER

Thanks everyone...AngelIII got it set up perfectly. I am still very new at coding SQL, and I really appreciate all of the help.

R