Tuesday, March 27, 2012
General network error
I am working on sql server 2000.
We have a job that runs every 30 mins every day. It has
been behaving very well. The only time it failed was
yesterday at 10:00am. When I viewed the job history, it
showed the following message:
Executed as user: blahblah\sql_admin. ConnectionRead (recv
()). [SQLSTATE 01000] (Message 10054) General network
error. Check your network documentation. [SQLSTATE 08S01]
(Error 11). The step failed.
General network error usually indicate that there is a
network connection failure. But this specific job/stored
procedure is not pulling data from any other server but
from local table. (Message 10054) indicating BCP overflow
certain column definition, but we are not doing BCP
either.
Could this message mean that there are too many disk I/O
going on at that time, and this job was waiting too long
in idle and failed?
Or could that be a logon info issue?
Any suggestion will be greatly appreciated.
JJHi JJ,
You might want to check SQL errorrlog and make sure that there is no error
occurred during that time.
Sincerely,
Yih-Yoon Lee [Microsoft]
Microsoft SQL Server Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Subscribe to MSDN & use http://msdn.microsoft.com/newsgroups.
Monday, March 26, 2012
Gap filling in a time series
Hello,
I am new to SQL Server and learning lots very quickly! I am experienced at building databases in Access and using VBA in Access and Excel.
I have a time series of 1440 records that may have some gaps in it. I need to check the time series for gaps and then fill these or reject the time series.
The criteria for accepting and rejecting is a user defined number of time steps from 1 to 10. For example, if the user sets the maximum gap as 5 time steps and a gap has 5 or less then I simply want to lineraly interpolate betwen the two timesteps bounding the gap. If the gap is 6 time steps then I will reject the timeseries.
I have searched the BOL and MSDN for SQL Server and think there must be a solution using the PredictTimeSeries in DMX, but not quite sure if I can do this. I may be better off simply passing through the time series as a recordset and processing as I would have done in Access...(I am reluctant to do this as I have of the order 100 * 5 * 365 time series and growng by 100 each day and fear it will take quite some time...)
Can anyone help me by pointing me in the right direction please?
Unless there is a way of using PredictTimeSeries on its own, I think the solution is:
Identify if a record is the a valid one or part of a gap (ie missing values).
Identify the longest gap and reject or process data on this value.
Identify if a record preceedes or succeeds a gap.
For each gap fill it using a linear interpolation.
Thanks,
Alan.
Hello,
Thank you for reading the problem above. I have moved on one step and decided that I need to store the data in a 2-d matrix with time as one dimension and space as another. I will then have to interpolate in both time and space. Also we think that we can work with a subset of just over half of the data so we are going to read the data in to an array and process it that way.
I am still interested in knowing if the DMX functions could be used to fill multiple variable length gaps in a table. Any links would be appreciated.
Thanks,
Alan.
|||I don't think this would be a good application for the time series algorithm. You would have to create a new TS model for each series leading up to each gap and then do a prediction after creating the model. Given the data, the time series may not be able to fill the gap - since the algorithm stops predicting when it determines the predictions are unstable.
We are working on changes to the time series algorithm that may make it more suitable for such problems, but I can't share the details as of yet.
Gap filling in a time series
Hello,
I am new to SQL Server and learning lots very quickly! I am experienced at building databases in Access and using VBA in Access and Excel.
I have a time series of 1440 records that may have some gaps in it. I need to check the time series for gaps and then fill these or reject the time series.
The criteria for accepting and rejecting is a user defined number of time steps from 1 to 10. For example, if the user sets the maximum gap as 5 time steps and a gap has 5 or less then I simply want to lineraly interpolate betwen the two timesteps bounding the gap. If the gap is 6 time steps then I will reject the timeseries.
I have searched the BOL and MSDN for SQL Server and think there must be a solution using the PredictTimeSeries in DMX, but not quite sure if I can do this. I may be better off simply passing through the time series as a recordset and processing as I would have done in Access...(I am reluctant to do this as I have of the order 100 * 5 * 365 time series and growng by 100 each day and fear it will take quite some time...)
Can anyone help me by pointing me in the right direction please?
Unless there is a way of using PredictTimeSeries on its own, I think the solution is:
- Identify if a record is the a valid one or part of a gap (ie missing values). Identify the longest gap and reject or process data on this value. Identify if a record preceedes or succeeds a gap. For each gap fill it using a linear interpolation.
Thanks,
Alan.
Hello,
Thank you for reading the problem above. I have moved on one step and decided that I need to store the data in a 2-d matrix with time as one dimension and space as another. I will then have to interpolate in both time and space. Also we think that we can work with a subset of just over half of the data so we are going to read the data in to an array and process it that way.
I am still interested in knowing if the DMX functions could be used to fill multiple variable length gaps in a table. Any links would be appreciated.
Thanks,
Alan.
|||I don't think this would be a good application for the time series algorithm. You would have to create a new TS model for each series leading up to each gap and then do a prediction after creating the model. Given the data, the time series may not be able to fill the gap - since the algorithm stops predicting when it determines the predictions are unstable.
We are working on changes to the time series algorithm that may make it more suitable for such problems, but I can't share the details as of yet.
Friday, March 23, 2012
fuzzy lookup taking too much time
How big is that other table? The fuzzy will build an index to start with, and this can take time. Review the options on the second tab to influence the index. Also check obvious things like blocking or such like? What about a profiler trace, anything untoward?
|||other table also is the same size and has same no of rows.Thank for the clues I found that some of the NOT null columns in the destination table were not mapped which result in failure of insert. Now it inserts correct rows to temp table and fails with a primary key violation which means its going in a never ending sort of a loop. I am going to put a profiler trace to identify the problem.Any advice welcomeWednesday, March 21, 2012
Fuzzy Grouping in parallel
Hello,
I have created a project to do de-dupification of addresses.
I understand that Fuzzy Grouping will take less time if it has lesser data volume to process.
My source feed file is sometimes huge. So I am splitting the input into multiple branches based on
the first letter of the city. There are 7 branches in the process.
Source File Feed
|
Split data into 7 groups
|
| | | | | | |
FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg
| | | | | | |
Split Split Split Split Split Split Split
| | | | | | |
- -- -- -- -- -- --
| | | | | | | | | | | | | |
<- - - - - - - Write the Canonicals and Dupes from each of these splits into database - - - - - - - - ->
When I designed this I was hoping that each of the Fuzzy Grouping tasks will execute in parallel.
But in reality they are processing one after the other.
Is there anyway to make them execute in parallel?
Appreciate your help.
Thanks
KM
How do you know they are not going in parallel and what kind of machine are you using?
I haven't use Fuzzy groups before, but parallel processing would depend on the hardware you are using. If the machine you use is a single processor, I doubt you can see parallelism on the process.
|||Its a 4 dual core CPU machine with 8 GB RAM.
When I run in the debug mode you could see the data flowing in the pipelines at runtime.
|||Which component are you using right before to fuzzy groups? I *think*, you should be using a multicast in order to get the parallelism you want; as it would generate 7 identical data sets to be consumed by each fuzzy grouping component. See if this article gives you some tips (Parallelism section):
http://www.microsoft.com/technet/prodtechnol/sql/2005/ssisperf.mspx
[Microsoft follow-up] perhaps somebody at MSFT can give you a better explanation
|||Yes, I believe the current pipeline engine will not do a great job in optimizing this one. It would most probably end up using a single thread as Conditional Split is synchronous. You could try to artificially break synchronicity of the fuzzy grouping branches by adding a fake asynchronous transform (Union All with one input and one output should be good).
The next version of the pipeline scheduler should be able to better optimize distribution of threads.
Thanks.
|||Bob and Rafael, thanks a lot for your input. So you are saying it should be like this?
Source File Feed
|
Split data into 7 groups
|
| | | | | | |
UnionAll UnionAll UnionAll UnionAll UnionAll UnionAll UnionAll
| | | | | | |
FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg
| | | | | | |
Split Split Split Split Split Split Split
| | | | | | |
- -- -- -- -- -- --
| | | | | | | | | | | | | |
<- - - - - - - Write the Canonicals and Dupes from each of these splits into database - - - - - - - - ->
|||
As an alternative, could you do the split in one data flow, dumping each branch to a raw file, and then use a seperate data flow (or 7 data flows) to read in the raw files and do the Fuzzy Grouping?
The engine seems to optimize better with multiple data flows, than with multiple paths in the same data flow.
|||Yes, that is how I meant to use Union Alls.
The idea of using raw files sounds good too. I would try both and see which one works better for youe scenario.
Thanks.
|||Thanks a lot guys.
I tried the UnionAll approach and it works perfectly fine. I am able to see that all the threads go in parallel.
A run that used to take around 10 hours got completed in 2.5 hours and that's a lot of saving.
And utilitzation of the CPUs was 100%.
As and when I tweak this more I will keep you all posted.
Thanks again.
|||
KM68 wrote:
Thanks a lot guys.
I tried the UnionAll approach and it works perfectly fine. I am able to see that all the threads go in parallel.
A run that used to take around 10 hours got completed in 2.5 hours and that's a lot of saving.
And utilitzation of the CPUs was 100%.
As and when I tweak this more I will keep you all posted.
Thanks again.
[Microsoft follow-up] This sounds like a possitive feedback.
KM68,
We all will appreciate your updates.
|||I am glad it worked.
Hopefully, with the next version of the data flow engine you will not need this workaround and the execution time can be trimmed even more.
Thanks.
|||Thanks.
Any idea when the next version is scheduled for release?
Fuzzy Grouping in parallel
Hello,
I have created a project to do de-dupification of addresses.
I understand that Fuzzy Grouping will take less time if it has lesser data volume to process.
My source feed file is sometimes huge. So I am splitting the input into multiple branches based on
the first letter of the city. There are 7 branches in the process.
Source File Feed
|
Split data into 7 groups
|
| | | | | | |
FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg
| | | | | | |
Split Split Split Split Split Split Split
| | | | | | |
- -- -- -- -- -- --
| | | | | | | | | | | | | |
<- - - - - - - Write the Canonicals and Dupes from each of these splits into database - - - - - - - - ->
When I designed this I was hoping that each of the Fuzzy Grouping tasks will execute in parallel.
But in reality they are processing one after the other.
Is there anyway to make them execute in parallel?
Appreciate your help.
Thanks
KM
How do you know they are not going in parallel and what kind of machine are you using?
I haven't use Fuzzy groups before, but parallel processing would depend on the hardware you are using. If the machine you use is a single processor, I doubt you can see parallelism on the process.
|||Its a 4 dual core CPU machine with 8 GB RAM.
When I run in the debug mode you could see the data flowing in the pipelines at runtime.
|||Which component are you using right before to fuzzy groups? I *think*, you should be using a multicast in order to get the parallelism you want; as it would generate 7 identical data sets to be consumed by each fuzzy grouping component. See if this article gives you some tips (Parallelism section):
http://www.microsoft.com/technet/prodtechnol/sql/2005/ssisperf.mspx
[Microsoft follow-up] perhaps somebody at MSFT can give you a better explanation
|||Yes, I believe the current pipeline engine will not do a great job in optimizing this one. It would most probably end up using a single thread as Conditional Split is synchronous. You could try to artificially break synchronicity of the fuzzy grouping branches by adding a fake asynchronous transform (Union All with one input and one output should be good).
The next version of the pipeline scheduler should be able to better optimize distribution of threads.
Thanks.
|||Bob and Rafael, thanks a lot for your input. So you are saying it should be like this?
Source File Feed
|
Split data into 7 groups
|
| | | | | | |
UnionAll UnionAll UnionAll UnionAll UnionAll UnionAll UnionAll
| | | | | | |
FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg FzGrpg
| | | | | | |
Split Split Split Split Split Split Split
| | | | | | |
- -- -- -- -- -- --
| | | | | | | | | | | | | |
<- - - - - - - Write the Canonicals and Dupes from each of these splits into database - - - - - - - - ->
|||
As an alternative, could you do the split in one data flow, dumping each branch to a raw file, and then use a seperate data flow (or 7 data flows) to read in the raw files and do the Fuzzy Grouping?
The engine seems to optimize better with multiple data flows, than with multiple paths in the same data flow.
|||Yes, that is how I meant to use Union Alls.
The idea of using raw files sounds good too. I would try both and see which one works better for youe scenario.
Thanks.
|||Thanks a lot guys.
I tried the UnionAll approach and it works perfectly fine. I am able to see that all the threads go in parallel.
A run that used to take around 10 hours got completed in 2.5 hours and that's a lot of saving.
And utilitzation of the CPUs was 100%.
As and when I tweak this more I will keep you all posted.
Thanks again.
|||
KM68 wrote:
Thanks a lot guys.
I tried the UnionAll approach and it works perfectly fine. I am able to see that all the threads go in parallel.
A run that used to take around 10 hours got completed in 2.5 hours and that's a lot of saving.
And utilitzation of the CPUs was 100%.
As and when I tweak this more I will keep you all posted.
Thanks again.
[Microsoft follow-up] This sounds like a possitive feedback.
KM68,
We all will appreciate your updates.
|||I am glad it worked.
Hopefully, with the next version of the data flow engine you will not need this workaround and the execution time can be trimmed even more.
Thanks.
|||Thanks.
Any idea when the next version is scheduled for release?
Fusion Date and Time in a new DataTime field
I have two fields Date and Time. I've just created a new filed called
Date_Time, I need put the old information in the new field. All fields are
DateTime type data.
Thanks a lot.
Carlos A. wrote:
> Hello all
> I have two fields Date and Time. I've just created a new filed called
> Date_Time, I need put the old information in the new field. All fields are
> DateTime type data.
> Thanks a lot.
>
Something like this:
SELECT CONVERT(DATETIME, '09/21/2006' + ' ' + '09:23am')
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||See update statement at end of the script. The code is not dependent on any language settings
(http://www.karaszi.com/SQLServer/info_datetime.asp):
DROP TABLE dt
CREATE TABLE dt(c1 datetime NULL , c2 datetime NULL, c3 datetime NULL)
GO
INSERT INTO dt (c2, c3) VALUES('20060921', '20:44:57')
SELECT * FROM dt
SELECT CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
FROM dt
UPDATE dt
SET c1 = CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
SELECT * FROM dt
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Carlos A." <carlin445@.gmail.com> wrote in message news:usgTaeY3GHA.3344@.TK2MSFTNGP05.phx.gbl...
> Hello all
> I have two fields Date and Time. I've just created a new filed called Date_Time, I need put the
> old information in the new field. All fields are DateTime type data.
> Thanks a lot.
>
|||Thanks both for your answers...
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:evhIm5a3GHA.600@.TK2MSFTNGP05.phx.gbl...
> See update statement at end of the script. The code is not dependent on
> any language settings
> (http://www.karaszi.com/SQLServer/info_datetime.asp):
> DROP TABLE dt
> CREATE TABLE dt(c1 datetime NULL , c2 datetime NULL, c3 datetime NULL)
> GO
> INSERT INTO dt (c2, c3) VALUES('20060921', '20:44:57')
>
> SELECT * FROM dt
> SELECT CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
> FROM dt
> UPDATE dt
> SET c1 = CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
> SELECT * FROM dt
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Carlos A." <carlin445@.gmail.com> wrote in message
> news:usgTaeY3GHA.3344@.TK2MSFTNGP05.phx.gbl...
>
Fusion Date and Time in a new DataTime field
I have two fields Date and Time. I've just created a new filed called
Date_Time, I need put the old information in the new field. All fields are
DateTime type data.
Thanks a lot.Carlos A. wrote:
> Hello all
> I have two fields Date and Time. I've just created a new filed called
> Date_Time, I need put the old information in the new field. All fields ar
e
> DateTime type data.
> Thanks a lot.
>
Something like this:
SELECT CONVERT(DATETIME, '09/21/2006' + ' ' + '09:23am')
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||See update statement at end of the script. The code is not dependent on any
language settings
(http://www.karaszi.com/SQLServer/info_datetime.asp):
DROP TABLE dt
CREATE TABLE dt(c1 datetime NULL , c2 datetime NULL, c3 datetime NULL)
GO
INSERT INTO dt (c2, c3) VALUES('20060921', '20:44:57')
SELECT * FROM dt
SELECT CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
FROM dt
UPDATE dt
SET c1 = CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
SELECT * FROM dt
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Carlos A." <carlin445@.gmail.com> wrote in message news:usgTaeY3GHA.3344@.TK2MSFTNGP05.phx.gb
l...
> Hello all
> I have two fields Date and Time. I've just created a new filed called Dat
e_Time, I need put the
> old information in the new field. All fields are DateTime type data.
> Thanks a lot.
>|||Thanks both for your answers...
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:evhIm5a3GHA.600@.TK2MSFTNGP05.phx.gbl...
> See update statement at end of the script. The code is not dependent on
> any language settings
> (http://www.karaszi.com/SQLServer/info_datetime.asp):
> DROP TABLE dt
> CREATE TABLE dt(c1 datetime NULL , c2 datetime NULL, c3 datetime NULL)
> GO
> INSERT INTO dt (c2, c3) VALUES('20060921', '20:44:57')
>
> SELECT * FROM dt
> SELECT CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
> FROM dt
> UPDATE dt
> SET c1 = CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
> SELECT * FROM dt
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Carlos A." <carlin445@.gmail.com> wrote in message
> news:usgTaeY3GHA.3344@.TK2MSFTNGP05.phx.gbl...
>
Fusion Date and Time in a new DataTime field
I have two fields Date and Time. I've just created a new filed called
Date_Time, I need put the old information in the new field. All fields are
DateTime type data.
Thanks a lot.Carlos A. wrote:
> Hello all
> I have two fields Date and Time. I've just created a new filed called
> Date_Time, I need put the old information in the new field. All fields are
> DateTime type data.
> Thanks a lot.
>
Something like this:
SELECT CONVERT(DATETIME, '09/21/2006' + ' ' + '09:23am')
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||See update statement at end of the script. The code is not dependent on any language settings
(http://www.karaszi.com/SQLServer/info_datetime.asp):
DROP TABLE dt
CREATE TABLE dt(c1 datetime NULL , c2 datetime NULL, c3 datetime NULL)
GO
INSERT INTO dt (c2, c3) VALUES('20060921', '20:44:57')
SELECT * FROM dt
SELECT CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
FROM dt
UPDATE dt
SET c1 = CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
SELECT * FROM dt
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Carlos A." <carlin445@.gmail.com> wrote in message news:usgTaeY3GHA.3344@.TK2MSFTNGP05.phx.gbl...
> Hello all
> I have two fields Date and Time. I've just created a new filed called Date_Time, I need put the
> old information in the new field. All fields are DateTime type data.
> Thanks a lot.
>|||Thanks both for your answers...
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:evhIm5a3GHA.600@.TK2MSFTNGP05.phx.gbl...
> See update statement at end of the script. The code is not dependent on
> any language settings
> (http://www.karaszi.com/SQLServer/info_datetime.asp):
> DROP TABLE dt
> CREATE TABLE dt(c1 datetime NULL , c2 datetime NULL, c3 datetime NULL)
> GO
> INSERT INTO dt (c2, c3) VALUES('20060921', '20:44:57')
>
> SELECT * FROM dt
> SELECT CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
> FROM dt
> UPDATE dt
> SET c1 = CONVERT(char(8), c2, 112) + ' ' + CONVERT(char(8), c3, 114)
> SELECT * FROM dt
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Carlos A." <carlin445@.gmail.com> wrote in message
> news:usgTaeY3GHA.3344@.TK2MSFTNGP05.phx.gbl...
>> Hello all
>> I have two fields Date and Time. I've just created a new filed called
>> Date_Time, I need put the old information in the new field. All fields
>> are DateTime type data.
>> Thanks a lot.
>
Further to 'slow backups'
Why does each db take the same time to back up, regardless
of db size...''?Read the page titled "Optimizing Backup and Restore Performance" in SQL
Server 2000 Books Online. It discusses how to optimize backups to tape.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"H jones" <anonymous@.discussions.microsoft.com> wrote in message
news:031201c3db58$a1d52010$a001280a@.phx.gbl...
I'm backing up to a tape drive
Why does each db take the same time to back up, regardless
of db size...''?
Further to 'slow backups'
Why does each db take the same time to back up, regardless
of db size...''?Read the page titled "Optimizing Backup and Restore Performance" in SQL
Server 2000 Books Online. It discusses how to optimize backups to tape.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"H jones" <anonymous@.discussions.microsoft.com> wrote in message
news:031201c3db58$a1d52010$a001280a@.phx.gbl...
I'm backing up to a tape drive
Why does each db take the same time to back up, regardless
of db size...''?
Monday, March 19, 2012
Function works on SQLServer but not on MSDE
success.
I have a database which runs on my client's SQLServer 2000. It
contains a scalar-valued text function which works fine.
Using the same function definition in the same way on MSDE it returns
the wrong result. I am baffled. Is there some incompatibility I
should know about?
The function (simplified) goes like this
ALTER FUNCTION dbo.fnDoseRate
(
@.ID Int,
@.WhichDoseRate Int
)
RETURNS Float
AS
BEGIN
DECLARE @.Dose Float
IF @.WhichDoseRate=1
SELECT @.Dose = 1.2
IF @.WhichDoseRate=2
SELECT @.Dose = 2.3
IF @.WhichDoseRate=3
SELECT @.Dose = 3.4
RETURN @.Dose
END
I call it from a query
SELECT X, Y, dbo.fnDoseRate(1,1), dbo.fnDoseRate(1,2),
dbo.fnDoseRate(2,3) FROM MyTable
and the query delivers the expected results
If I change the query to
SELECT X, Y, SUM(dbo.fnDoseRate(1,1)), SUM(dbo.fnDoseRate(1,2)),
SUM(dbo.fnDoseRate(2,3)) FROM MyTable GROUP BY X, Y
and the first 2 of the SUM fields return the same value (appropriate
only to 1,1). If I change the last call to 1,3 it gives the same wrong
value.
Any ideas?
Bill Manville
MVP - Microsoft Excel, Oxford, England
FWIW I should add that I created the function definition and the view
using an Access2002 ADP project.
Bill Manville
MVP - Microsoft Excel, Oxford, England
|||Are both engines at the same service pack level?
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
------
"Bill Manville" <Bill-Manville@.msn.com> wrote in message
news:VA.000013fd.3da5fb80@.msn.com...
> FWIW I should add that I created the function definition and the view
> using an Access2002 ADP project.
> Bill Manville
> MVP - Microsoft Excel, Oxford, England
>
|||>Are both engines at the same service pack level?
Good question.
The client controls the remote server so I don't readily know about
that. Is there a way I could interrogate it to find out?
Nor am I sure how to find out the service pack level of my MSDE; I'm a
bit of an amateur in this area! Can you point me in the right
direction?
Looking at SysInfo > Loaded Modules, I see
sqlserver 2000.080.0194.00
Is that the correct place to look? And is that the most recent
version? If not, where should I go to update it?
(I run Microsoft Update regularly but I guess it might not reach MSDE)
Bill Manville
MVP - Microsoft Excel, Oxford, England
|||SELECT @.@.Version
returns:
Microsoft SQL Server 2005 - 9.00.3054.00 (Intel X86) Mar 23 2007 16:28:52
Copyright (c) 1988-2005 Microsoft Corporation Developer Edition on Windows
NT 5.1 (Build 2600: Service Pack 2)
Ah, I'm running on XP which is reported (in this case) as NT 5.1.
It seems to me there is a Microsoft site that lists the versions and the
service packs etc. associated with each. I'm pretty sure I have SS 2005 SP2
installed here.
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
------
"Bill Manville" <Bill-Manville@.msn.com> wrote in message
news:VA.000013fe.3fc7c2fb@.msn.com...
> Good question.
> The client controls the remote server so I don't readily know about
> that. Is there a way I could interrogate it to find out?
> Nor am I sure how to find out the service pack level of my MSDE; I'm a
> bit of an amateur in this area! Can you point me in the right
> direction?
> Looking at SysInfo > Loaded Modules, I see
> sqlserver 2000.080.0194.00
> Is that the correct place to look? And is that the most recent
> version? If not, where should I go to update it?
> (I run Microsoft Update regularly but I guess it might not reach MSDE)
>
> Bill Manville
> MVP - Microsoft Excel, Oxford, England
>
|||OK, so my MSDE is
Microsoft SQL Server 2000 - 8.00.194 (Intel X86)
Aug 6 2000
00:57:48
Copyright (c) 1988-2000 Microsoft Corporation
Personal
Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
and my client's server is
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
May 3 2005
23:18:38
Copyright (c) 1988-2003 Microsoft Corporation
Standard
Edition on Windows NT 5.2 (Build 3790: Service Pack 1)
I guess that indicates my MSDE is a bit out of date.
Now to find out how to get it updated...
Bill Manville
MVP - Microsoft Excel, Oxford,
|||Ah, it's looks like it--perhaps dangerously so. It might still be prone to
the network attacks the pre SP2 versions faced years ago.
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
------
"Bill Manville" <Bill-Manville@.msn.com> wrote in message
news:VA.000013ff.412751a3@.msn.com...
> OK, so my MSDE is
> Microsoft SQL Server 2000 - 8.00.194 (Intel X86)
> Aug 6 2000
> 00:57:48
> Copyright (c) 1988-2000 Microsoft Corporation
> Personal
> Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
>
> and my client's server is
> Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
> May 3 2005
> 23:18:38
> Copyright (c) 1988-2003 Microsoft Corporation
> Standard
> Edition on Windows NT 5.2 (Build 3790: Service Pack 1)
>
> I guess that indicates my MSDE is a bit out of date.
> Now to find out how to get it updated...
> Bill Manville
> MVP - Microsoft Excel, Oxford,
>
Monday, March 12, 2012
Function vs. Sub-Query
BjornI've seen this too. In my case when I looked at the execution plan and the server trace it appears the udf is called for each row returned where the sub query doesn't. I was using a udf to calculate the status of the records. I ended up using a view instead to calculate the status and joined my original query to the view. This is similiar to a sub query and much much faster than the udf.|||Thanks! It makes sense. It seems that the sub query runs first and only once in an sproc, extracting all the data needed for the main query.
Bjorn
function to format Time (24 hours- 5 digits)
Hi
I know this is not a complicated matter.
I'm using this code in my SP to return the time formated in 24 hours
DECLARE @.Hora VARCHAR(5)
SET @.Hora = CONVERT(char(2), DatePart (hh,GetDate())) + ':' + CONVERT(char(2), DatePart (mi,GetDate()))
print @.Hora
te problem is that when the time is any before 10 am for instance 7:23 am the sp returns 7 :23 and I need it ro return 07:23.
What function allows me to insert that '0' to complete the 5 digits format in this case?
thanks
Try this instead:
SELECT My24HrTime = convert( char(5), getdate(), 114 )
For future reference, you may wish to refer to the 'style' chart in Books Online, Topic: 'Cast and Convert'.
(The number 114, above is the 'style' used in the convert() function.)
Function to convert a 'date range' to table of starting and ending
The time elapsed between these day could be greater than one year.
I would like to develop a UDF that would convert these dates into a
table of values. For example, if the dates are 7/1/03 and 4/1/06 the
resulting table would look like:
startingDate endingDate
07/01/03 12/31/03
01/01/04 12/31/04
01/01/05 12/31/05
01/01/06 04/01/06
I am confident that I can do this in a stored procedure, but I'm having
difficulty in a table-set UDF.
Suggestions appreciated.
Craig BuchananAdi-
Not exactly what I was looking for, but useful in other situations.
Thanks a lot for your response.
Craig
Adi wrote:
> You can do it this way:
> create function ShowDates (@.StartDate smalldatetime, @.EndDate
> smalldatetime)
> returns @.DatesTable table (DateCol smalldatetime)
> as
> begin
> while @.startDate <= @.EndDate
> BEGIN
> insert into @.DatesTable (DateCol) values (@.StartDate)
> set @.StartDate = dateadd(dd,1, @.StartDate)
> END
> return
> END
> If you are using SQL Server 2005, then you can use recursive CTE to do
> the same thing
>|||Razvan-
Perfect! Thanks a lot.
Craig Buchanan
Razvan Socol wrote:
> Hello, Craig
> You can use this function (after you give it a better name):
> CREATE FUNCTION YourFunctionName(
> @.EffectiveFrom datetime,
> @.EffectiveTo datetime
> )
> RETURNS @.Result TABLE (
> StartingDate datetime NOT NULL PRIMARY KEY,
> EndingDate datetime NOT NULL UNIQUE,
> CHECK (startingDate<=endingDate)
> ) AS BEGIN
> WHILE YEAR(@.EffectiveFrom)<YEAR(@.EffectiveTo) BEGIN
> DECLARE @.EndOfYear datetime
> SET @.EndOfYear=DATEADD(year,DATEDIFF(year,0,
@.EffectiveFrom)+1,0)-1
> INSERT INTO @.Result VALUES (@.EffectiveFrom, @.EndOfYear)
> SET @.EffectiveFrom=@.EndOfYear+1
> END
> IF @.EffectiveFrom<=@.EffectiveTo BEGIN
> INSERT INTO @.Result VALUES (@.EffectiveFrom, @.EffectiveTo)
> END
> RETURN
> END
> Razvan
>|||Uri-
Thanks for the reply. Not exactly what I needed, but I can use this in
another situation.
Thanks,
Craig
Uri Dimant wrote:
> Try this one
> CREATE FUNCTION fn_dates(@.from AS DATETIME, @.to AS DATETIME)
> RETURNS @.Dates TABLE(dt DATETIME NOT NULL PRIMARY KEY)
> AS
> BEGIN
> DECLARE @.rc AS INT
> SET @.rc = 1
> INSERT INTO @.Dates VALUES(@.from)
> WHILE @.from + @.rc * 2 - 1 <= @.to
> BEGIN
> INSERT INTO @.Dates
> SELECT dt + @.rc FROM @.Dates
> SET @.rc = @.rc * 2
> END
> INSERT INTO @.Dates
> SELECT dt + @.rc FROM @.Dates
> WHERE dt + @.rc <= @.to
> RETURN
> END
> GO
> SELECT dt FROM fn_dates('20060101', '20060130')
>
> "Craig Buchanan" <user@.example.net> wrote in message
> news:OAAuwYKMGHA.2992@.tk2msftngp13.phx.gbl...
>
Wednesday, March 7, 2012
Function for Determining Completion Time
(IT-related) issues. The issues is timestamped and assigned a Priority
level (A-D). Each level relates to an estimated completion time. What
I'm trying to accomplish is to add the estimated completion time to the
time and date. For example. If a customer sends in an issue at 12:21PM
with a priority level of 'A' then it should be known that the issue
should be done at 2:22PM.
Key:
A - 2 hours
B - 8 hours
C - 48 hours
D - 72 hours
This is where it gets tricky. Our business hours are from 7:30am -
4:00pm. I would like to account for this in the function. So if a
customer sends in a request on 01/21/2006 @. 3:30PM with a 'B' priority
level it should be fulfilled by 01/22/2006 @. 3:00PM.
I don't expect anyone to write up a function for this write away. Any
pointers, suggestions, or direction would be greatly appreciated.
*** Sent via Developersdex http://www.examnotes.net ***Hello, Will
Hint: If your workday is 8 and a half hours long (and w
count) you can say:
A = 2 hours = 1 day minus 6.5 hours
B = 8 hours = 1 day minus 0.5 hours
C = 48 hours = 6 days minus 3 hours
D = 72 hours = 9 days minus 4.5 hours
and use a CASE expression to see which of the above is within working
hours.
But I have a feeling that you don't work on sundays, so this method
will not be good enough...
Razvan|||Because of w
Try a look-up table instead:
CREATE TABLE CompletionTimes
(submission_time DATETIME NOT NULL PRIMARY KEY,
A_complete_time DATETIME NOT NULL,
B_complete_time DATETIME NOT NULL,
C_complete_time DATETIME NOT NULL,
D_complete_time DATETIME NOT NULL);
15 minute intervals is probably good enough, so each day is 07:30 to
16:00 hrs to give us about 30 time slots. Again, just estimating, you
have 250 work days to a year, so the table is about 75,000 rows for ten
years.
A calendar table for US Secular holidays can be built from the data at
this website, so you will get the three-day w
http://www.smart.net/~mmontes/ushols.html
function causes a timeout
ALTER FUNCTION[8977].[isClosed] (@.Irefnvarchar(30),@.clidint)
RETURNS BIT
AS/* if the event is closed return true */
BEGIN
RETURN(SELECTclosed
FROMdbo.tblOCompEvents
WHERE(ClientID = @.clid)AND(IRef = @.Iref)
GROUP BYclosed
HAVING(closed = 1))
END
I am using in like this
AND([8977].isClosed(tblOCompEvents.IRef, tblOCompEvents.ClientID)IS NULL)
I have taken the IRef Argument out still times out
I have changed it from IS NULL to = 0 and to = 1, all still cause a time out
any ideas please?
When you write a function like that, it is making SQL Server go through every row to evaluate the isClosed bit, and then go through your original query to evaluate the AND. Try incorporating the function logic into the WHERE clause instead of calling it like you are.|||See if you can join this SQL statement to your original query and get the value of the function logic directly in the SELECT stmt.
|||This would probably run much faster:
ALTER FUNCTION[8977].[isClosed] (@.Irefnvarchar(30),@.clidint)
RETURNS BIT
AS/* if the event is closed return true */
BEGIN
RETURN(SELECT TOP 1closed
FROMdbo.tblOCompEvents
WHERE(ClientID = @.clid)AND(IRef = @.Iref) AND (closed = 1))
END
This may be even faster yet, but you need to do some performance testing.
CREATEFUNCTION [8977].[isClosed](@.Irefnvarchar(30),@.clidint)
RETURNSBITAS/* if the event is closed return true */
BEGIN
IFEXISTS(SELECT closedFROM dbo.tblOCompEventsWHERE(ClientID= @.clid)AND(IRef= @.Iref)AND(closed= 1))
RETURN 1
ELSE
RETURN 0
END
Ultimately, changing your where clause to something like:
WHERE NOT EXISTS(SELECT closedFROM dbo.tblOCompEventsWHERE(ClientID= @.clid)AND(IRef= @.Iref)AND(closed= 1))
would be much much faster than using a scalar function. You can also change your query to use a join like:
SELECT ...
FROM ... a
LEFT JOIN dbo.tblOCompEvents e ON a.ClientID=e.ClientID AND a.IRef=e.IRef AND e.Closed=1
WHERE ...
AND e.ClientID IS NULL
|||yes I suspected that was part of the problem
Thanks
|||tried that thanks but I think the function it's self is not right
|||thanks but I think it is more fundemental than that I don't think the function is doing what I want. it is working fine now there is less pressure on the server (after 5pm in the UK)
But I am sure I could do better
these are the rows
clientid1,row 1, false, ref1
clientid2,row 2, false, ref2
clientid2,row 2, false, ref2
clientid2,row 4, true, ref2
clientid1,row 5, false, ref1
if a series of rows have the same ref and the same client id and JUST one of the rows is trueref2 then return true if the series of rows are all false then return false
However in this case I think it will be better to return the client id and use that to include or exclude clients
The function does achieve your goals, but it's very very inefficient. Any of the above 3 methods I gave will greatly reduce the resources needed to run your queries.
Is this possible?
clientid1,row 1, false, ref1
clientid2,row 2, false, ref2
clientid2,row 3, false, ref2
clientid2,row 4, true, ref2
clientid1,row 5, false, ref1
clientid2,row 6, false, ref2
clientid2,row 7, false, ref2
If so, what should it return? You said if a series of rows have the same ref and the same client id, which there are two series of rows, one series has a true, the other does not. Or did I misunderstand?
|||your example is possible and client2 ref2 would return true and client1 ref1 false you do understand it
I have tried you option :
NOT EXISTS(SELECTclosedFROMdbo.tblOCompEventsWHERE(ClientID = dbo.tblClients.ClientID)AND(IRef = tblOCompEvents.Iref)AND(closed = 1))
thanks
Sunday, February 26, 2012
Full-text Search with CONTAINSTABLE is slow for first time
SELECT * FROM CONTAINSTABLE(TABLE_NAME, COL_Name,
N'ISABOUT(FORMSOF(INFLECTIONAL, TEXT_HERE))') ORDER BY Rank DESC
The table, TABLE_NAME contains around 800 rows and the column COL_Name is
data type of nvarchar(255).
The above query taking around 60 seconds when i execute it very first time.
And in next sub-sequent executions it is taking less than 1 second.
If i execute the same query after 30 minutes (without performing any thing),
in the first time it is taking again 60 seconds.
What whould be the problem here?
Thanks,
Naveen
does this apply?
http://support.microsoft.com/kb/915850
http://www.zetainteractive.com - Shift Happens!
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Naveen Kumar" <Naveen Kumar@.discussions.microsoft.com> wrote in message
news:87A1EE89-C7EC-4290-9DBA-F383396AB7A0@.microsoft.com...
>I have a Full-text Search query as mentioned below.
> SELECT * FROM CONTAINSTABLE(TABLE_NAME, COL_Name,
> N'ISABOUT(FORMSOF(INFLECTIONAL, TEXT_HERE))') ORDER BY Rank DESC
> The table, TABLE_NAME contains around 800 rows and the column COL_Name is
> data type of nvarchar(255).
> The above query taking around 60 seconds when i execute it very first
> time.
> And in next sub-sequent executions it is taking less than 1 second.
> If i execute the same query after 30 minutes (without performing any
> thing),
> in the first time it is taking again 60 seconds.
> What whould be the problem here?
> Thanks,
> Naveen
>
Sunday, February 19, 2012
Full-Text Population Fails for Specific Table
I expect that since the catalog used to populate, but will no longer populate, this must have something to do with the data added to the table recently.
Do these symptoms match any known issues? What should I do to debug this issue? I'm stuck.
Please help. Thank you.
Dave McCall? Do the gatherer logs reveal anything? -- Hilary CotterDirector of Text Mining and Database StrategyRelevantNOISE.Com - Dedicated to mining blogs for business intelligence. This posting is my own and doesn't necessarily represent RelevantNoise's positions, strategies or opinions. Looking for a SQL Server replication book?http://www.nwsu.com/0974973602.html Looking for a FAQ on Indexing Services/SQL FTShttp://www.indexserverfaq.com <Dave McCall@.discussions.microsoft.com> wrote in message news:b6cf47d2-6c0a-4c82-a9f9-42f1d2b71454@.discussions.microsoft.com...I have a SQL Server 2000 database with the latest service pack (3?). For some time, I've had full-text indexing working. Eventually, one of my full-text catalogs failed to populate. After a rebuild, I still couldn't populate it. I dropped it and recreated several catalogs. Eventually, I was able to get all of the original tables into a full-text catalog that populates except one. The offending table has less than 4000 rows in it. It is now in its own catalog which refuses to populate. I can't find any errors in the Application Log that correspond to this catalog population failing.I expect that since the catalog used to populate, but will no longer populate, this must have something to do with the data added to the table recently.Do these symptoms match any known issues? What should I do to debug this issue? I'm stuck.Please help. Thank you.Dave McCall