Advertisement
Guest User

Untitled

a guest
Jan 9th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 2.22 KB | None | 0 0
  1. SELECT DISTINCT TOP 250
  2.      Asset.AssetVersionId
  3.     ,Asset.AssetSnapshotId
  4.     ,Asset.AssetId
  5.     ,Asset.Title
  6.     ,Product.Title AS 'Model'
  7.     ,Brand.Title AS 'Brand'
  8.     ,Customer.Title AS 'Customer'
  9.     ,Customer.CustomerId
  10.     ,CustomerLocation.ServiceLocationId
  11.     ,Asset.AssetSnapshotId
  12.     ,ISNULL(AssetIdentifier_TagNumber.Value, '') AS 'TagNumber'
  13.     ,CustomerLocation.Title AS 'CustomerLocation'
  14.     ,Asset.TagLocationId
  15.     ,ISNULL(TagLocation.TagLocationNumber, '') AS 'TagLocationTitle'
  16.     ,TagLocation.RBIRequired
  17.     ,Asset.AssetApprovalStatusId
  18.     ,AssetManufacturerTag.SerialNumber
  19.     ,Asset.FullModelNumber
  20.     ,Customer.LocalTitle
  21. FROM
  22.     dbo.vwAsset AS Asset
  23.         INNER JOIN dbo.tblProduct AS Product ON Product.ProductId = Asset.ProductId
  24.             INNER JOIN dbo.tblBrand AS Brand ON Brand.BrandId = Product.BrandId
  25.         INNER JOIN dbo.tblCustomer AS Customer ON Customer.CustomerId = Asset.CustomerId
  26.         INNER JOIN dbo.tblCustomerLocation AS CustomerLocation ON CustomerLocation.CustomerLocationId = Asset.CustomerLocationId
  27.             INNER JOIN dbo.vwUserServiceLocation AS UserServiceLocation ON UserServiceLocation.ServiceLocationId = CustomerLocation.ServiceLocationId
  28.         LEFT JOIN dbo.vwAssetIdentifier AS AssetIdentifier_TagNumber ON AssetIdentifier_TagNumber.AssetSnapshotId = Asset.AssetSnapshotId AND AssetIdentifier_TagNumber.Title = 'Tag Number'
  29.         LEFT JOIN dbo.tblTagLocation AS TagLocation ON TagLocation.TagLocationId = Asset.TagLocationId
  30.         INNER JOIN dbo.tblAssetManufacturerTag AS AssetManufacturerTag ON AssetManufacturerTag.AssetId = Asset.AssetId
  31.         LEFT JOIN dbo.tblStatementOfWork AS SOW ON SOW.AssetId = Asset.AssetId
  32.             LEFT JOIN dbo.tblWorkOrder AS WorkOrder ON WorkOrder.WorkOrderId = SOW.WorkOrderId
  33.                 LEFT JOIN dbo.tblProject AS Project ON Project.ProjectId = WorkOrder.ProjectId
  34.         LEFT JOIN dbo.tblAssetIdentifierSnapshot AS AssetIdentifierSnapshot ON AssetIdentifierSnapshot.AssetSnapshotId = Asset.AssetSnapshotId
  35.             LEFT JOIN dbo.tblAssetIdentifierVersion AS AssetIdentifierVersion ON AssetIdentifierVersion.AssetIdentifierVersionId = AssetIdentifierSnapshot.AssetIdentifierVersionId
  36. WHERE
  37.     1 = 1
  38.     AND (Asset.Title LIKE '%E29%' OR AssetIdentifierVersion.Value LIKE '%E29%')
  39.     AND UserServiceLocation.OwnerId = '1A07E201-D832-465D-A1B1-10500A20E16A'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement