Quantcast
Channel: SQLServerCentral » SQL Server 2012 » SQL Server 2012 - T-SQL » Latest topics
Viewing all 4901 articles
Browse latest View live

Executing a dynamic tsql stored procedure keeps on executing and not finishing:

$
0
0
/****** Object: StoredProcedure [dbo].[spQMS_FetchStrataSummary] Script Date: 8/4/2013 9:05:25 AM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================---- =============================================/* declare @pEmployeeIDs udtEmployeeIDs insert into @pEmployeeIDs values(1836) exec spQMS_FetchStrataSummary @pEmployeeIDs,'2013-08-02','2013-08-02',33,'BatchNo','E'*/ALTER PROCEDURE [dbo].[spQMS_FetchStrataSummary] @pEmployeeIDs udtEmployeeIDs readonly, @pWorkedDateFrom date, @pWorkedDateTo date, @pProjectProcessID smallint, @pGroupBy varchar(500), @pMode char(1)='I'ASBEGIN SET NOCOUNT ON; declare @StrataSummary nvarchar(4000),@ViewName varchar(500),@Columns varchar(8000),@GroupByCount tinyint,@GroupBy varchar(500) declare @JoinCondition varchar(8000),@Condition varchar(8000),@ViewCondition varchar(100),@ClientSubClientID int set @GroupBy=@pGroupBy select @ClientSubClientID=pqs.ClientSubClientID from tblProcessQCStructure pqs where pqs.ProcessStructureID=@pProjectProcessID -- used to filter client wise data in view if((select IsSameAs from tblProcessQCStructure where ProcessStructureID=@pProjectProcessID) is not null) begin select @pProjectProcessID=pqs.IsSameAs from tblProcessQCStructure pqs where pqs.ProcessStructureID=@pProjectProcessID -- used to get root resource end select @ViewName=DatabaseName+'.'+SchemaName+'.'+ViewName, @ViewCondition=case when Condition is null then '' else ' and ' + Condition end from dbo.tblProcessDataSource where ProcessID=@pProjectProcessID select @GroupByCount= 2-(LEN(@pGroupBy) - LEN(REPLACE(@pGroupBy, ',', ''))) while(@GroupByCount>0) begin set @GroupBy=@GroupBy+',NULL as Column'+CONVERT(varchar, @GroupByCount) set @GroupByCount=@GroupByCount-1 end if(@ViewName is not null) begin if(@pMode='I') begin if not exists ( select 1 from tblProcessQCColumns where SourceColumn='FFMTransactionCount' and ProcessID=@pProjectProcessID ) begin set @StrataSummary =' select '+@GroupBy+', COUNT(*) as [Count], COUNT(*) as [TobeQcd] from '+@ViewName+' trn where WorkedBy in(select EmployeeID from @pEmployeeIDs) and (trn.ProcessID='+convert(varchar(50),@ClientSubClientID) +' or trn.ProcessID is null) and CONVERT(date,WorkedDate) between '''+CONVERT(varchar,@pWorkedDateFrom)+''' and '''+CONVERT(varchar,@pWorkedDateTo)+''' '+@ViewCondition+' group by '+@pGroupBy+' order by '+@pGroupBy exec sp_executesql @StrataSummary,N'@pEmployeeIDs udtEmployeeIDs readonly',@pEmployeeIDs select @StrataSummary end else begin set @StrataSummary =' select '+@GroupBy+', SUM(ISNULL(FFMTransactionCount,0)) as [Count], SUM(ISNULL(FFMTransactionCount,0)) as [TobeQcd] from '+@ViewName+' trn where WorkedBy in(select EmployeeID from @pEmployeeIDs) and (trn.ProcessID='+convert(varchar(50),@ClientSubClientID) +' or trn.ProcessID is null) and CONVERT(date,WorkedDate) between '''+CONVERT(varchar,@pWorkedDateFrom)+''' and '''+CONVERT(varchar,@pWorkedDateTo)+''' '+@ViewCondition+' group by '+@pGroupBy+' order by '+@pGroupBy exec sp_executesql @StrataSummary,N'@pEmployeeIDs udtEmployeeIDs readonly',@pEmployeeIDs --print(@StrataSummary) end end else begin if not exists ( select 1 from tblProcessQCColumns where SourceColumn='FFMTransactionCount' and ProcessID=@pProjectProcessID ) begin select @JoinCondition=COALESCE(@JoinCondition+' and ','')+'ISNULL(CONVERT(varchar(1000),trn.['+pqc.SourceColumn+']),'''')=ISNULL(CONVERT(varchar(1000),qms.['+qc.ColumnName+']),'''')' from dbo.tblProcessQCColumns pqc inner join dbo.tblQCColumns qc on qc.ColumnID=pqc.ColumnID where pqc.ProcessID=@pProjectProcessID and pqc.IsMatchingColumn=1 select @Condition=COALESCE(@Condition+' and ','')+'qms.['+qc.ColumnName+'] is null' from dbo.tblProcessQCColumns pqc inner join dbo.tblQCColumns qc on qc.ColumnID=pqc.ColumnID where pqc.ProcessID=@pProjectProcessID and pqc.IsMatchingColumn=1 set @StrataSummary = ' select '+@GroupBy+', COUNT(*) as [Count], COUNT(*) as [TobeQcd] from '+@ViewName+' trn left outer join tblEmployeeTransactions qms on '+@JoinCondition+' inner join @pEmployeeIDs emp on emp.EmployeeID=trn.WorkedBy where (trn.ProcessID='+convert(varchar(50),@ClientSubClientID) +' or trn.ProcessID is null) and CONVERT(date,WorkedDate) between '''+CONVERT(varchar,@pWorkedDateFrom)+''' and '''+CONVERT(varchar,@pWorkedDateTo)+''' and ' +@Condition+ ' '+@ViewCondition+' group by '+@pGroupBy+' order by '+@pGroupBy --print @StrataSummary exec sp_executesql @StrataSummary,N'@pEmployeeIDs udtEmployeeIDs readonly',@pEmployeeIDs select @StrataSummary end else begin select @JoinCondition=COALESCE(@JoinCondition+' and ','')+'ISNULL(CONVERT(varchar(1000),trn.['+pqc.SourceColumn+']),'''')=ISNULL(CONVERT(varchar(1000),qms.['+qc.ColumnName+']),'''')' from dbo.tblProcessQCColumns pqc inner join dbo.tblQCColumns qc on qc.ColumnID=pqc.ColumnID where pqc.ProcessID=@pProjectProcessID and pqc.IsMatchingColumn=1 select @Condition=COALESCE(@Condition+' and ','')+'qms.['+qc.ColumnName+'] is null' from dbo.tblProcessQCColumns pqc inner join dbo.tblQCColumns qc on qc.ColumnID=pqc.ColumnID where pqc.ProcessID=@pProjectProcessID and pqc.IsMatchingColumn=1 set @StrataSummary = ' select '+@GroupBy+', SUM(ISNULL(FFMTransactionCount,0)) as [Count], SUM(ISNULL(FFMTransactionCount,0)) as [TobeQcd] from '+@ViewName+' trn left outer join tblEmployeeTransactions qms on '+@JoinCondition+' where WorkedBy in(select EmployeeID from @pEmployeeIDs) and (trn.ProcessID='+convert(varchar(50),@ClientSubClientID) +' or trn.ProcessID is null) and CONVERT(date,WorkedDate) between '''+CONVERT(varchar,@pWorkedDateFrom)+''' and '''+CONVERT(varchar,@pWorkedDateTo)+''' and ' +@Condition+ ' '+@ViewCondition+' group by '+@pGroupBy+' order by '+@pGroupBy exec sp_executesql @StrataSummary,N'@pEmployeeIDs udtEmployeeIDs readonly',@pEmployeeIDs end end end print(@StrataSummary)END

Scripting all Triggers

$
0
0
Is there a way to script all Triggers in a Database to a text file?Thanks

RAISEERROR syntax

$
0
0
Hi,I have a Database created before SQL Server 2005. It contains many table Triggers with RAISEERROR statements like: RAISERROR 44446 'The record can''t be added or changed. Referential integrity rules require a related record in table ''tblPolicy''.'SQL Server 2012 tells me this has a syntax error, and Books Online provides the correct syntax as: RAISERROR ('The record can''t be added or changed. Referential integrity rules require a related record in table ''tblPolicy''.', 0, 1)Is there any way to make the old syntax work in SQL Server 2012 as it does in SQL Server 2005?ThanksNorm

Display SQL result like Quick Search format

$
0
0
Hello everyoneI want to display the result of SQL result like Quick Search format. For exampleBelow is the output of my SQL resultSection A (Mick) Albert Edward ScottSection A Eric aka Mick Vernon PrestonSection A Gary Michael GlenaneSection A Maksymiljan Michael KabothSection A Michael Clarence BraithwaiteSection A Michael Paul JonesSection A Shayne Michael CurriganSection A Stipe MamicSection B (Mick) Albert Edward ScottSection B Anthony Michael PayneSection B Gary Michael GlenaneSection B Maksymiljan Michael KabothSection B Michael Clarence BraithwaiteSection B Michael John CrawfordSection B Michael Paul JonesSection B Micheal David JoshiSection B Shayne Michael CurriganSection B Stipe MamicI want the result to display AsSection A(List of all values whose section are from Section A)Michael Clarence BraithwaiteMichael Paul Jones(Mick) Albert Edward Scott........Section B(List of all values whose section are from Section B)Micheal David JoshiShayne Michael CurriganStipe Mamic...........One way is to save my result in temp table and display it but i know there might be some other better way to perform this..Please let me know...Thanx in advance.

Subtraction and Group by in the same table

$
0
0
Hi Guys,I'm trying to accomplish the following : I have a table which has 2 different scenario's. Now each scenario has a set of same fund, function, project etc..etc which differs only in value.So I want to be able to do , group by Fund,Function,Project ,Account ,Department Just need the select statement. I'll write the insert statement and put it in a stored proc with dynamic variables.eg : [code="other"]Fiscal Period Scenario Fund Function Project Account Department Value2014 Jun Actual 10 40 0000 64000 418 72.312014 Jun Jun (0+12) Fcst 10 40 0000 64000 418 500Result Fiscal Period Scenario Fund Function Project Account Dept Value2014 [b]Jul [/b] Jun (0+12) Fcst 10 40 0000 64000 418 427.69 (500-72.31)[/code][b] Even if there is no pair it should still subtract and generate one set of row[/b][b] DDL statement [/b][code="plain"]USE [Test]GO/****** Object: Table [dbo].[Sub] Script Date: 08/07/2013 11:11:14 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[Sub]( [Fiscal_Key] [int] NULL, [Fiscal_Name] [varchar](80) NULL, [Period_Key] [int] NULL, [Period_Name] [varchar](80) NULL, [Scenario_Key] [int] NULL, [Scenario_Name] [varchar](80) NULL, [Fund_Key] [int] NULL, [Fund_Name] [varchar](80) NULL, [Function_Key] [int] NULL, [Function_Name] [varchar](80) NULL, [Project_Key] [int] NULL, [Project_Name] [varchar](80) NULL, [Project_Alias] [varchar](500) NULL, [Account_Key] [int] NULL, [Account_Name] [varchar](80) NULL, [Department_Key] [int] NULL, [Department_Name] [varchar](80) NULL, [Planning_Year_Key] [int] NULL, [Planning_Year_Name] [varchar](80) NULL, [Special_Key] [int] NULL, [Special_Name] [varchar](80) NULL, [value] [float] NULL) ON [PRIMARY]GOSET ANSI_PADDING OFFGOINSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 54, N'429', 1, N'None', 1, N'0', 722.08)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 45, N'420', 1, N'None', 1, N'0', 62.87)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 40, N'415', 1, N'None', 1, N'0', 657.85)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 27, N'402', 1, N'None', 1, N'0', 1400)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 46, N'421', 1, N'None', 1, N'0', 900)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 30, N'405', 1, N'None', 1, N'0', 1923.18)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 43, N'418', 1, N'None', 1, N'0', 72.31)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 60, N'435', 1, N'None', 1, N'0', 850)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 49, N'424', 1, N'None', 1, N'0', 1200)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 42, N'417', 1, N'None', 1, N'0', 1115.22)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 64, N'439', 1, N'None', 1, N'0', 550)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 36, N'411', 1, N'None', 1, N'0', 1200)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 59, N'434', 1, N'None', 1, N'0', 1725)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 59, N'434', 1, N'None', 1, N'0', 842.67)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 28, N'403', 1, N'None', 1, N'0', 2000)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 37, N'412', 1, N'None', 1, N'0', 565.49)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 41, N'416', 1, N'None', 1, N'0', 535)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 54, N'429', 1, N'None', 1, N'0', 800)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 48, N'423', 1, N'None', 1, N'0', 580)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 39, N'414', 1, N'None', 1, N'0', 800)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 58, N'433', 1, N'None', 1, N'0', 900)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 29, N'404', 1, N'None', 1, N'0', 1300)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 185, N'446', 1, N'None', 1, N'0', 500)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 66, N'441', 1, N'None', 1, N'0', 492.3)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 34, N'409', 1, N'None', 1, N'0', 900)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 41, N'416', 1, N'None', 1, N'0', 202.45)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 61, N'436', 1, N'None', 1, N'0', 650)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 52, N'427', 1, N'None', 1, N'0', 53.25)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 55, N'430', 1, N'None', 1, N'0', 620.86)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 56, N'431', 1, N'None', 1, N'0', 1300)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 26, N'401', 1, N'None', 1, N'0', 400)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 40, N'415', 1, N'None', 1, N'0', 1200)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 44, N'419', 1, N'None', 1, N'0', 3787.5)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 33, N'408', 1, N'None', 1, N'0', 635.55)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 53, N'428', 1, N'None', 1, N'0', 200)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 66, N'441', 1, N'None', 1, N'0', 350)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 47, N'422', 1, N'None', 1, N'0', 500)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 26, N'401', 1, N'None', 1, N'0', 433.23)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 42, N'417', 1, N'None', 1, N'0', 1028)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 68, N'443', 1, N'None', 1, N'0', 500)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 37, N'412', 1, N'None', 1, N'0', 650)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 31, N'406', 1, N'None', 1, N'0', 772.07)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 55, N'430', 1, N'None', 1, N'0', 800)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 60, N'435', 1, N'None', 1, N'0', 1155.78)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 32, N'407', 1, N'None', 1, N'0', 1000)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 49, N'424', 1, N'None', 1, N'0', 1123.31)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 63, N'438', 1, N'None', 1, N'0', 675)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 25, N'400', 1, N'None', 1, N'0', 1288.5)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 156, N'444', 1, N'None', 1, N'0', 450)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 68, N'443', 1, N'None', 1, N'0', 575.49)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 63, N'438', 1, N'None', 1, N'0', 681.92)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 34, N'409', 1, N'None', 1, N'0', 1308.75)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 31, N'406', 1, N'None', 1, N'0', 900)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 58, N'433', 1, N'None', 1, N'0', 49.45)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 48, N'423', 1, N'None', 1, N'0', 546.2)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 38, N'413', 1, N'None', 1, N'0', 1462.71)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 131, N'596', 1, N'None', 1, N'0', 80)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 67, N'442', 1, N'None', 1, N'0', 540.03)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 35, N'410', 1, N'None', 1, N'0', 1112.29)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 65, N'440', 1, N'None', 1, N'0', 600)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 27, N'402', 1, N'None', 1, N'0', 1439.67)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 38, N'413', 1, N'None', 1, N'0', 2100)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 53, N'428', 1, N'None', 1, N'0', 9.43)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 62, N'437', 1, N'None', 1, N'0', 1140.5)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 25, N'400', 1, N'None', 1, N'0', 2500)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 32, N'407', 1, N'None', 1, N'0', 539.83)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 35, N'410', 1, N'None', 1, N'0', 1200)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 44, N'419', 1, N'None', 1, N'0', 1800)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 29, N'404', 1, N'None', 1, N'0', 1173.09)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 64, N'439', 1, N'None', 1, N'0', 563.38)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 36, N'411', 1, N'None', 1, N'0', 794.12)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 45, N'420', 1, N'None', 1, N'0', 991.56)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 30, N'405', 1, N'None', 1, N'0', 2000)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 1, N'Actual', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 61, N'436', 1, N'None', 1, N'0', 525.98)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 43, N'418', 1, N'None', 1, N'0', 500)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 62, N'437', 1, N'None', 1, N'0', 1100)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 57, N'432', 1, N'None', 1, N'0', 900)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 33, N'408', 1, N'None', 1, N'0', 1200)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 67, N'442', 1, N'None', 1, N'0', 900)INSERT [dbo].[Sub] ([Fiscal_Key], [Fiscal_Name], [Period_Key], [Period_Name], [Scenario_Key], [Scenario_Name], [Fund_Key], [Fund_Name], [Function_Key], [Function_Name], [Project_Key], [Project_Name], [Project_Alias], [Account_Key], [Account_Name], [Department_Key], [Department_Name], [Planning_Year_Key], [Planning_Year_Name], [Special_Key], [Special_Name], [value]) VALUES (7, N'2014', 16, N'Jun', 11, N'Jun (0+12) Forecast', 1, N'10', 8, N'40', 1, N'0000', N'0000 - Default', 274, N'64000', 184, N'445', 1, N'None', 1, N'0', 500)[/code]Hope it makes sense. Thanks for your help.

Select CASE Sum calculation

$
0
0
I need to create a field that looks at calculation based on the client. My code below needs to apply extra Item field if the client name is 1 or the other:SELECT [CLIENT], [ORDERNUM], [CARRIER], Count([LINE]) as [LINE COUNT], Sum([QTY]) As [ITEM COUNT], CASE WHEN (Sum([QTY])>3 AND [CLIENT]='CLIENT01' THEN Sum([QTY])-3) ELSE CASE WHEN (Sum([QTY])>4 AND [CLIENT]='CLIENT02' THEN Sum([QTY])-4) ELSE 0 END AS [EXTRA ITEMS] FROM SQLQRY1GROUP BY [CLIENT], [ORDERNUM], [CARRIER]ORDER BY [ORDERNUM]I feel that I am missing something because I receive a syntax error near 'EXTRA ITEMS'. Can someone review and provide insight into what I am overlooking?Thank you-:-P

Need Help In Query ....

$
0
0
I need to write a SQL when i pass Max & Min Date like (2013-04-01,2010-01-01)i should get below result which is 6 months differenceMindate MaxDate2010-01-01 2010-07-012010-07-01 2011-01-012011-01-01 2011-07-012011-07-01 2012-01-012012-01-01 2012-07-012012-07-01 2013-01-012013-01-01 2013-04-01

Query lastbackup history from MSDB with 3 replicas, any suggestion

$
0
0
Hi, Data Info for my "high availability system" build SQL2012 :OS2008R2SQL2012, with AlwaysON enabledNumber of replicas, 3Backup Method:NO backup on the primary during working hours, but FULL and DIFF outside working hours.LOG backup on Primary each 15 min.Scenario:Each 30min I check for a successful LOGbackup from MSDBChallenge:-no matter what state my replicas are in, I need the complete BackupList fromall replica's MSDB to see (FULL,DIFF,LOG) backup_start_date and backup_finish_dateI could Query MSDB from each replica, but if one replica are Down cause of hw/swfailure or other tings, I still need the last full history from that replicas msdb backup list.One Solution: Query the msdb.dbo.backupset to DW location or to the other replicas in the availability Group.Any ideas?RegardsMichael Hesselberg

Empty database and reload from an image from another server

$
0
0
Good morningI needed to make a stored procedure for maintaining a database SQLServer 2008. The idea is to automate the deletion of records in the tables and load table by table from another database. You have something to guide me?regards

Need help with query

$
0
0
Table looks like this....employeeId, Activity, StartDateTime, EndDateTime12345 Break 2013-08-06 09:00:00 2013-08-06 09:10:0012345 Lunch 2013-08-06 13:00:00 2013-08-06 14:00:00what i need to do is add a record in between that will take the last endDateTime from the first record and the first record from the startDateTime.. should look like this below12345 Break 2013-08-06 09:00:00 2013-08-06 09:10:0012345 Open 2013-08-06 09:10:00 2013-08-06 13:00:0012345 Lunch 2013-08-06 13:00:00 2013-08-06 14:00:00Any Help would be greatly appreciated

searching between two dates - issue of accuracy

$
0
0
I want records for datetimes between 01/01/2000 (after midnight) through 01/03/2000 (through midnight). Is the following predicate the correct one to use?WHERE orderdate BETWEEN '01/01/2000 00:00:00:000 AND '01/03/2000 00:00:00.000' or will this also return records from midnight of '01/01/2000' ?Thank you. Note: This is for study purposes. I would like to test this for myself, but don't know how to create a table with the sample data needed to test this. If instead of answering someone prefers to point me to a resource for generating a table with a datetime column containing several thousands of dates that are guaranteed to fall within midnight->minute after midnight range, I would also appreciate.

Alternate of materialized view to avoid excessive table reads where Min/Max is required

$
0
0
Hi,I have a similar situation as in the following code where i want to materialize future due orders to avoid excessive reads in the procedure which at the moment i am handling using co-related sub-queries or even APPLY. [code="sql"]USE [AdventureWorks2012] -- SQL 2012 Std EditionGO--CREATE VIEW Sales.future_order_Due_Date--WITH SCHEMABINDING--ASSELECT [CustomerID] , [SalesPersonID] , MIN([OrderDate]) AS OrderDate , MIN([DueDate]) AS DueDate , MIN([ShipDate]) AS ShipDate FROM [Sales].[SalesOrderHeader] GROUP BY [CustomerID], [SalesPersonID] HAVING MIN([DueDate]) > '2007Jan01' --getdate()[/code]So what is the alternate option available to avoid excessive reads from table in every query and in many SPs wherever i need to use this logic?Thanks.

Use same partition scheme across multiple tables

$
0
0
Hi AllWe have some really large tables(100s of GB) in our Datawarehouse and have decided to partition the tables based on the ID column. Is it sensible to use the same partition scheme across all the tables. If so will it cause any issues when we try to merge/split partitions in the live environment? Else is it safe to just use unique partition schemes for each of the tables?

Unknown object type 'SEARCH' Error when I try to CREATE SEARCH PROPERTY LIST

$
0
0
I'm following along in Itzhik Ben Gan's book for Exam 70-461 Querying Microsoft SQL Server 2012, in chapter 6 on Creating Full-Text Catalogs and Indexes. I'm on exercise 1 reproducing steps to Create a Table and Full-Text Components.I am using SQL Server 2012.I have checked that Full-Text Search is installed by using the following query.SELECT SERVERPROPERTY('IsFullTextInstalled');GOI have created a table using the following code. [code="other"]CREATE TABLE dbo.Documents( id INT IDENTITY(1,1) NOT NULL, title NVARCHAR(100) NOT NULL, doctype NCHAR(4) NOT NULL, docexcerpt NVARCHAR(1000) NOT NULL, doccontent VARBINARY(MAX) NOT NULL, CONSTRAINT PK_Documents PRIMARY KEY CLUSTERED(id));GO[/code]I've imported four documents included in exercise folder using following statements:[code="other"]INSERT INTO dbo.Documents(title, doctype, docexcerpt, doccontent)SELECT N'Columnstore Indices and Batch Processing', N'docx', N'You should use a columnstore index on your fact tables, putting all columns of a fact table in a columnstore index. In addition to fact tables, very large dimensions could benefit from columnstore indices as well. Do not use columnstore indices for small dimensions. ', bulkcolumnFROM OPENROWSET(BULK 'C:\Users\Helen\Documents\70-461\Chapter 06\ColumnstoreIndicesAndBatchProcessing.docx', SINGLE_BLOB) AS doc;INSERT INTO dbo.Documents(title, doctype, docexcerpt, doccontent)SELECT N'Introduction to Data Mining', N'docx', N'Using Data Mining is becoming more a necessity for every company and not an advantage of some rare companies anymore. ', bulkcolumnFROM OPENROWSET(BULK 'C:\Users\Helen\Documents\70-461\Chapter 06\IntroductionToDataMining.docx', SINGLE_BLOB) AS doc;INSERT INTO dbo.Documents(title, doctype, docexcerpt, doccontent)SELECT N'Why Is Bleeding Edge a Different Conference', N'docx', N'During high level presentations attendees encounter many questions. For the third year, we are continuing with the breakfast Q&A session. It is very popular, and for two years now, we could not accommodate enough time for all questions and discussions! ', bulkcolumnFROM OPENROWSET(BULK 'C:\Users\Helen\Documents\70-461\Chapter 06\WhyIsBleedingEdgeADifferentConference.docx', SINGLE_BLOB) AS doc;INSERT INTO dbo.Documents(title, doctype, docexcerpt, doccontent)SELECT N'Additivity of Measures', N'docx', N'Additivity of measures is not exactly a data warehouse design problem. However, you have to realize which aggregate functions you will use in reports for which measure, and which aggregate functions you will use when aggregating over which dimension.', bulkcolumnFROM OPENROWSET(BULK 'C:\Users\Helen\Documents\70-461\Chapter 06\AdditivityOfMeasures.docx', SINGLE_BLOB) AS doc;GO[/code] All good so far, but then I try to CREATE SEARCH PROPERTY LIST as follows and get error.[code="other"]CREATE SEARCH PROPERTY LIST WordSearchPropertyList;GOALTER SEARCH PROPERTY LIST WordSearchPropertyList ADD 'Authors' WITH (PROPERTY_SET_GUID = 'F29F85E0-4FF9-1068-AB91-08002B27B3D9', PROPERTY_INT_ID = 4, PROPERTY_DESCRIPTION = 'System.Authors - authors of a given item.');GO[/code]Error is:Msg 343, Level 15, State 1, Line 1Unknown object type 'SEARCH' used in a CREATE, DROP, or ALTER statement.Msg 343, Level 15, State 1, Line 1Unknown object type 'SEARCH' used in a CREATE, DROP, or ALTER statement.Can someone help me get past error so I can run statement? Googled by no documentation about this error found.

Search string without special characters

$
0
0
Hello,I am trying to update our search engine. There is a field called product SKU. Each product has its own sku and it's vachar(100) field. Currently, this field is searched as exact term with simple:WHERE product_sku = @searchTermBut, the problem is that customers sometimes don't know exact sku.For example, for sku = 'F-120-SB', someone tries just F120 (without dash). For sku F-120-SB, product should be found for these search terms:F-120-SB (exact term)F 120 SB (this is done easily with full text search)F120SB (not sure how to get this)F120 (just part and without characters, have no idea how to achieve this :-) )In short, I have to search part of string without certain characters like -,<>" The best idea I have now, is to simply create another field called sku_variations and put there all variations, in this case it would be sku_variations = 'F120SB F120' and then simply search one more field.Any better idea? Thanks

Remove Duplicates

$
0
0
Hi Guys,This should be simple but I've spent too much time on it and can't see the solution. Tried using ROW_NUMBER / OVER and the idea is to delete (row number) rn>1[b]Current Code:[/b]----------------DECLARE @Data TABLE (Name VARCHAR(50) , InOut VARCHAR(50) ,Ord int)insert into @Data select 'Bob','In',1insert into @Data select 'Bob','Out',2insert into @Data select 'Bob','In',3insert into @Data select 'Bob','Out',4insert into @Data select 'Bob','Out',5insert into @Data select 'Sam','Out',1insert into @Data select 'Sam','Out',2insert into @Data select 'Sam','In',3insert into @Data select 'Sam','In',4insert into @Data select 'Sam','Out',5SELECT Row,Ord,DuplicateRow= CASE WHEN Name=NameTHEN (SELECT COUNT(*) FROM (SELECT ROW_NUMBER() OVER ( ORDER BY Name,Ord) AS ROW,Name,InOut FROM @Data ) AS A WHERE A.Name=B.Name AND A.InOut=B.InOut ANDA.ROW<B.ROW)+1 END,Name,InOut FROM (SELECT ROW_NUMBER() OVER (ORDER BY Name,Ord) AS ROW,Name,InOut,Ord FROM @Data) AS B-------------------[b]Current Results:[/b][b]Row Ord DuplicateRow Name InOut[/b]1 1 1 Bob In2 2 1 Bob Out3 3 2 Bob In4 4 2 Bob Out5 5 3 Bob Out6 1 1 Sam Out7 2 2 Sam Out8 3 1 Sam In9 4 2 Sam In10 5 3 Sam Out[b]Desired Results:[/b][b]Row Ord DuplicateRow Name InOut[/b]1 1 1 Bob In2 2 1 Bob Out3 3 1 Bob In4 4 1 Bob Out5 5 2 Bob Out6 1 1 Sam Out7 2 2 Sam Out8 3 1 Sam In9 4 2 Sam In10 5 1 Sam OutYour help appreciated.

Extracting a Date from a string

$
0
0
hi,Bad situation that I can't get out of, but, I am able to get the data below extracted from a string... as you can see I get many variations of the dates I need...I thought about RegEd or using the tally table to give me each character and then coalesce it back together as a date...I'm lost and have searched here and google for hours...Any ideas please???thanks,PS the gaps in the string are what exists...[code="sql"]create table #temp ( MyValues varchar(50) )insert into #temp values ('3/24/12 Saturday ')insert into #temp values ('02/18/2013')insert into #temp values ('fri 10/19/12')insert into #temp values ('11/20/12')insert into #temp values ('7/21/12')[/code]

table

Query COUNT incorrect

$
0
0
My count is incorrect when I do this query:[code="sql"]SELECT Records.JulianDate, Records.Records, COUNT(sales_view.JulianDate) AS Sales, COUNT(cancels_view.JulianDate) AS Cancels, COUNT(sales_view.JulianDate) / Records.Records AS RP, CASE WHEN COUNT(sales_view.JulianDate) = 0 THEN 0 ELSE (COUNT(cancels_view.JulianDate) / COUNT(sales_view.JulianDate)) END AS CPFROM Records LEFT OUTER JOIN sales_view ON Records.Listcode = sales_view.listcode AND Records.JulianDate = sales_view.JulianDate LEFT OUTER JOIN cancels_view ON Records.Listcode = cancels_view.listcode AND Records.JulianDate = cancels_view.JulianDateGROUP BY Records.JulianDate, Records.Records, Records.ListcodeHAVING (Records.Listcode = 'AM') AND (Records.JulianDate = '362')ORDER BY LEN(Records.JulianDate) DESC, Records.JulianDate DESC[/code]When I run this query I get the correct amount of Records of 20000. But I get the incorrect number of Sales (119) and the Cancels is the same as the Sales (119). Now the correct amount of Sales with that listcode and juliandate is 17 and the correct amount of cancels is 7. Now if you multiply 17 * 7 you get 119. So how do I correct this?

Help on query

$
0
0
Hi Friends,Pls help me out ...[code="plain"]create table sample (name varchar(100),Mark1 int,mark2 int,mark3 int )insert into sample values ('x',10,12,5)insert into sample values ('y',15,2,5)insert into sample values ('z',10,12,45)[/code]there are 3 columns mark1,mark2 & mark3I need to find out in which a student scored high mark.which means I need output showing the student name & column name of the highest mark.desired output is name columnname x Mark2y Mark1z mark3
Viewing all 4901 articles
Browse latest View live