Synchronization Performed On Day Basis

Nov 5, 2007

Currently database1 and database2 are planned to be synchronized with the interval of 5 seconds!! ( dont know exact, but i select run continoulsly on subscriber screen )
This could cause serious performance issues as both applications will be live on difference servers.

how can i Synchronization should be performed on day basis or it should be modification basis to avoid any performance issue on live application

i am using merge replication
Local distributor
and subscriber on another server .


plz help me
its urgent

View 3 Replies


ADVERTISEMENT

Windows Synchronization Manager And Subscriber Web Synchronization

Dec 7, 2005

Hi,

View 5 Replies View Related

Web Synchronization - Completed Synchronization Starts Again

Sep 6, 2006

Hello everybody,

There is some strange behaviour i've recently noticed while watching synchronization progress in Replication Monitor on SQL 2005 Server Standard with merge replication configured. The merge process seems to repeat several times.

This is the initial synchronizaion (reinitalization at the subsciber). Client is using Microsoft.SQLServer.Replication objects from .net framework assemblies.

The synchronization starts normally (status is "Running"). The last message of selected session box shows (among other messages): "Beginning evaluating partial replication filters" then "Finished evaluating partial replication filters" and finally "Merge completed after processing xxx changes... etc." after a few seconds. Status changes to "Completed" and then... the merge process starts again!! "Beginning evaluating partial replication filters" etc. And this repeats about 15-20 times.

And so whole process takes about 15 minutes instead about 45 seconds to complete initial synchronization. The number of changes is "Merge completed after processing ..." never change since the first such message.

Is this some bug in web synchronization or some invalid configuration setting? Why does merge process repeat itself so many times??

Please help, thanks in advance.

Kuba

View 6 Replies View Related

Where Is Join Performed?

Mar 1, 2000

I have someone in my organization that is running
EXTREMELY large queries on our SMS database from
his desktop. By that I mean that he is pulling all the fields
from multiple tables requesting 40+ fields. (And yes, he
states that he needs all this information from 1 query!!)

With this in mind, can you tell me where the work is performed?
Are all the requested tables and fields pulled back to the
desktop and then joined? Or, does the work get done on
the server?

Thanks! I appreciate the help.
Toni

View 1 Replies View Related

Value That Is Returned If An Insert Is Not Performed From A SQL Stored Procedure.

Sep 14, 2007

I am using the following stored procedure to insert a value into the database. I am new to stored procedures so I need help. Basically this stored procedurewill only insert a value for "CustomerName" if it is not a duplicate value.
So I noticed in My C# when I call this stored procedure, a negative one "-1"is returned if the insert is not performed because of a duplicate value.
Is that correct? Should I be getting back a negative one "-1" ? You seeI thought that a Zero "0" would be returned if the insert was not performed.Not a negative one?
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO
CREATE PROCEDURE [dbo].[CustomerCreate](  @CustomerDescription nvarchar(100),  @CustomerName nvarchar(100),  @LastUpdateDate datetime,  @LastUpdateUser nvarchar(32),  @inserted_record smallint output)
AS
 if exists (select 1 from Customer where CustomerName = @CustomerName) BEGIN
    set @inserted_record = 0
 END    ELSE BEGIN INSERT INTO Customer (  CustomerDescription,  CustomerName,        Active,  LastUpdateDate,  LastUpdateUser ) VALUES (  @CustomerDescription,  @CustomerName,  @LastUpdateDate,  @LastUpdateUser ) END

View 5 Replies View Related

Must Destination Table Exist Before Transformation Can Be Performed?

Sep 26, 2006

hi all,

i'm a newbie in SSIS. i created a package to transfer data from one table to another. before the data flow, i added a Execute SQL Task package that truncate the dest table if it exists and create a new one if it doesn't.

i'll encounter an error (invalid object name) when i run the whole package but no error if i execute the tasks 1 by 1.

what's the workaround for this? thanks!

View 3 Replies View Related

How To Return Number Of Selected Rows From All Queries Performed On DB

Feb 20, 2013

Recently I had an application developer approach me and asked if I could provided him with a list of sprocs by returned row count. We had an issue where the application passed in a number of parameters which attempted to return 200k plus rows of data and the application was timing out. He changed the required parameters in the application and a reasonable number of rows were returned as expected. Short term solution to this one problem.

However there are always timeout issues with this particular application and we got to thinking that maybe other sprocs that were called using parameters would also fail at some point in time because too much data was being returned.

View 5 Replies View Related

SQL 2012 :: Error 1237 - The Operating Could Not Be Completed - Retry Should Be Performed

Oct 19, 2015

One of our dba's runs a process every night to update the database with a daily data file received from an external source. He was testing on a new SQL Server 2012/Windows 2012 R2 cluster that has an Availability Group. While trying to process INSERTs, the process failed with a error: "could not allocate a new page for database X because of insufficient disk space in filegroup PRIMARY."

The log also contains "Operating System Error 1237 (The operating could not be completed. A retry should be performed) encountered".

However, there is 300 GB free on the data drive (E:) where the .mdf file is located. The SQL Server service account has the "Perform Volume Maintenance Tasks" permission (instant file initialization).

All of the disks are VMware 5.1 or 5.5 VM's and the E: disk has thick/eager zero provisioning.

View 3 Replies View Related

Implicit Conversion Of Char Value To Varchar Cannot Be Performed Because The Collation Of The Value Is Unresolved..

Nov 12, 2007

I got this erorr when trying to create my stored proc,

What do i need to fix, and how do i fix it?!!

Msg 457, Level 16, State 1, Procedure PROC_DAILY_ACTIVITY, Line 13

Implicit conversion of char value to varchar cannot be performed because the collation of the value is unresolved due to a collation conflict.




Code Block
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- =============================================
-- Author: <Zaccheus,Tenchy>
-- Create date: <NOVEMEBER,12,2007>
-- Description: <Reporting stored procedure,DAILY ACTIVITY,>
-- =============================================
CREATE PROCEDURE [dbo].[PROC_DAILY_ACTIVITY]
(@Region_Key int=null)
AS
BEGIN
SELECT
Region_Key,
Null as Customer_Code,
Non_Customer_Activities.Question_code,
Non_Customer_Activities.Description,
Region AS Region,
Name AS Territory_Name,
Non_Customer_Activities.Que_Desc AS Store_Name,
Non_Customer_Activities.Logged_Time AS TheDate,
Non_Customer_Activities.response AS Response,
Null as is_Visit_Fg
FROM [FSSRC].[dbo].Qry_Sales_Group Sales_Group
INNER JOIN
(Select QH.[question_code]
,Question_Header.Description
,CONVERT(datetime,DATEADD(day, (qh.cycle_day-1), p.start_date),6) Logged_Time
,SUBSTRING([entity_code],1,5) SR_Code
,[response]
,Territory_Code SR_Territory_Code
,'Not Customer Related' Que_Desc
From question_history QH
INNER JOIN Period P
ON p.period_code = qh.period_code
INNER JOIN [RC_DWDB_INSTANCE_1].[dbo].[Tbl_Territory_In_Sales_Responsible] as Territory_In_Sales_Responsible
ON Territory_In_Sales_Responsible.SalesPerson_Purchaser_Code=SUBSTRING([entity_code],1,5) COLLATE Latin1_General_CI_AS
INNER JOIN dbo.questions Question_Header
ON Question_Header.question_code = QH.question_code
WHERE [entity_code] like '%.USER%'
AND Question_Header.Question_Code IN('AME01','ASE01','ACO01','ALU01','AOS01','APH01','ATR01','ATE01','ACR06','ACR05','ACR02','ACR03','ACR08','ACR07')
AND CONVERT(datetime,DATEADD(day, (qh.cycle_day-1), p.start_date),6) = '11/9/2007'
) Non_Customer_Activities
ON Sales_Group.Code = Non_Customer_Activities.SR_Territory_Code
UNION ALL
SELECT
Customer_Activities.Customer_Code,
NULL,
NULL,
Region AS Region,
Name AS Territory_Name,
Customer_Activities.Customer_Name AS Store_Name,
Customer_Activities.Logged_Time AS TheDate,
NULL AS Response,
is_Visit_Fg
FROM [FSSRC].[dbo].Qry_Sales_Group Sales_Group
INNER JOIN
(Select distinct time_log Logged_Time
,[entity_code] Customer_Code
,[name] Customer_Name
,Territory_Code Cust_Territory_Code
,MAX(is_Visit_Fg) Is_Visit_Fg
From question_history QH
INNER JOIN Period P
ON p.period_code = qh.period_code
INNER JOIN dbo.questions Question_Header
ON Question_Header.question_code = QH.question_code
INNER JOIN [FSSRC].[dbo].[customer]
ON Entity_Code = [customer_code]
INNER JOIN [FSSRC].[dbo].[visit] V
ON V.[customer_code] = QH.[entity_code]
AND V.[period_code] = QH.[period_code]
AND V.[cycle_day] = QH.[cycle_day]
INNER JOIN [RC_DWDB_INSTANCE_1].[dbo].[Tbl_Territory_In_Sales_Responsible] as Territory_In_Sales_Responsible
ON Territory_In_Sales_Responsible.SalesPerson_Purchaser_Code=[sales_person_code] COLLATE Latin1_General_CI_AS
WHERE [entity_code] NOT like '%.USER%'
AND Convert(datetime,convert(Varchar,time_log,110)) = '11/9/2007'

GROUP BY
time_log
,[entity_code]
,[name]
,Territory_Code
) Customer_Activities
ON Sales_Group.Code = Customer_Activities.Cust_Territory_Code
WHERE @Region_Key=Region_Key
order by 4
END

View 2 Replies View Related

Why Most Of The Index's Avg_fragmentation_in_percent Doesn't Reduce After Reorganize / Rebuild Is Performed

Sep 18, 2007

I am build up a maintenance plan to reorganize and rebuild the index of one database. After that maintenance plan is performed, i found that most of indexes's avg_fragmentation_in_percent doesn't reduce. Is that any efficiency way to reduce fragmentation of the indexes?

View 9 Replies View Related

The Operation Could Not Be Performed Because The OLE DB Provider 'SQLOLEDB' Was Unable To Begin A Distributed Transaction.

Jan 14, 2008

Hi,

I am facing the below mentioned error:

The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction.
[OLE/DB provider returned message: New transaction cannot enlist in the specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' ITransactionJoin::JoinTransaction returned 0x8004d00a].

I have a Insert statement which i am using to insert data into a remote server from my local server. I have added the remote server as a linked server in my local server but when i try to execute the statement i am getting the above mentioned error. I am using Windows Enterprise Edition 2003 and SQL Server 2000.

I have also enabled the Allow InBound and Allow OutBound in the security configuration of My Computer properties but still i am facing the same problem. Kindly let me know how to resolve this issue.

Thanks.

View 13 Replies View Related

An Operation On A Socket Could Not Be Performed Because The System Lacked Sufficient Buffer Space Or Because A Queue

Jul 14, 2006

Hi Guys,

Can anyone help me with this error

An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Protocol error in TDS stream".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Protocol error in TDS stream".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Protocol error in TDS stream".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Communication link failure".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "TCP Provider: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue
was full.

I have three packages running in parallel. This package download data from different databases from ServerA into ServerB.
At some point one of the package is getting the error above at random time.

View 1 Replies View Related

An Operation On A Socket Could Not Be Performed Because The System Lacked Sufficient Buffer Space Or Because A Queue

Jul 18, 2006

Hi Guys,

Can anyone help me with this error

An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Protocol error in TDS stream".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Protocol error in TDS stream".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Protocol error in TDS stream".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Communication link failure".
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "TCP Provider: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue
was full.

View 11 Replies View Related

Basis SQL Question

Mar 21, 2008

How do I format a date value in SQL 2000 sp?  Tired the following none are returning the quivilent rates.  What is the syntax please?
SELECT *FROM tblCompanyWHERE ( C_LastBuyDate = '03/21/2008')
SELECT *FROM tblCompanyWHERE ( C_LastBuyDate = '2008/03/2008')
SELECT *FROM tblCompanyWHERE ( C_LastBuyDate = '03-21-2008')

View 3 Replies View Related

Linked Server Issue: The Operation Could Not Be Performed Because The OLE DB Provider 'SQLOLEDB' Was Unable To Begin A Distribut

Jan 16, 2008

Hi,
I was making a linked server connection between 2 SQL Server 2000 servers (both running on Windows 2003 Server), and I was creating an insert trigger in one of the SQL Server table to insert the same value to the other SQL table. But when I try to make an insert to the table, the following error occurred :

Server: Msg 7391, Level 16, State 1, Procedure <triggername>, Line xx
The operation could not be performed because the OLE DB provider 'SQLOLEDB' was unable to begin a distributed transaction.
[OLE/DB provider returned message: New transaction cannot enlist in the specified transaction coordinator. ]
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' ITransactionJoin::JoinTransaction returned 0x8004d00a].

I tried to change the trigger into a SELECT statement only and the error still occurred. But when I tried to insert a row directly to the linked server via Query Analyzer, it succeeded.
I have read KB 280106, KB 306212, and KB 329332, and I've tried SET XACT_ABORT ON statement, but none of them can solve the problem.
If there's anyone who has idea on what's wrong or has a suggestion what I should try please help.
Thank you in advance.

View 1 Replies View Related

DTS - Dataimport On A Daily Basis

Apr 3, 2000

I have to import data into 2 tables on a daily basis.
The data is provided as a flatfile.
In order to fullfill this task the tables have to be truncated first.
Are there any possibilities to do this job automatically with dts, or do I
have to write an Interface
in VB or something like that?

Thanx

Michael F.

info@sunguard-explorers.de

View 2 Replies View Related

Update On Basis Of Another Table

Apr 12, 2007

hello guys !
i need a little help in an update statement.

i have two tables as

table1(id1,name)
table2(id2,date,val2)

what i want is to set val2=45 in table2 where date=4/4/2007 (say) and id2, now id is to be obtained from table1 based on the name;

like
table1
---------
(1,"akmal")
(2,"peter")
(3,"kamal")

I know the name as peter, but i want to used its id1 (2) in the update statement. You might have got the idea that id2 is a foreign key referring to id1.

How to do that ?

View 2 Replies View Related

Getting Count On Weekly Basis

Apr 11, 2008

Hi All
I am using following code for my application
SELECT
convert(varchar(10),acr._eventTime,120) [Date],
sum(case r.Severity WHEN 'Warning' THEN 1 end)[Warning],
isnull(sum(case r.Severity WHEN 'OK' THEN 1 end),0)[OK],
FROM ActiveCheckIssueResult r
GROUP BY convert(varchar(10),acr._eventTime,120)


it gives me Result as,

Date warning OK
--------- --------- -----
1/1/1008 1 1
2/1/2008 0 2

i want count on weekly basis
Could any one help me?

View 8 Replies View Related

Job Agent To Schedule For Second Basis ????

Dec 4, 2006

Hello friends!

I want to set my job agent to schedule for second basis but in EM i found by right clicking job in EDIT Recuring Job Schedule i m getting option in Hr and MM but not in SS so where i can set this in seconds (SS) or through QA????


T.I.A

View 2 Replies View Related

How Xml Could Help Us With Our ETL Processes On Daily-basis?

May 26, 2006

Hi all of you,

I'm just a newbie with XML. Now we're moving all our DTS to SSIS packages. Most of them are simply processes that takes a plain file and loading these data into Sql table or in inverse way. So that I wonder what role will play XML here.

I mean, are there big differences between store data as XML format and nvarchar?

That sort of stuff.

Thanks in advance for any input,

View 5 Replies View Related

Desperate! - Need Simple MSSQL Server Monitoring Scripts, Ideas, Etc That Can Be Performed By Operator Types (non-programmers)

Jul 20, 2005

Does anyone have any basic, simple scripts of sp's that I can give mycomputer operators to use to monitor for serious conditions on our sqlservers? We are new in the ms-sql arena, a small shop and we cantreally purchase any tools to monitor these servers, but we need somebasic checks that we can use to make sure a server is performing in areasonable fashion, no blocks, cpu<xx%, memory not pegged, IO working,etc...and we need to be able to do this without bugging ourprogrammers every time we are wondering why things are slowwnig down.We are a split shop between as400s and sql servers, and our operationsstaff has no problem performing this type of duty on the 400s. I thinksince the sql servers are so easy to deploy into production, the ideaof how to monitor these things health got lost in the shuffle andallowing the programmers to do it just serves to destabilize ourenvironment.Please help! Our shop has turned to chaos since we went live withMSSQL centric applications and everytime one programmer "resolves anissue" some other programmers application starts to act up.

View 6 Replies View Related

Breaking Query On Basis Of Conditions

Mar 20, 2008

 On a webpage, there are filters to choose from. Like date, amount, SSN (multiple filters can be choosen).I have a single query so far.   SqlCommand cmd = new SqlCommand("SELECT [column1], [column2], [column3],  [column4], [column5] FROM [table] WHERE [column4] = 'condition4'  AND [column5] = @total_bill AND [last_change] >= @txtStartDate AND [last_change] <= @txtEndDate  ", Conn) ;          cmd.Parameters.Add(new SqlParameter("@total_bill", total_bill1.Text));         cmd.Parameters.Add(new SqlParameter("@txtStartDate", txtStartDate.Text));           cmd.Parameters.Add(new SqlParameter("@txtEndDate", txtEndDate.Text));  I want to break the query so that it executes on the basis of different sets of conditions (filters). If I dont select date filter, then the above query will not execute properly.Please help. 

View 2 Replies View Related

Select On The Basis On Month And Year

May 18, 2004

hi guys.

I have a datetime column in my SQL server database.. I need to select the value from the table by passing month and year only..

any suggestions..??

Thanks in advance..

:)

View 1 Replies View Related

SQL 2005 Sps Need To Be Recompiled On A Daily Basis Why?

Aug 16, 2006

Hi All,

I have recently upgraded one of our servers using the in place upgrade method to SQL Server 2005 from SQL Server 2000.

We are currently having an issue with stored procedures as they appear to be running slowly and the only way to correct this issue is to recompile them on a daily basis.

Has any one else had a similar issue, any ideas what could be causing this to occur.

Thanks.

View 1 Replies View Related

Capturing A Warning - Ongoing Basis

May 17, 2004

Hi all,

I currently have a series of stored procedures that capture stock prices on a daily basis, then summarize the results into a daily, and further, a weekly summary of the "index" of a group of stocks. The data is accumulated from a (to use a highly technical unit of measurement...) bunch-O-individual rows of data using aggregate functions such as AVG and SUM.

The problem is that I occasionally get a warning on such aggregate statements which is the common one complaining thusly: "Warning: Null value is eliminated by an aggregate or other SET operation"

I know where it comes from, and I know how to code to protect the aggregate from complaining (i.e., AVG(ISNULL(yadayada,0)) ) but I am interested in figuring out a way to REPORT the statement that contains null values. I can, of course, capture ERRORS in selects, but is the same mechanism used to capture these NULL warnings on my aggregate statements? I don't necessarily want to know which individual row is causing it, just want to "tag" somehow the statement that results in the warning so I can go back after the run and check into it (after capturing local "pointer" info at the time the offending aggregate is invoked).

The code I use to capture errors and trace information follows:
UPDATE PortfolioPerformance
SET PrevDate = @PrevDate,
DailyPerChg = GPP.DailyPerChg,
DailySumPriceChg = GPP.DailySumPriceChg,
SumCurrPrice = GPP.SumCurrPrice,
SumPrevPrice = GPP.SumPrevPrice,
StockCount = GPP.StockCnt,
AvgHighPriceRatio = GPP.AvgHighPriceRatio,
AvgLowPriceRatio = GPP.AvgLowPriceRatio,
Volume = GPP.Volume
FROMPortfolioPerformance PP (nolock), VIEW_Get_PortfolioPerformance GPP
WHERE PP.PortfolioID = GPP.PortfolioID AND
(PP.CreateDate = GPP.CreateDate AND
PP.CreateDate = @CreateDate) AND
PP.PrevDate IS NULL

SELECT @RowCount = LTRIM(STR(@@ROWCOUNT)) /* capture rowcount so @m_error select doesn't clobber it*/

SELECT @m_error = @@Error IF @m_error <> 0 GOTO ErrorHandler
SET @TraceMsg = 'Completed Daily Portfolio Performance calculations (updated ' + @RowCount + ' rows)'
EXECUTE [dbo].[tracelog] 1, 'Index', 'sp_Set_PortfolioPerformance', @TraceMsg

NOTE: the aggregation in the above code is performed in the view referenced as "GPP", but that's outside the realm of the question, I think, so I won't bore you with the details of that just yet.

So I think if I can capture the warning like I do the errors, I can accomplish what I want to accomplish. I haven't yet been able to find any guidance in the Books Online, so do any of you have any pointers?

Thanks!
Paul

View 2 Replies View Related

Scheduling DB Restore On Daily Basis

Sep 27, 2013

I need to be able to restore a test db from a production db on a daily basis..

View 3 Replies View Related

Merging 50 Databases Into One On A Nightly Basis

Sep 13, 2007

How would you solve this problem?
Would you use replication? SSIS? Schedule stored procs? A third party data tool?

We have about 50 databases located at offices around the world. There are several key tables which we need a central copy of at our Head Office.

We need only the new INSERTS or UPDATES for the day to be copied to head office.
The copying process should happen after business hours for that office.

Some cleaning of the data needs to happen before updating head office.

Our database is being installed at new offices every other month, so it's important to us that this be easy to add a new database into the schedule, ideally without needing a SQL DBA or Developer.

We want something robust, performant and easy to troubleshoot.


Kev

View 1 Replies View Related

On What Basis Sql Server Sorts The Rows

May 16, 2007

Hi,



When I execute the following statement:



Select * from table1;



On what basis, SQL server decides the sequence of these rows?



I need to fetch data from a table with very large number of rows. Because of the datasize I need to do this in chunks. I am thinking of passing row counter and fetch N rows at a time. I want to know if there is a need for sorting a table before I apply the above logic or I can rely on default sorting.



Thanks veyr much.



Regards,

Tim

View 5 Replies View Related

Transfer Data In Monthly Or Adhoc Basis

May 7, 2012

I have 10 oracle o/p tables. I have to transfer data in monthly or adhoc basis. Each table will have millions of records. How to transfer Oracle to SQL Server 2005. Which is the best way to transfer the data.

View 2 Replies View Related

SQL Server 2012 :: How To Get Data On Quarterly Basis

May 12, 2014

I need to get results on quarterly basis, matching 2 quarters AUTOMATICALLY.

- As the new quarter starts, it needs to match the last quarter results.

SELECT DATEADD(mm, (QUARTER - 1) * 3, year_date) StartDate,
DATEADD(dd, -1, DATEADD(mm, QUARTER * 3, year_date)) EndDate,
QUARTER QuarterNo

[Code] ....

Here is my Query, I don't know whether I'm getting it right?

--Quarter 1
SELECTD.MerchantName, A.MID, A.TID, ISNULL(SUM(A.SumTrxnMon), 0) AS SumTrxnMon, E.FullName, E.DxBEmail
INTO#Quarter1
FROMdbo.tblRPT_Spend AS A INNER JOIN
dbo.tblMer_DeployORetrieveTerm AS B ON A.MID = B.MID AND A.TID = B.TID INNER JOIN

[Code] ....

View 4 Replies View Related

T-SQL (SS2K8) :: Ranking Rows On Basis Of SUM Of Records

Jul 17, 2014

Following is my table structure

IDRowCount PagID
1448
2267
3297
4216
5405
6254

[Code] ....

PageId is currently set to 0

I have a user input, @IntNoOfRowsPerPage = 800 Means 800 rows per page. So following is the output I require.

AIDRowCountPageId
1448 1
2267 1
3297 2
4216 2
5405 3
6254 3

[Code] ....

The values of PageID are such that summation of RowCount for PageID is <= @IntNoOfRowsPerPage (i.e, 800)

If NTILE function can be used in such scenarios.

View 5 Replies View Related

SQL Server 2012 :: Call SP On The Basis Of Input?

Feb 15, 2015

I have create Store procedure for all the Source and destination table for loading new and updated record.

For example I have below Store procedure

1-SP_Archive_using_merge_Fdoor
2-SP_Archive_using_merge_Fdoop

now I want to call all the sp on the basis of input like If filename is Fdoor then it shold fire the SP_Archive_using_merge_Fdoor , if file name is Fdoop then it shoilud fire the SP_Archive_using_merge_Fdoop like that .

below is the 2 sp .

--First SP
ALTER PROCEDURE [dbo].[SP_Archive_using_merge_Fdoor]
AS
BEGIN
SET NOCOUNT ON
DECLARE @Source_RowCount int
DECLARE @New_RowCount int

[code].....

View 1 Replies View Related

Compound Return On A Rolling Daily Basis

Nov 2, 2014

Looking to create a query, as simple as possible, that allows me to compound returns on a rolling daily basis. So far this this have I have:

DECLARE @stock_returns TABLE
(
stock_code VARCHAR(10) NOT NULL,
date1 DATE NOT NULL,
daily_return NUMERIC(10, 2) NOT NULL
);

[Code] ....

But I´m not getting what I need. If you run the above select, the output should be:

stock_codedate1daily_returnLAGCompound_return
stock12014-07-080.00510 0.00000 0.0051000000
stock12014-07-090.00300 0.00510 0.0081153000
stock12014-07-100.00500 0.00300 0.0080150000
stock12014-07-110.00600 0.00500 0.0110300000
stock12014-07-120.00200 0.00600 0.0080120000
stock12014-07-130.00700 0.00200 0.0090140000
stock12014-07-140.00240 0.00700 0.0094168000
stock12014-07-150.00240 0.00240 0.0048057600
stock12014-07-160.00250 0.00240 0.0049060000

The problem is with this column:

(lag(daily_return, 1, 0) over (order by date1) + 1) * (daily_return + 1) - 1 as Compound_return

The (daily_return + 1) portion should be the accumulated compound return. So it should be something like

(lag(ACCUMULATED_COMPOUND RETURN, 1, 0) over (order by date1) + 1) * (daily_return + 1) - 1 as Compound_return

And the output should be:

Date1Daily returnLAGCompound Return
08/07/20140,00510,00000,0051
09/07/20140,00300,00510,0081
10/07/20140,00500,00300,0132
11/07/20140,00600,00500,0192
12/07/20140,00200,00600,0213
13/07/20140,00700,00200,0284
14/07/20140,00240,00700,0309
15/07/20140,00240,00240,0334
16/07/20140,00250,00240,0359

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved