Query on Sample
Dear all
My Query: I cannot create sales order with reference to quotation because Net value in quotation is zero. As we have to send sample as free to customer, the quotations Net Value should be zero.
Regards
Sandeep Bhowmick
Hi
Sandeep
What antima said is correct u have to consider all the pricing components even if u wnat to clear goods for sample u have to create excise invoice and paid the duty. U can not give 100% discount. Only u can save is sales tax by maintaining relevent tax code. And on Invoice u have to indicate " FREE SAMPLE-NOT FOR SALE-NO COMMERCIAL VALUE.
Hope this will help you.
Thx.
Similar Messages
-
Oracle Text query parser - sample code
I've posted a new entry on my "searchtech" blog which includes code for a "Google-like" query syntax parser:
https://blogs.oracle.com/searchtech/entry/oracle_text_query_parser
Currently it's just sample code, but if it goes down well we might include it, or something similar, in a future release of the product.
I'd very much welcome feedback on it, either here on the forum, or on the blog, or directly to me email address (which is included in the download file).
Thanks, everyone.When I select the "open in browser" option for each now, I get formatted, readable code, which can easily be copied and pasted into a file without the extra txt extension, and I much prefer that. So, for me, that is a sufficient fix.
It seems like this is handy, virtually idiot-proof code, easy to create the package, easy to use it, and provides the Google-like search that users expect, without raising errors or producing unexpected results. Frequently, on the OraFAQ forums, where I am a moderator, when there are various ways to solve a problem and I provide a Text solution, the complaint is that it is too complicated to create all of the formatting to fix potential problems with user input. Your code solves that problem and I hope it will be included in the next version. If you don't mind, I will post an announcement in the OraFAQ Text forum with the permanent link that you provided. -
Query re sampling rates when importing from CD in UK
Hi again. I was going to try to import a track from a CD via iTunes and convert it. I know that the rate is 44.1 before converting it in iTunes, but i'm unsure which raye to con vert to. my FCE setup is Pal 32Khz, therefor should I be converting to that rate to import into my project?
Again your help is much appreciated. DenisThanks Tom. I was perusing the manual while I was waiting read the bit about checking the Seqence settings. on going to Sequence>settings I noted that the audio rate was 32.0 KHz and the format was 32bit floating point, which it states I should match.
Thank again from one of the newbies following you Editing workshop and your video 'Final Cut Express HD Made Easy' -
How to get Quername while executing query in CMOD
Hello,
I have written some code for giving authorization to the users while excuting query,
i need to find users with role YB_CRM_MN_ADMINISTRATOR which i can get through FM CRM_ROLES_OF_USER_GET.
After that I need to find the query it is executing, if it is ZZCMI0UO01_Q0002 the user should have all the access to view all the data in the query or have limited data access.
how can i get the Query name at runtime ??
Thanks in advance.
regards,
MaheshThe result of the query is normally shown via an iterator which ids bound to a vo. After the query is executed you can check the iterator (estimatedRowCount >0) and then insert a message.
Got this you need to use your own query listener (sample for this http://andrejusb.blogspot.de/2008/11/adf-query-component-and-view-criteria.html) here you execute the query and after that get the estimated row count.
Timo -
SQL Query with a little bit more complicated WHERE clause performance issue
Hello, I have some performance issue in this case:
Very simplified query:
SELECT COUNT(*) FROM Items
WHERE
ConditionA OR
ConditionB OR
ConditionC OR ...
Simply I have to determine how many Items the user has access through some complicated conditions.
When there is a large number of records (100,000+) in the Items table and say ~10 complicated conditions concatenated in WHERE clause, I get the result about 2 seconds in my case. The problem is when very few conditions are met, f.e. when I get only
10 Items from 100,000.
How can I improve the performace in this "Get my items" case?
Additional information:
the query is generated by EF 6.1
MS SQL 2012 Express
Here is the main part of the real SQL Execution Plan:Can you post table/index DDL? Query?
Sample query:
exec sp_executesql N'SELECT
[GroupBy1].[A1] AS [C1]
FROM ( SELECT
COUNT(1) AS [A1]
FROM [dbo].[Tickets] AS [Extent1]
LEFT OUTER JOIN [dbo].[Services] AS [Extent2] ON [Extent1].[ServiceId] = [Extent2].[Id]
WHERE (@p__linq__0 = 1) OR ([Extent1].[SubmitterKey] = @p__linq__1) OR ([Extent1].[OperatorKey] = @p__linq__2) OR (([Extent1].[OperatorKey] IS NULL) AND (@p__linq__2 IS NULL)) OR ([Extent1].[SolverKey] = @p__linq__3) OR (([Extent1].[SolverKey] IS NULL) AND (@p__linq__3 IS NULL)) OR ([Extent1].[Incident2ndLineSupportKey] = @p__linq__4) OR (([Extent1].[Incident2ndLineSupportKey] IS NULL) AND (@p__linq__4 IS NULL)) OR ((@p__linq__5 = 1) AND ((1 = CAST( [Extent1].[TicketType] AS int)) OR ((@p__linq__6 = 1) AND (((2 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[IncidentManager] = @p__linq__7) OR (([Extent2].[IncidentManager] IS NULL) AND (@p__linq__7 IS NULL)))) OR ((3 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[ServiceRequestManager] = @p__linq__8) OR (([Extent2].[ServiceRequestManager] IS NULL) AND (@p__linq__8 IS NULL)))) OR ((4 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[ProblemManager] = @p__linq__9) OR (([Extent2].[ProblemManager] IS NULL) AND (@p__linq__9 IS NULL)))) OR ((5 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[ChangeManager] = @p__linq__10) OR (([Extent2].[ChangeManager] IS NULL) AND (@p__linq__10 IS NULL)))))) OR ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceDeputyManagers] AS [Extent3]
WHERE ([Extent1].[ServiceId] = [Extent3].[ServiceId]) AND ( CAST( [Extent3].[TicketType] AS int) = CAST( [Extent1].[TicketType] AS int)) AND ([Extent3].[UserProviderKey] = @p__linq__11)
)))) OR ((2 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[AllowAccessToOtherOperatorsIncidents] = 1) OR ((201 = [Extent1].[TicketStateValue]) AND ([Extent2].[WfDisableIncidentTakeFromQueueAction] <> cast(1 as bit)))) AND ([Extent2].[Incident1stLineSupportLimitedAccess] <> cast(1 as bit))) OR ((3 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[AllowAccessToOtherOperatorsServiceRequests] = 1) OR ((301 = [Extent1].[TicketStateValue]) AND ([Extent2].[WfDisableServiceRequestTakeFromQueueAction] <> cast(1 as bit)))) AND ([Extent2].[ServiceRequestLimitedAccess] <> cast(1 as bit))) OR ((4 = CAST( [Extent1].[TicketType] AS int)) AND ([Extent2].[AllowAccessToOtherOperatorsProblems] = 1) AND ([Extent2].[ProblemLimitedAccess] <> cast(1 as bit))) OR ((5 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[AllowAccessToOtherOperatorsChanges] = 1) OR ((501 = [Extent1].[TicketStateValue]) AND ([Extent2].[WfDisableChangeTakeFromQueueAction] <> cast(1 as bit)))) AND ([Extent2].[ChangeLimitedAccess] <> cast(1 as bit))) OR ((2 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[AllowAccessToOtherOperatorsIncidents] = 1) OR ((201 = [Extent1].[TicketStateValue]) AND ([Extent2].[WfDisableIncidentTakeFromQueueAction] <> cast(1 as bit)))) AND (( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperators] AS [Extent4]
WHERE ([Extent1].[ServiceId] = [Extent4].[ServiceId]) AND (2 = CAST( [Extent4].[TicketType] AS int)) AND ([Extent4].[UserProviderKey] = @p__linq__12) AND (1 = [Extent4].[SupportLine])
)) OR ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[OperatorGroupUsers] AS [Extent5]
WHERE ([Extent5].[UserProviderKey] = @p__linq__13) AND ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperatorGroups] AS [Extent6]
WHERE ([Extent6].[ServiceId] = [Extent1].[ServiceId]) AND (2 = CAST( [Extent6].[TicketType] AS int)) AND (1 = [Extent6].[SupportLine]) AND ([Extent6].[OperatorGroupId] = [Extent5].[OperatorGroupId])
)))) OR ((2 = CAST( [Extent1].[TicketType] AS int)) AND ([Extent1].[IncidentFunctionEscalatedTo2ndLineSupport] = 1) AND ([Extent1].[Incident2ndLineSupportKey] IS NULL) AND (([Extent2].[Incident2ndLineSupportLimitedAccess] <> cast(1 as bit)) OR ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperators] AS [Extent7]
WHERE ([Extent1].[ServiceId] = [Extent7].[ServiceId]) AND (2 = CAST( [Extent7].[TicketType] AS int)) AND ([Extent7].[UserProviderKey] = @p__linq__14) AND (2 = [Extent7].[SupportLine])
)) OR ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[OperatorGroupUsers] AS [Extent8]
WHERE ([Extent8].[UserProviderKey] = @p__linq__15) AND ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperatorGroups] AS [Extent9]
WHERE ([Extent9].[ServiceId] = [Extent1].[ServiceId]) AND (2 = CAST( [Extent9].[TicketType] AS int)) AND (2 = [Extent9].[SupportLine]) AND ([Extent9].[OperatorGroupId] = [Extent8].[OperatorGroupId])
)))) OR ((3 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[AllowAccessToOtherOperatorsServiceRequests] = 1) OR ((301 = CAST( [Extent1].[TicketState] AS int)) AND ([Extent2].[WfDisableServiceRequestTakeFromQueueAction] <> cast(1 as bit)))) AND (( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperators] AS [Extent10]
WHERE ([Extent1].[ServiceId] = [Extent10].[ServiceId]) AND (3 = CAST( [Extent10].[TicketType] AS int)) AND ([Extent10].[UserProviderKey] = @p__linq__16)
)) OR ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[OperatorGroupUsers] AS [Extent11]
WHERE ([Extent11].[UserProviderKey] = @p__linq__17) AND ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperatorGroups] AS [Extent12]
WHERE ([Extent12].[ServiceId] = [Extent1].[ServiceId]) AND (3 = CAST( [Extent12].[TicketType] AS int)) AND ([Extent12].[OperatorGroupId] = [Extent11].[OperatorGroupId])
)))) OR ((4 = CAST( [Extent1].[TicketType] AS int)) AND ([Extent2].[AllowAccessToOtherOperatorsProblems] = 1) AND (( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperators] AS [Extent13]
WHERE ([Extent1].[ServiceId] = [Extent13].[ServiceId]) AND (4 = CAST( [Extent13].[TicketType] AS int)) AND ([Extent13].[UserProviderKey] = @p__linq__18)
)) OR ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[OperatorGroupUsers] AS [Extent14]
WHERE ([Extent14].[UserProviderKey] = @p__linq__19) AND ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperatorGroups] AS [Extent15]
WHERE ([Extent15].[ServiceId] = [Extent1].[ServiceId]) AND (4 = CAST( [Extent15].[TicketType] AS int)) AND ([Extent15].[OperatorGroupId] = [Extent14].[OperatorGroupId])
)))) OR ((5 = CAST( [Extent1].[TicketType] AS int)) AND (([Extent2].[AllowAccessToOtherOperatorsChanges] = 1) OR ((501 = [Extent1].[TicketStateValue]) AND ([Extent2].[WfDisableChangeTakeFromQueueAction] <> cast(1 as bit)))) AND (( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperators] AS [Extent16]
WHERE ([Extent1].[ServiceId] = [Extent16].[ServiceId]) AND (5 = CAST( [Extent16].[TicketType] AS int)) AND ([Extent16].[UserProviderKey] = @p__linq__20)
)) OR ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[OperatorGroupUsers] AS [Extent17]
WHERE ([Extent17].[UserProviderKey] = @p__linq__21) AND ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[ServiceOperatorGroups] AS [Extent18]
WHERE ([Extent18].[ServiceId] = [Extent1].[ServiceId]) AND (5 = CAST( [Extent18].[TicketType] AS int)) AND ([Extent18].[OperatorGroupId] = [Extent17].[OperatorGroupId])
)))) OR ( EXISTS (SELECT
1 AS [C1]
FROM [dbo].[TicketInvitations] AS [Extent19]
WHERE ([Extent19].[TicketId] = [Extent1].[Id]) AND (([Extent19].[InvitedUserProviderKey] = @p__linq__22) OR (([Extent19].[InvitedUserProviderKey] IS NULL) AND (@p__linq__22 IS NULL)))
)) OR ( EXISTS (SELECT
1 AS [C1]
FROM (SELECT
[Extent20].[CustomerId] AS [CustomerId]
FROM [dbo].[CustomerUsers] AS [Extent20]
WHERE ([Extent20].[UserProviderKey] = @p__linq__23) AND ([Extent20].[CanAccessOthersTickets] = 1)
INTERSECT
SELECT
[Extent21].[CustomerId] AS [CustomerId]
FROM [dbo].[CustomerUsers] AS [Extent21]
WHERE [Extent21].[UserProviderKey] = [Extent1].[SubmitterKey]) AS [Intersect1]
)) OR ( EXISTS (SELECT
1 AS [C1]
FROM (SELECT
[Extent22].[InternalGroupId] AS [InternalGroupId]
FROM [dbo].[InternalGroupUsers] AS [Extent22]
WHERE ([Extent22].[UserProviderKey] = @p__linq__24) AND ([Extent22].[CanAccessOthersTickets] = 1)
INTERSECT
SELECT
[Extent23].[InternalGroupId] AS [InternalGroupId]
FROM [dbo].[InternalGroupUsers] AS [Extent23]
WHERE [Extent23].[UserProviderKey] = [Extent1].[SubmitterKey]) AS [Intersect2]
) AS [GroupBy1]',N'@p__linq__0 bit,@p__linq__1 varchar(8000),@p__linq__2 varchar(8000),@p__linq__3 varchar(8000),@p__linq__4 varchar(8000),@p__linq__5 bit,@p__linq__6 bit,@p__linq__7 varchar(8000),@p__linq__8 varchar(8000),@p__linq__9 varchar(8000),@p__linq__10 varchar(8000),@p__linq__11 varchar(8000),@p__linq__12 varchar(8000),@p__linq__13 varchar(8000),@p__linq__14 varchar(8000),@p__linq__15 varchar(8000),@p__linq__16 varchar(8000),@p__linq__17 varchar(8000),@p__linq__18 varchar(8000),@p__linq__19 varchar(8000),@p__linq__20 varchar(8000),@p__linq__21 varchar(8000),@p__linq__22 varchar(8000),@p__linq__23 varchar(8000),@p__linq__24 varchar(8000)',@p__linq__0=0,@p__linq__1='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__2='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__3='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__4='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__5=1,@p__linq__6=0,@p__linq__7='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__8='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__9='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__10='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__11='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__12='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__13='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__14='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__15='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__16='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__17='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__18='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__19='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__20='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__21='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__22='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__23='31555851-b89d-4a15-bb05-5a6fd42f9552',@p__linq__24='31555851-b89d-4a15-bb05-5a6fd42f9552'
Generated DDL for related tables: (indexes are primary on PKs and FKs)
CREATE TABLE [dbo].[CustomerUsers](
[UserProviderKey] [varchar](184) NOT NULL,
[CustomerId] [int] NOT NULL,
[CanAccessOthersTickets] [bit] NOT NULL,
CONSTRAINT [PK_dbo.CustomerUsers] PRIMARY KEY CLUSTERED
[UserProviderKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[InternalGroupUsers] Script Date: 7.5.2014 8:39:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[InternalGroupUsers](
[UserProviderKey] [varchar](184) NOT NULL,
[InternalGroupId] [int] NOT NULL,
[CanAccessOthersTickets] [bit] NOT NULL,
CONSTRAINT [PK_dbo.InternalGroupUsers] PRIMARY KEY CLUSTERED
[UserProviderKey] ASC,
[InternalGroupId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[OperatorGroupUsers] Script Date: 7.5.2014 8:39:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[OperatorGroupUsers](
[UserProviderKey] [varchar](184) NOT NULL,
[OperatorGroupId] [int] NOT NULL,
CONSTRAINT [PK_dbo.OperatorGroupUsers] PRIMARY KEY CLUSTERED
[UserProviderKey] ASC,
[OperatorGroupId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[ServiceDeputyManagers] Script Date: 7.5.2014 8:39:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ServiceDeputyManagers](
[UserProviderKey] [varchar](184) NOT NULL,
[ServiceId] [int] NOT NULL,
[TicketType] [int] NOT NULL,
CONSTRAINT [PK_dbo.ServiceDeputyManagers] PRIMARY KEY CLUSTERED
[UserProviderKey] ASC,
[ServiceId] ASC,
[TicketType] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[ServiceOperatorGroups] Script Date: 7.5.2014 8:39:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiceOperatorGroups](
[ServiceId] [int] NOT NULL,
[OperatorGroupId] [int] NOT NULL,
[TicketTypeValue] [int] NOT NULL,
[SupportLine] [int] NOT NULL,
[TicketType] [int] NOT NULL,
CONSTRAINT [PK_dbo.ServiceOperatorGroups] PRIMARY KEY CLUSTERED
[ServiceId] ASC,
[OperatorGroupId] ASC,
[TicketTypeValue] ASC,
[SupportLine] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[ServiceOperators] Script Date: 7.5.2014 8:39:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ServiceOperators](
[UserProviderKey] [varchar](184) NOT NULL,
[ServiceId] [int] NOT NULL,
[TicketTypeValue] [int] NOT NULL,
[SupportLine] [int] NOT NULL,
[TicketType] [int] NOT NULL,
CONSTRAINT [PK_dbo.ServiceOperators] PRIMARY KEY CLUSTERED
[UserProviderKey] ASC,
[ServiceId] ASC,
[TicketTypeValue] ASC,
[SupportLine] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Services] Script Date: 7.5.2014 8:39:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Services](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ParentId] [int] NULL,
[Name] [nvarchar](256) NOT NULL,
[Description] [nvarchar](max) NULL,
[Disabled] [bit] NOT NULL,
[NewTicketLimitedAccess] [bit] NOT NULL,
[Incident1stLineSupportLimitedAccess] [bit] NOT NULL,
[Incident2ndLineSupportLimitedAccess] [bit] NOT NULL,
[ServiceRequestLimitedAccess] [bit] NOT NULL,
[ProblemLimitedAccess] [bit] NOT NULL,
[ServiceRequestManager] [varchar](184) NOT NULL,
[IncidentManager] [varchar](184) NOT NULL,
[ProblemManager] [varchar](184) NOT NULL,
[Deleted] [bit] NOT NULL,
[WfDisableIncidentAssignedState] [bit] NOT NULL,
[WfDisableIncidentConfirmedState] [bit] NOT NULL,
[WfDisableIncidentTakeFromQueueAction] [bit] NOT NULL,
[WfDisableIncidentFinishSolutionAction] [bit] NOT NULL,
[WfDisableServiceRequestAssignedState] [bit] NOT NULL,
[WfDisableServiceRequestConfirmedState] [bit] NOT NULL,
[WfDisableServiceRequestTakeFromQueueAction] [bit] NOT NULL,
[WfDisableServiceRequestFinishSolutionAction] [bit] NOT NULL,
[WfDisableServiceRequestPostponeAction] [bit] NOT NULL,
[ChangeLimitedAccess] [bit] NOT NULL,
[ChangeManager] [varchar](184) NOT NULL,
[WfDisableChangeTakeFromQueueAction] [bit] NOT NULL,
[WfDisableChangeAssignedState] [bit] NOT NULL,
[WfDisableChangeStartPreparationAction] [bit] NOT NULL,
[IsDepartment] [bit] NOT NULL,
[InheritsFromDepartment] [bit] NOT NULL,
[AllowSelectSolverBySubmitterForIncidents] [bit] NOT NULL,
[AllowSelectSolverBySubmitterForServiceRequests] [bit] NOT NULL,
[AllowSelectSolverBySubmitterForProblems] [bit] NOT NULL,
[AllowSelectSolverBySubmitterForChanges] [bit] NOT NULL,
[AllowAccessToOtherOperatorsIncidents] [bit] NOT NULL,
[AllowAccessToOtherOperatorsServiceRequests] [bit] NOT NULL,
[AllowAccessToOtherOperatorsProblems] [bit] NOT NULL,
[AllowAccessToOtherOperatorsChanges] [bit] NOT NULL,
[AllowChangeDeadlineForIncidents] [bit] NOT NULL,
[AllowChangeDeadlineForServiceRequests] [bit] NOT NULL,
[AllowChangeDeadlineForProblems] [bit] NOT NULL,
[AllowChangeDeadlineForChanges] [bit] NOT NULL,
[AllowSelectPriorityForServiceRequests] [bit] NOT NULL,
[WfDisableIncidentCompletedState] [bit] NOT NULL,
[WfDoIncidentCompleteActionBySubmittersMessage] [bit] NOT NULL,
[WfDisableServiceRequestCompletedState] [bit] NOT NULL,
[WfDoServiceRequestCompleteActionBySubmittersMessage] [bit] NOT NULL,
CONSTRAINT [PK_dbo.Services] PRIMARY KEY CLUSTERED
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[TicketInvitations] Script Date: 7.5.2014 8:39:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TicketInvitations](
[Id] [int] IDENTITY(1,1) NOT NULL,
[TicketId] [int] NOT NULL,
[InitiatorUserProviderKey] [varchar](184) NULL,
[InitiatorFullName] [nvarchar](max) NULL,
[InvitedUserProviderKey] [varchar](184) NULL,
[InvitedFullName] [nvarchar](max) NULL,
[Type] [int] NOT NULL,
[CreatedUTC] [datetime] NOT NULL,
CONSTRAINT [PK_dbo.TicketInvitations] PRIMARY KEY CLUSTERED
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Tickets] Script Date: 7.5.2014 8:39:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Tickets](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ParentId] [int] NULL,
[ServiceId] [int] NULL,
[ServiceMailboxId] [int] NULL,
[TicketTypeValue] [int] NOT NULL,
[TicketTypeIdREF] [int] NOT NULL,
[SubmitterKey] [varchar](184) NOT NULL,
[SubmitterFullName] [nvarchar](256) NULL,
[CustomerId] [int] NULL,
[SolverKey] [varchar](184) NULL,
[SolverFullName] [nvarchar](256) NULL,
[Subject] [nvarchar](max) NULL,
[CreatedUTC] [datetime] NOT NULL,
[Archived] [bit] NOT NULL,
[MarkedAsSolvedUTC] [datetime] NULL,
[ArchivedUTC] [datetime] NULL,
[TicketSourceValue] [int] NOT NULL,
[OperatorKey] [varchar](184) NULL,
[DeadlineUTC] [datetime] NULL,
[DeadlineLastNotificatedPercentage] [int] NULL,
[UrgencyValue] [int] NULL,
[ImpactValue] [int] NULL,
[PriorityValue] [int] NULL,
[TicketStateValue] [int] NOT NULL,
[IncidentFunctionEscalatedTo2ndLineSupport] [bit] NOT NULL,
[Incident2ndLineSupportKey] [varchar](184) NULL,
[Incident2ndLineSupportFullName] [nvarchar](max) NULL,
[TicketType] [int] NOT NULL,
[Source] [int] NOT NULL,
[TicketState] [int] NOT NULL,
[Urgency] [int] NULL,
[Impact] [int] NULL,
[TicketSummaryState] [int] NOT NULL,
[ResolutionText] [nvarchar](max) NULL,
[ResolutionModifiedUTC] [datetime] NULL,
[ResolutionEdited] [bit] NOT NULL,
[ResolutionUserProviderKey] [varchar](184) NULL,
[ResolutionFullName] [nvarchar](max) NULL,
[TicketSubType] [int] NULL,
[ChangeRiskProbabilityValue] [int] NULL,
[ChangeImpactValue] [int] NULL,
[ChangeRiskCategoryValue] [int] NULL,
[RfcText] [nvarchar](max) NULL,
[RfcModifiedUTC] [datetime] NULL,
[RfcEdited] [bit] NOT NULL,
[RfcUserProviderKey] [varchar](184) NULL,
[RfcFullName] [nvarchar](max) NULL,
[ManualDeadline] [bit] NOT NULL,
[ContactInformation] [nvarchar](256) NULL,
[Imported] [bit] NOT NULL,
[ForceClosed] [bit] NOT NULL,
CONSTRAINT [PK_dbo.Tickets] PRIMARY KEY CLUSTERED
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Index [IX_CustomerId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_CustomerId] ON [dbo].[CustomerUsers]
[CustomerId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_InternalGroupId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_InternalGroupId] ON [dbo].[InternalGroupUsers]
[InternalGroupId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_OperatorGroupId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_OperatorGroupId] ON [dbo].[OperatorGroupUsers]
[OperatorGroupId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_ServiceId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_ServiceId] ON [dbo].[ServiceDeputyManagers]
[ServiceId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_OperatorGroupId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_OperatorGroupId] ON [dbo].[ServiceOperatorGroups]
[OperatorGroupId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_ServiceId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_ServiceId] ON [dbo].[ServiceOperatorGroups]
[ServiceId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_ServiceId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_ServiceId] ON [dbo].[ServiceOperators]
[ServiceId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_ParentId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_ParentId] ON [dbo].[Services]
[ParentId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_TicketId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_TicketId] ON [dbo].[TicketInvitations]
[TicketId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [IX_TicketInvitations_InvitedUserProviderKey_TicketId] Script Date: 7.5.2014 8:39:38 ******/
CREATE UNIQUE NONCLUSTERED INDEX [IX_TicketInvitations_InvitedUserProviderKey_TicketId] ON [dbo].[TicketInvitations]
[InvitedUserProviderKey] ASC,
[TicketId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_CustomerId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_CustomerId] ON [dbo].[Tickets]
[CustomerId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_ParentId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_ParentId] ON [dbo].[Tickets]
[ParentId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_ServiceId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_ServiceId] ON [dbo].[Tickets]
[ServiceId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_ServiceMailboxId] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_ServiceMailboxId] ON [dbo].[Tickets]
[ServiceMailboxId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [IX_SolverFullName] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_SolverFullName] ON [dbo].[Tickets]
[SolverFullName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [IX_SolverKey] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_SolverKey] ON [dbo].[Tickets]
[SolverKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [IX_SubmitterFullName] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_SubmitterFullName] ON [dbo].[Tickets]
[SubmitterFullName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [IX_SubmitterKey] Script Date: 7.5.2014 8:39:38 ******/
CREATE NONCLUSTERED INDEX [IX_SubmitterKey] ON [dbo].[Tickets]
[SubmitterKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object: Index [IX_Tickets_TicketType_TicketTypeIdREF] Script Date: 7.5.2014 8:39:38 ******/
CREATE UNIQUE NONCLUSTERED INDEX [IX_Tickets_TicketType_TicketTypeIdREF] ON [dbo].[Tickets]
[TicketType] ASC,
[TicketTypeIdREF] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CustomerUsers] WITH CHECK ADD CONSTRAINT [FK_dbo.CustomerUsers_dbo.Customers_CustomerId] FOREIGN KEY([CustomerId])
REFERENCES [dbo].[Customers] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[CustomerUsers] CHECK CONSTRAINT [FK_dbo.CustomerUsers_dbo.Customers_CustomerId]
GO
ALTER TABLE [dbo].[InternalGroupUsers] WITH CHECK ADD CONSTRAINT [FK_dbo.InternalGroupUsers_dbo.InternalGroups_InternalGroupId] FOREIGN KEY([InternalGroupId])
REFERENCES [dbo].[InternalGroups] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[InternalGroupUsers] CHECK CONSTRAINT [FK_dbo.InternalGroupUsers_dbo.InternalGroups_InternalGroupId]
GO
ALTER TABLE [dbo].[OperatorGroupUsers] WITH CHECK ADD CONSTRAINT [FK_dbo.OperatorGroupUsers_dbo.OperatorGroups_OperatorGroupId] FOREIGN KEY([OperatorGroupId])
REFERENCES [dbo].[OperatorGroups] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[OperatorGroupUsers] CHECK CONSTRAINT [FK_dbo.OperatorGroupUsers_dbo.OperatorGroups_OperatorGroupId]
GO
ALTER TABLE [dbo].[ServiceDeputyManagers] WITH CHECK ADD CONSTRAINT [FK_dbo.ServiceDeputyManagers_dbo.Services_ServiceId] FOREIGN KEY([ServiceId])
REFERENCES [dbo].[Services] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ServiceDeputyManagers] CHECK CONSTRAINT [FK_dbo.ServiceDeputyManagers_dbo.Services_ServiceId]
GO
ALTER TABLE [dbo].[ServiceOperatorGroups] WITH CHECK ADD CONSTRAINT [FK_dbo.ServiceOperatorGroups_dbo.OperatorGroups_OperatorGroupId] FOREIGN KEY([OperatorGroupId])
REFERENCES [dbo].[OperatorGroups] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ServiceOperatorGroups] CHECK CONSTRAINT [FK_dbo.ServiceOperatorGroups_dbo.OperatorGroups_OperatorGroupId]
GO
ALTER TABLE [dbo].[ServiceOperatorGroups] WITH CHECK ADD CONSTRAINT [FK_dbo.ServiceOperatorGroups_dbo.Services_ServiceId] FOREIGN KEY([ServiceId])
REFERENCES [dbo].[Services] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ServiceOperatorGroups] CHECK CONSTRAINT [FK_dbo.ServiceOperatorGroups_dbo.Services_ServiceId]
GO
ALTER TABLE [dbo].[ServiceOperators] WITH CHECK ADD CONSTRAINT [FK_dbo.ServiceOperators_dbo.Services_ServiceId] FOREIGN KEY([ServiceId])
REFERENCES [dbo].[Services] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ServiceOperators] CHECK CONSTRAINT [FK_dbo.ServiceOperators_dbo.Services_ServiceId]
GO
ALTER TABLE [dbo].[Services] WITH CHECK ADD CONSTRAINT [FK_dbo.Services_dbo.Services_ParentId] FOREIGN KEY([ParentId])
REFERENCES [dbo].[Services] ([Id])
GO
ALTER TABLE [dbo].[Services] CHECK CONSTRAINT [FK_dbo.Services_dbo.Services_ParentId]
GO
ALTER TABLE [dbo].[TicketInvitations] WITH CHECK ADD CONSTRAINT [FK_dbo.TicketInvitations_dbo.Tickets_TicketId] FOREIGN KEY([TicketId])
REFERENCES [dbo].[Tickets] ([Id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[TicketInvitations] CHECK CONSTRAINT [FK_dbo.TicketInvitations_dbo.Tickets_TicketId]
GO
ALTER TABLE [dbo].[Tickets] WITH CHECK ADD CONSTRAINT [FK_dbo.Tickets_dbo.Customers_CustomerId] FOREIGN KEY([CustomerId])
REFERENCES [dbo].[Customers] ([Id])
GO
ALTER TABLE [dbo].[Tickets] CHECK CONSTRAINT [FK_dbo.Tickets_dbo.Customers_CustomerId]
GO
ALTER TABLE [dbo].[Tickets] WITH CHECK ADD CONSTRAINT [FK_dbo.Tickets_dbo.ServiceMailboxes_ServiceMailboxId] FOREIGN KEY([ServiceMailboxId])
REFERENCES [dbo].[ServiceMailboxes] ([Id])
GO
ALTER TABLE [dbo].[Tickets] CHECK CONSTRAINT [FK_dbo.Tickets_dbo.ServiceMailboxes_ServiceMailboxId]
GO
ALTER TABLE [dbo].[Tickets] WITH CHECK ADD CONSTRAINT [FK_dbo.Tickets_dbo.Services_ServiceId] FOREIGN KEY([ServiceId])
REFERENCES [dbo].[Services] ([Id])
GO
ALTER TABLE [dbo].[Tickets] CHECK CONSTRAINT [FK_dbo.Tickets_dbo.Services_ServiceId]
GO
ALTER TABLE [dbo].[Tickets] WITH CHECK ADD CONSTRAINT [FK_dbo.Tickets_dbo.Tickets_ParentId] FOREIGN KEY([ParentId])
REFERENCES [dbo].[Tickets] ([Id])
GO
ALTER TABLE [dbo].[Tickets] CHECK CONSTRAINT [FK_dbo.Tickets_dbo.Tickets_ParentId]
GO -
Structure or syntax for query/filter
I need to find a 12-digit number in a column called "SequenceNumTxt", in a VERY long table.
I can query the first n lines but need to add something like "WHERE [SequenceNumTxt]="123412341234"
The above does not work, gives me a syntax error; what am I doing wrong?Good day
Joseph_L_W,
Firstly I have to agree with all previous responses. Your question is not clear and you did not gave us any information (I use to say that you gave us stories instead of information). In order to understand the issue and to reproduce it we need you to always
post DDL+DML.
DDL = Data Definition Language. In our case that is, CREATE TABLE statements for the relevant tables
* How to get DDL: Right click on the table in Object Explorer and select script table as CREATE. Post these create table scripts here.
DML = data manipulation language is a family of queries used for manipulating the data itself like: inserting, deleting and updating data.
In our case we need some sample data in order to check the query and get result, so we need some insert query for sample data.
If you post a "create query" for the tables and "insert query" with some sample, then we could help you without Assuming/Guessing.
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
Query only works on the first word of the managed property
I have several managed properties that are not returning query results as expected, they are returning results only if the term queried matches
the first word in the property, any other query returns no results.
Scenario:
filename = "Sample Excel File.xlsx" (OOTB property)
FooOwner = "Martin Zima"
FooSiteName = "Test Site"
If I query filename:Sample, filename:File, filename:Excel (or any combination) they all works as expected. However, if I query "FooOwner:Martin"
it works, but if I query FooOwner:Martin Zima it fails, and FooOwner:Zima also fails. Similarly, if I search for FooSiteName:Site it fails (only CPSiteName:Test works). Everything seems ok in the crawled property and managed property. Can anyone please help?Hi Martin,
I tried in my envrionment, author:"Rebecca Tu" and
author:Rebecca Tu returned the same result. Please try author:* and see if it will return all the results. If there is no result, then we should check the DisplayAuthor property in Search schema.
In the default search result page, there should be Author refiner in the Refinement. You could use the default one as below:
Regards,
Rebecca Tu
TechNet Community Support -
Select Query with diagonally matching columns
hi
the following is the table struncture and insert statements
create table emp_trans values (empno number , emptran_no number, prev_amount number, current_amount number)
insert into emp_trans values(102,109,0,20);
insert into emp_trans values(102,119,10,20);
insert into emp_trans values(102,129,20,30);
insert into emp_trans values(102,139,30,0);
insert into emp_trans values(201,101,0,20);
insert into emp_trans values(201,110,20,30);
insert into emp_trans values(201,120,0,30);
insert into emp_trans values(201,130,30,20);
insert into emp_trans values(201,140,0,20);In the table we can see some mappings as follows
The data is on empno basis.
we have 2 employees with empno 201 and 102 . Each empno has different emptrans_no. Need not be in an sequence.
we need to select the set of records where prev_amount column matches with the current_amount column values for
the previous record for every individual empno.
prior to that the following basic select statement can be considered
select * from emp_trans order by empno , emptran_nofor ex:
emp no 102 emptran_no 129 prev_amount column having values of 20 matches with the current_amount column having values 20
with emptran_no 119.
for empno 201 with emptran_no 110 we can see the prev_amount column having value 20 matched with current_account column havig values of 20
of previous emptran_no 101 for the same empno 201.
something like we need to see the diagnally mathced values.
Any help on such query most welcome.
Regards,Hi,
sri wrote:
Hi
A small Change required
For empno 201 we need to display
EMPNO EMPTRAN_NO PREV_AMOUNT CURRENT_AMOUNT
102 129 20 30
102 139 30 0
201 *120* 20 30
201 130 30 20
rathe than
EMPNO EMPTRAN_NO PREV_AMOUNT CURRENT_AMOUNT
102 129 20 30
102 139 30 0
201 *110* 20 30
201 130 30 20Always explain how you get the results you want. Otherwise, the solution that works on your sample data won't necessarily work on your real data.
Given that the data for empno=201 is:
insert into emp_trans values (201, 101, 0, 20);
insert into emp_trans values (201, 110, 20, 30);
insert into emp_trans values (201, 120, 0, 30);
insert into emp_trans values (201, 130, 30, 20);
insert into emp_trans values (201, 140, 0, 20);Why do you want the row with emptrn_no=120, and not the row with emptran_no=110?
If you want the row with emptran_no=120, why don't you want the row with emptran_no=101?
If you want the row with emptran_no=130, why don't you want the row with emptran_no=110?
can u please let me know the way you formatted the code for the query and sample output This site noramlly compresses whitespace.
Whenever you post formatted text (such as query results) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing. -
BEx Query Report - Customer transactions for a period.
Dear Experts
my management has asked me to create a Customer Statement Query.
Sample Format
Customer Code | Document Date | Document No | Transaction Type | Opening Balance (Beginning of month) | Credit | Debit
Necessary Data Available in FI AR line item cube.
since i am new to SAP BI i am finding difficultly in calculating the opening balance in the first row. it will be a great help if somebody can assist me in creating the query in the above format.
thans
viru
Edited by: Lankem-IT on Apr 27, 2011 5:15 PM
Edited by: Lankem-IT on Apr 27, 2011 5:19 PMHi
Thanks Ashutosh Singh & AP_SAP for replying.
i am planning to use : 0FIAR_O03 DSO for this purpose.
logic given to me by management is like this
Statement is for a month. Example ( 2011/04/01 to 2011/04/30).
opening balance is as at 2011/03/31 (Cumulative Debit/Credit Amount .) on First Row
then followed by Statement period Transaction
Fields : Document No , Document Date , Transaction Type , Debit Amount , Credit Amount
Then Finally Closing Balance as at 2011/04/30 on the Final Row(Cumulative Debit/Credit Amount = Opening Balance + Debit Amt - Credit Amt)
Regards
Viru. -
Duplicates in sql query out put when qury has join on multiple tables.
I have the below query whcih is returning 2 duplicate records.
Is there any way how to figure out from which table is causing the duplicate?
There are so many inline view and join conditions in this query .
in waht join conditions i need to look into mainly?
or how to find the whcih table is causing the duplicate when we have multimple joins?
this is really bothering me a lot .please help me with this.
SELECT 'BCCALGLB' model_cd,
fi_instrument_id,
fmr_cusip instrument_id,
price,
'27-FEB-2013' pricing_dt,
currency_cd
FROM (SELECT II.fmr_cusip,
IAI.fi_instrument_id,
IP.price,
IP.currency_cd
FROM (SELECT IdxHldg.vendor_instrument_id,
IdxHldg.index_cd,
IdxHldg.data_source_cd,
GM.member_rank,
RANK () OVER (PARTITION BY IdxHldg.vendor_instrument_id
ORDER BY GM.member_rank ASC) priority
FROM (SELECT IBH.vendor_instrument_id,
IBH.index_cd,
IBH.data_source_cd
FROM fi_idx_benchmark_holdings IBH
WHERE IBH.pricing_dt = '27-FEB-2013'
UNION
SELECT IFH.vendor_instrument_id,
IFH.index_cd,
IFH.data_source_cd
FROM fi_idx_forward_holdings IFH
WHERE IFH.pricing_dt = '27-FEB-2013'
) IdxHldg,
fi_group_member GM
WHERE GM.group_cd = 'BCGLOBALIDX'
AND GM.purpose_cd = 'GLOBALIDX'
AND IdxHldg.index_cd = GM.character_val
) BCIdxHldg,
fi_idx_instrument II,
fi_idx_price IP,
instrument_alternate_id IAI,
instrument I
WHERE BCIdxHldg.priority = 1
AND BCIdxHldg.data_source_cd = II.data_source_cd
AND BCIdxHldg.vendor_instrument_id = II.vendor_instrument_id
AND II.data_source_cd = IP.data_source_cd
AND II.vendor_instrument_id = IP.vendor_instrument_id
AND IP.currency_cd = I.currency_cd
AND IP.pricing_dt = '27-FEB-2013'
AND II.fmr_cusip = IAI.alternate_id
AND IAI.alternate_id_type_code = 'FMR_CUSIP'
AND IAI.fi_instrument_id = I.fi_instrument_id
AND NVL (I.instrument_domain_cd, 'XXX') NOT IN ('MBS', 'MGEN')
AND NVL (I.instrument_type_cd, 'XXX') != 'CMBS'
AND ((I.currency_cd NOT IN ('CAD', 'USD'))
OR
(EXISTS (SELECT 1
FROM adm_calendar_date ACD,
ctry_curr_link CCL
WHERE TO_DATE (ACD.calendar_yyyymmdd, 'YYYYMMDD') = '27-FEB-2013'
AND ACD.calendar_origin_cd = 'EXCHANGE'
AND ACD.calendar_type_cd = 'BUSINESS'
AND ACD.geography_cd = CCL.ctry_cd
AND CCL.link_typ = 'ISS'
AND CCL.curr_cd = I.currency_cd
AND ACD.business_day_ind = 'Y'))))Hi,
953115 wrote:
I have the below query whcih is returning 2 duplicate records.
Is there any way how to figure out from which table is causing the duplicate?
There are so many inline view and join conditions in this query .
in waht join conditions i need to look into mainly?
or how to find the whcih table is causing the duplicate when we have multimple joins?What has changed since the last time the query ran correctly? (It must have run correctly at some point. You didn't just write a query that big all at once without testing each individual part, did you?)
Find a small set of sample data that causes the problem. Create and work with tables that have only that small set of data.
Take baby steps. Start with the most deeply nested sub-query. and simplify it so that it uses only 1 table: comment out all references to other tables. Does it produce exactly what you're expecting, especially the number of rows?
If not, post just that one sub-query, your sample data, and the output you need (but are not getting) from that sub-query.
If it does work, then un-comment the other tables, 1 at a time. Test after each one. If the revised sub-query starts acting strangely, then you have a good clue about what's causing the problem, but if you can't figure it out, post that much of the query, your sample data (CREATE TABLE and INSERT statements) and the expected results from the code you posted.
If then entire sub-query works, then add the next super-query, and repeat the testing process.
What is the data type of ibh.pricing_dt?
If its a DATE, then don't compare it to a VARCHAR2, as you're doing in this line:
IBH.pricing_dt = '27-FEB-2013'Use TO_DATE to convert a string, such as '27-FEB-2013', to a DATE.
If it's not a DATE (or TIMESTAMP), then you have an even more serious problem. -
Linking Siebel Sample DB and SQL Server
Hi Gurus,
I have installed siebel in my laptop for learning purposes and i want to query the Sample DB in the process. Can anyone tell me how to link the sample DB and SQL Server 2008, so that i can query the sample db in the similar the way i query a normal siebel database server.
I already tried to create a linked server in SQL Server 2008 using Microsoft OLE DB Provider for ODBC drivers, but its throwing errors. Is it possible to create a linked server for sample DB.
Please let me know if there is any other way to query the sample DBIn the BIN directory you can find dbisqlc.exe.
Fill in the login credentials (SADMIN/SADMIN), don't set the ODBC, but go to the next tab and browse to the sample db.
It could be that you don't see it until you set the file filter to all files. -
Dashboard quick query limit component
Hi All,
I am using quick query limit in a dashboard...
I set it up ok in the ESM file... everything is working as advertised, BUT when I create the runtime version everything from the component disappear... the query panel button in the other frames is missing , the runtime dashboard doesn't start from the query panel even if it's defined in the dashboard properties as the startup frame...
I tried to build the runtime version from the quick query limit sample and I noticed the same behaviour, there is some hidden flags in building the runtime version?
I'm using version 9.3.1.0.0.248 on Vista
TIA & best wishes
GianlucaHi,
Check
http://blog.applegrew.com/2012/02/adf-super-code-snippets/ -
SLOW Query ... Need help improving performance
Database: Oracle 8i
Note: I don't have a whole lot of experience with writing queries, so please forgive me for any dumb mistakes I most likely made.
I have a query in which I have a SUM in two levels. I think this is probably the root cause of the very slow performance of the query. However, I just don't see any way around it, and can't come up with any other ways to speed up the query. The query itself only returns one line, the summary line. And, by slow, I mean it can take up to an hour or two. This is a query I need to run multiple times, based on some parameters that I cannot query from a database.
The query basically calculates the current unit cost of a part. It has to sum up the issue cost of the part (cost of material issued to the part's order), the actual dollars put into a part (labor, etc.), and the burden dollars associated with the part. This sum has to be divided by the total quantity of parts completed on the part's order to get the unit cost. I have to account for the possibility that the quantity complete is 0, so that I don't end up dividing by 0.
Below is my query, and sample data for it:
SELECT a.part_nbr
, a.mo_nbr
, a.unit_iss_cost
, CASE
WHEN a.qty_complete_ind ='Nonzero'
THEN SUM(a.act_dlrs/a.qty_complete)
ELSE 0
END AS unit_dlrs
, CASE
WHEN a.qty_complete_ind ='Zero'
THEN SUM(a.act_dlrs)
ELSE 0
END AS qty_0_dlrs
FROM ( SELECT act.part_nbr AS part_nbr
, act.order_nbr || '-' || act.sub_order_nbr AS mo_nbr
, ic.unit_iss_cost AS unit_iss_cost
, SUM (
act.act_dlrs_earned +
act.act_brdn_dls_earned +
act.tool_dlrs_earned +
act.act_fix_brdn_dls_ea
) AS act_dlrs
, ord.qty_complete AS qty_complete
, CASE
WHEN ord.qty_complete <>0
THEN 'Nonzero'
ELSE 'Zero'
END AS qty_complete_ind
FROM ACT act
, ISSUE_COST ic
, ORD ord
WHERE ord.ord_nbr =act.order_nbr AND
ord.sub_ord_nbr =act.sub_order_nbr AND
ord.major_seq_nbr =act.maj_seq_nbr AND
ic.ord_nbr =act.order_nbr AND
ic.sub_ord_nbr =act.sub_order_nbr AND
(act.order_nbr =LPAD(?,10,'0')) AND
(act.sub_order_nbr =LPAD(?,3,'0')) AND
(act.activity_date <=?)
GROUP BY act.part_nbr
, act.order_nbr || '-' || act.sub_order_nbr
, act.maj_seq_nbr
, ord.qty_complete
, ic.unit_iss_cost
) a
GROUP BY a.part_nbr
, a.mo_nbr
, a.unit_iss_cost
, a.qty_complete_ind
CREATE TABLE ACT
creation_date date
, c_id number (5,0)
, part_nbr varchar(25)
, order_nbr varchar(10)
, sub_order_nbr varchar(3)
, maj_seq_nbr varchar(4)
, act_dlrs_earned number (15,2)
, act_brdn_dls_earned number (15,2)
, tool_dlrs_earned number (15,2)
, act_fix_brdn_dls_ea number (15,2)
, activity_date date
CONSTRAINT ACT_PK
PRIMARY KEY (creation_date, c_id)
);--Please note, issue_cost is actually a view, not a table, but by itself it runs very quickly
CREATE TABLE ISSUE_COST
unit_iss_cost number(15,2)
, ord_nbr varchar(10)
, sub_ord_nbr varchar(3)
);--Please note, ord table has a couple of foreign keys that I did not mention
CREATE TABLE ORD
ord_nbr varchar(10)
, sub_ord_nbr varchar(3)
, major_seq_nbr varchar(4)
, qty_complete number (13,4)
);Sample tables:
ACT
creation_date c_id part_nbr order_nbr sub_order_nbr maj_seq_nbr act_dlrs_earned act_brdn_dls_earned tool_dlrs_earned act_fix_brdn_dls_ea activity_date
01/02/2000 12345 ABC-123 0000012345 001 0010 10.00 20.00 0.00 0.00 01/01/2000
01/02/2000 12345 XYZ-987 0000054321 001 0030 100.00 175.00 10.00 10.00 01/01/2000
01/03/2000 12347 ABC-123 0000012345 001 0020 25.00 75.00 5.00 1.00 01/02/2000
01/03/2000 12348 ABC-123 0000012345 001 0020 75.00 120.00 25.00 5.00 01/02/2000
01/03/2000 12349 XYZ-987 0000054321 001 0050 50.00 110.00 0.00 0.00 01/02/2000
01/04/2000 12350 ABC-123 0000012345 001 0030 25.00 40.00 0.00 0.00 01/03/2000
ISSUE_COST
unit_iss_cost ord_nbr sub_ord_nbr
125.00 0000012345 001
650.00 0000054321 001
ORD
ord_nbr sub_ord_nbr major_seq_nbr qty_complete
0000012345 001 0010 10
0000012345 001 0020 10
0000012345 001 0030 0
0000054321 001 0030 20
0000054321 001 0050 19If insert statements are needed for the sample tables, let me know and I'll go re-figure out how to write them. (I only have read-only access to the database I'm querying, so creating tables and inserting values aren't things I ever do).
Thanks in advance!For diagnosing where the time of your query is being spent, we don't need create table and insert statements. If we execute your query with only a handful of rows, the query will be very fast. What we do need to know, is the plan the optimizer takes to compute your result set, and the cardinalities of each step.
Please read When your query takes too long ... carefully and post the full explain plan and tkprof output.
Regards,
Rob. -
Hi All,
I need to fine tune my select query . I am giving a sample query which is model of my Query .
Sample Tables: Employee, Manager, Department
Select a.employee_name,a.employee_age,decode(a.employee_status,'Y','Promoted','Still in Progress'), NVL(b.employee_details , 0),c.department_name from employee a, manager b , department c where a.employee_id =b.employee_id(+) and a.employee_id = c.employee_id(+) and c.department_status in ('Y',A') order by a.employee_joining_date
This is a sample query. In my query which should be fine tune has lot of decode and nvl functions. This query is passed to oracle as string from Java .It takes 2 seconds but it should be taking only fraction of seconds..
What shall i do?
Shall i create materialise views or a function in oracle with return value as sys_refucursor to Java code. does function based index should be used in where clause only. If so what should i do to minimise decode and nvl functions.Please help me>
Select a.employee_name,a.employee_age,decode(a.employee_status,'Y','Promoted','Still in Progress'),
NVL(b.employee_details , 0),c.department_name from employee a, manager b , department c
where a.employee_id =b.employee_id(+) and a.employee_id = c.employee_id(+) and c.department_status
in ('Y',A') order by a.employee_joining_date I'm wondering why an "employee_details" field is 0 - doesn't make much sense to me.
Also, the (+) syntax is deprecated - use standard ANSI join syntax instead (Mr. Google is your friend).
This is a sample query. In my query which should be fine tune has lot of decode and nvl functions.
This query is passed to oracle as string from Java .It takes 2 seconds but it should be taking only fraction of seconds..Why should it take only a fraction of a second? How do you know this for a fact? TKProf should be
able to tell you what's happening.
What shall i do?
Shall i create materialise views or a function in oracle with return value as sys_refucursor to Java code.
does function based index should be used in where clause only. If so what should i do to minimise
decode and nvl functions.Please help meSounds to me like you're thrashing around desperately in search of a "fancy" solution.
Read some performance books on Oracle - you don't mention your version of Oracle
or your OS, so it's difficult to help with that.
Christopher Lawson's book is an excellent and very readable into to Oracle performance.
Also, Oracle Performance 101 - as well as anything by Tom Kyte. More advanced stuff is
available from Jonathan Lewis and Christian Antognini. Also, take a look at the FAQ for
this group (as recommended by the other poster) and don't forget the docco*
or (short version) RTFM*.
HTH,
Paul... -
I have a column with values
Sample Data
EMPNO
=====
1
2
3
4
5
6
7
8
.I would like to display all the values of the column in a single row with multiple columns
I do not want to create any other objects. i require a single query.
Sample Output
col1 col2 col3 col4 col5 col6 col7 col8 ............
=======================================
1 2 3 4 5 6 7 8 ...............FYI i am using Oracle 9.2.0
Thanks in Advance
Edited by: user10733211 on Oct 7, 2009 5:38 AMHmm...
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.00
satyaki>
satyaki>
satyaki>with tab
2 as
3 (
4 select 1 cola from dual
5 union all
6 select 2 from dual
7 union all
8 select 3 from dual
9 )
10 select *
11 from tab;
COLA
1
2
3
Elapsed: 00:00:00.00
satyaki>
satyaki>
satyaki>with tab
2 as
3 (
4 select 1 cola from dual
5 union all
6 select 2 from dual
7 union all
8 select 3 from dual
9 )
10 select sum(decode(cola,1,1,0)) col1,
11 sum(decode(cola,2,2,0)) col2,
12 sum(decode(cola,3,3,0)) col3
13 from tab;
COL1 COL2 COL3
1 2 3
Elapsed: 00:00:00.00
satyaki>
satyaki>decode can be used in much more complex case - i guess. ;)
Regards.
Satyaki De.
Maybe you are looking for
-
MSI KT3 Ultra ARU 5.7 BIOS and SoudBlaster Cards - Audigy
I have flashed my BIOS to 5.7 Version and my sound card start to make a lot of noise (crackling) when play AC3 or DVD. If you dont want to use the new AMD CPU 333 FSB you dont need to flash the BIOS - I have Flashed to 5.6 again but, if you want to u
-
I get the following message when I try to open my web site which is cherrycreekwoodcrafts.com "An error occurred while processing your request. Reference #97.1625eb3f.1348245432.690562e" I'm using a MacBookPro, all software in current except iWeb. W
-
Deploying MDM Web Dynpro Components on NWCE 7.2 - /wdconfig not displayed
Hi all - I'm trying to deploy the MDM Web Dynpro Components Framework (the goal is to have NW CE connect to and 'see' the MDM repositories) and according to the URL http://help.sap.com/saphelpnwmdm71/helpdata/en/4a/8c20a0dc93203be10000000a42189b/fra
-
I want to upgrade my Hard Drive to 1TB and more. What is the maximun Hard Drive I can install for a MacBook Pro 2009 Yesterday, I tried a SEAGATE SSHD but my screen was always a showing a QUESTION MARK (?). It's not the cable because when I put back
-
I want to enter some value in a matrix I enbled matrix with oMatrix.AddRow() but problem is that - when I am inputing data in matrix fields , after pressing tab the value disappears how can I resolve the problem?