Showing posts with label custom. Show all posts
Showing posts with label custom. Show all posts

Sunday, March 25, 2012

Customising Report Manager

Hi,

I have implemented Forms authentication for my report manager. (using the custom Security sample solution) ie i have added a login page, which upon autentication redirects to report manager.

Now i want to add a "sign out" link in the report manager so that when the user clicks on that, it gets redirects to the login page.

Is it possible, if so can anyone let me know where i can implement the code for the same

Thanks,

Bharath V V

Report manager wasn't exactly meant to be customized. How did you create your login page? Using Visual Studio 2005?

|||

There really is not a lot of customizing that you can do with report manager.

In the past few times I have needed to customize, I just created an entire application to replace report manager.

Then used a combination of the web services and/or report viewer control.

BobP

|||Yes.. using VS 2005, and the CustomSecurity.Sln given in the reporting services samples.|||

Oh thats bad news for me

anyways thanks BobP

bharthvv

Customise Report Parameters in Report Manager

Is it possible to add custom controls in for parameters in report manager?

I have a parameter that requires the user to click a button and select a bunch of things in another form. How can i do this in reporting services?

I also would like to change the layout of the parameters toolbar, ie. make text boxes smaller widths, show/hide parameters based on other parameter values.

I know i could write my own web page that does this and hide the parameters toolbar when they run the report, but this would mean that we lose other functionality that report manager has, eg. scheduling.

Does anyone know if customising the report manager will become available in a later version?

You're correct that you can't customize Report Manager like this in RS 2005. You're also correct that if you wrote your own app using the Reporting controls in VS 2005, you'd have a lot of flexibility.

As for whether you'll be able to do this customization of RM in a later version, I doubt it, but there is "talk" of shipping add'l VS Reporting controls for things like scheduling and security, so you could build your own RM implementation.

Customise Report Parameters in Report Manager

Is it possible to add custom controls in for parameters in report manager?

I have a parameter that requires the user to click a button and select a bunch of things in another form. How can i do this in reporting services?

I also would like to change the layout of the parameters toolbar, ie. make text boxes smaller widths, show/hide parameters based on other parameter values.

I know i could write my own web page that does this and hide the parameters toolbar when they run the report, but this would mean that we lose other functionality that report manager has, eg. scheduling.

Does anyone know if customising the report manager will become available in a later version?

You're correct that you can't customize Report Manager like this in RS 2005. You're also correct that if you wrote your own app using the Reporting controls in VS 2005, you'd have a lot of flexibility.

As for whether you'll be able to do this customization of RM in a later version, I doubt it, but there is "talk" of shipping add'l VS Reporting controls for things like scheduling and security, so you could build your own RM implementation.

Custome code not working in Report manager

Hi all,
I have Written the Custom code to compare two different dates and
show a message Box depending on their values .It was Working Fine in
preview tab.But it is not working when i deploy to web.Only rhe message
box part is not working in Web
I do have the Custom code like this
Public Function Errorbox(ByVal s as Date,ByVal s1 as Date) As String
If s>s1 Then
System.Windows.Forms.MessageBox.Show("From Date is greater than
To Date,Please Click Ok" )
End if
Return "a"
End Function
and i gave a text box (Just a text box)
To call this custome code and i gave the expression
=Code.Errorbox(Parameters!FROM_DATE.Value,Parameters!TO_DATE.Value)
i added this Assembly also
"System.Windows.Forms"
Its not working in Report manager(web) .Can any body help me out to
knowwhat would be the Problem.i am very new to this VB Coding
Thank you
Raj Deep.AYou need to add the assembly to the following folders:
C:\Program Files\Microsoft SQL Server\80\Tools\Report Designer
C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\ReportServer\bin
Hope this helps.
"RajDeep" wrote:
> Hi all,
> I have Written the Custom code to compare two different dates and
> show a message Box depending on their values .It was Working Fine in
> preview tab.But it is not working when i deploy to web.Only rhe message
> box part is not working in Web
> I do have the Custom code like this
> Public Function Errorbox(ByVal s as Date,ByVal s1 as Date) As String
> If s>s1 Then
> System.Windows.Forms.MessageBox.Show("From Date is greater than
> To Date,Please Click Ok" )
> End if
> Return "a"
> End Function
> and i gave a text box (Just a text box)
> To call this custome code and i gave the expression
> =Code.Errorbox(Parameters!FROM_DATE.Value,Parameters!TO_DATE.Value)
> i added this Assembly also
> "System.Windows.Forms"
> Its not working in Report manager(web) .Can any body help me out to
> knowwhat would be the Problem.i am very new to this VB Coding
> Thank you
> Raj Deep.A
>

custome code - global?

Is the custom code you write in the Properties section of one report
accessible to other reports within the same project? if so, how is it
accessed?
Thanks,
PMNo it is not. Consider code behind reports. If you want to do this you have
to use custom assemblies. I.e. create the code outside of RS and then
reference it from RS.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"PacMan" <PacMan@.discussions.microsoft.com> wrote in message
news:32547C22-21CA-4EB6-9482-6DDB4A21A630@.microsoft.com...
> Is the custom code you write in the Properties section of one report
> accessible to other reports within the same project? if so, how is it
> accessed?
> Thanks,
> PM

custom(and dynamic) record fields query

Hello,
I need to create a query that depends on custom fields (virtual).
First I'll try to outline the background.
I got Nodes table, that has NodeID field, and other (not really important)
fields like name, some boolean fields and so on.
Lets define node as an item for sale (just for the example purposes).
User of the application can create custom attribute values for each each
item (node).
To make the attribute names consistant through application I got another
table Attributes (AttID, AttributeName)
And the last table is association table between Node and Attributes
containing the value of the attribute as well.
I'd like to get following resultset:
NodeID, NodeName, CustomField1, CustomField2, CustomField3, ... and so on
(names of the fields would depend on Attribute name)
with values:
1,FirstNode, 'one of the values', 'another value', NULL, ...
2,SecondNode, NULL, NULL, NULL , ...
3,ThirdNode, NULL, NULL, 'some value', ...
SQL for creation such tables would look like (I ommited constrains and
indexes for siplicity):
CREATE TABLE Nodes (
NodeID INT IDENTITY (1, 1) NOT NULL,
NodeName NVARCHAR(255) NULL
)
CREATE TABLE Attributes (
AttID INT IDENTITY (1, 1) NOT NULL,
AttributeName NVARCHAR(50) NOT NULL
)
CREATE TABLE NodeAttr (
NodeID INT NOT NULL,
AttID INT NOT NULL,
Value NVARCHAR(255)
)
some data insertion:
INSERT INTO Nodes(NodeName) VALUES ('FirstNode')
INSERT INTO Nodes(NodeName) VALUES ('SecondNode')
INSERT INTO Nodes(NodeName) VALUES ('ThirdNode')
INSERT INTO Nodes(NodeName) VALUES ('FourthNode')
INSERT INTO Nodes(NodeName) VALUES ('FifthNode')
INSERT INTO Attributes (AttributeName) VALUES ('CustomField1')
INSERT INTO Attributes (AttributeName) VALUES ('CustomField2')
INSERT INTO Attributes (AttributeName) VALUES ('CustomField3')
INSERT INTO NodeAttr (NodeID,AttID,Value) VALUES (1,1,'My Value for Field1')
INSERT INTO NodeAttr (NodeID,AttID,Value) VALUES (1,2,'My Value for Field2')
INSERT INTO NodeAttr (NodeID,AttID,Value) VALUES (1,3,'My Value for Field3')
INSERT INTO NodeAttr (NodeID,AttID,Value) VALUES (3,3,'My Value for Field3
in third node')
Second I describe my approach to the problem.
I created function that retrieves data based on nodeID and Attribute name:
CREATE FUNCTION myfun(@.NodeID INT, @.AttributeName NVARCHAR(50))
RETURNS NVARCHAR(255)
AS
BEGIN
DECLARE @.Value NVARCHAR(255)
SET @.Value=NULL
SELECT @.Value=Value FROM NodeAttr NA
INNER JOIN Attributes A ON (NA.AttID=A.AttID)
WHERE NodeID=@.NodeID AND AttributeName=@.AttributeName
RETURN @.Value
END
Next, I create dynamic SQL for data retrieval:
declare @.query NVARCHAR(4000)
SELECT
@.query=isnull(@.query+',','SELECT NodeID,
')+'dbo.myfun(NodeID,'''+AttributeName+''') AS ['+AttributeName+']'
FROM Attributes
SET @.query = @.query + ' FROM Nodes'
and execute it:
EXECUTE sp_executesql @.query
Dynamicly generated SQL looks like this:
SELECT NodeID,
dbo.myfun(NodeID,'CustomField1') AS [CustomField1],
dbo.myfun(NodeID,'CustomField2') AS [CustomField2],
dbo.myfun(NodeID,'CustomField3') AS [CustomField3]
FROM Nodes
It is great when you deal with small number of nodes. When node number is
about 2000 the perfomarnce is really bad (executes over a minute). And I'd
like to have even more.
Anyone can point me to better solution? :)
regards,
Pawel Rogozinski
Software Engineer at Eracent Inc.
pawel.rogozinski@.eracent.com>> I need to create a query that depends on custom fields (virtual). <<
This flawed approach is called an EAV design and newbies re-invent it
about once a month here. The basic fallacy that leads to meltdown in
about a year is that you are mixing data and metadata. Also, columns
are not fields and rows are not records -- totally different concepts.
Then give the users a copy of SQL and get out of the way. If any
random user is a better database programmers and designer than you are,
you should not be programming.
It is not just exponently slow; since it has no data integrity, it is
error-prone, too!!|||>> I'd like to get following resultset:
It is better to use a client programming language or a report writer to
generate such cross tabulations. In t-SQL, most general approaches are
clumsy. For some methods refer to: http://tinyurl.com/ayjwa
Anith|||This sounds like an EAV (Entity-Attribute-Value) design. One of it's biggest
failings is that reporting is significantly more difficult and slow. Another
divanatage is that it requires dynamic SQL and all of its issues. Thus, y
ou
should be aware that the difficulties you are having in finding a solution a
re
directly related to the design.
That said and assuming you wanted to continue with this design, one solution
that takes the dynamic SQL out of the equation would be to make the equivale
nt
of a materialized view. In essence, create a permanent temp table where each
"attribute" in your design is a column in this temp table. You would then
populate and maintain this table with every entity's attribute values. To do
that you can use a massive case statement like so:
Select NA.NodeId
, Min(Case When NA.AttId = 1 Then NA.Value End) As Attribute1Name
, Min(Case When NA.AttId = 2 Then NA.Value End) As Attribute2Name
...
From NodeAttr As NA
Group By NA.NodeId
In order to maitain the contents of the table, you'll need to use triggers t
o
update the entity's appropriate attribute values in the temp table and so on
.
The solutions to the problems created by this type of design get uglier and
uglier and the performance gets worse and worse.
Thomas|||Celko,
thanks for your "constructive" comments.

> This flawed approach is called an EAV design
> and newbies re-invent it about once a month here.
Nice. I did not reinvent this, I'm just working on such flawed design,
as you called it.
Do you know better design, that could substitute EAV then?
[...cut...]

> It is not just exponently slow; since it has no data
> integrity, it is error-prone, too!!
Didn't I mention that I did not put integrity constraitns for simplicity
of the example? I believie I did.
I would be very gratefull if you could lead me to a better solution and
not criticizing my approach, as I am aware of the flaws that come with
my approach (and the design as well).
*** Sent via Developersdex http://www.examnotes.net ***|||I like the temporary table solution.
As the attributes are not added/deleted frequently it could be one of the
best approaches.
regards,
Pawel Rogozinski
Software Engineer at Eracent
pawel.rogozinski@.eracent.com|||>> Do you know better design, that could substitute EAV then? <<
The point everyone is trying to get across to you is that you need a
totally different approach; it is not a matter of finding a substutute.
Why not use an actual data model, based on the specifications from the
user. There is no "magical, one size fits all" answer that you s
with kludges like EAV. Each database is a thing in itself, but you can
look for patterns for reuse.
simplicity of the example? I believe I did. <<
Did I meniton that doing that is virtually impossible without a few
hundred lines of procedural code in triggers and procs if you have a
database of any size?
Let's say I have 50 attributes of type INTEGER in my EAV model. They
are crammed into one table. Each one has 1 or 2 CHECK() constraints
that are totally different. Now try to write the CASE expression with
50 WHEN clauses to validlate each one.
Let's say that I have a primary key among those 50 attributes. Can you
show me the uniquenss constraint to enforce that business rule?
Let's say that I have a a foreign key among those 50 attributes. Can
you show me the uniquness constraint to enforce that business rule?
And do the DRI Actions required to maintain this relationship?
Thomas Coleman had a recent posting where he worked out the equivalent
of a simple GROUP BY statement for an EAV. Google it.sql

Thursday, March 22, 2012

Custom Zoom Factor

How'd
I was asked by a client if they could specify a custom zoom factor is this possible?
If not can it be incorporated into next SP or Version?
Thanks in Advance
SheaThe Zoom supported by Reporting Services is the standard Zoom supported by
IE. You can employ any numeric value and then also Page Width and Whole
Page.
What is the custom Zoom factor your client wishes to use?
Is your client accessing reports through Report Manager or through a custom
application?
--
Bryan Keller
Developer Documentation
SQL Server Reporting Services
A friendly reminder that this posting is provided "AS IS" with no
warranties, and confers no rights.
"Shea Strickland" <SheaStrickland@.discussions.microsoft.com> wrote in
message news:21322E4C-766B-4812-B1BA-6D096BA6753D@.microsoft.com...
> How'd
> I was asked by a client if they could specify a custom zoom factor is this
possible?
> If not can it be incorporated into next SP or Version?
> Thanks in Advance
> Shea|||I guess the client wants to be able to type a % in the drop down in the builtin control just like other microsoft products. eg 79%
The application is a custom web app that just uses the builtin reportparameter control and navigation control (export etc)
Thanks for you help
Shea
"Bryan Keller [MSFT]" wrote:
> The Zoom supported by Reporting Services is the standard Zoom supported by
> IE. You can employ any numeric value and then also Page Width and Whole
> Page.
> What is the custom Zoom factor your client wishes to use?
> Is your client accessing reports through Report Manager or through a custom
> application?
> --
> Bryan Keller
> Developer Documentation
> SQL Server Reporting Services
> A friendly reminder that this posting is provided "AS IS" with no
> warranties, and confers no rights.
>
> "Shea Strickland" <SheaStrickland@.discussions.microsoft.com> wrote in
> message news:21322E4C-766B-4812-B1BA-6D096BA6753D@.microsoft.com...
> > How'd
> >
> > I was asked by a client if they could specify a custom zoom factor is this
> possible?
> > If not can it be incorporated into next SP or Version?
> >
> > Thanks in Advance
> > Shea
>
>

Custom Y Axis Labels

Greetings.
I have data that is bit data type. I'd like the Y axis to display "Yes" for
1, "No" for Zero or Negative one.
How can this be accomplished? Thanks in advance.
--
Tim Heuer
heuert at Comcast dot netThe closest you can get is to use a bar chart (and therefore the x-axis
becomes the y-axis) with two static series - one for "Yes" and one for "No".
The aggregate functions would look similar to this:
Yes: =Sum( iif(Fields!BitField.Value = 1, 1, 0))
No: =Sum( iif(Fields!BitField.Value <> 1, 1, 0))
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Tim Heuer" <heuert at Comcast dot net> wrote in message
news:4BB4D6A1-693D-4292-986B-DB66E6C17669@.microsoft.com...
> Greetings.
> I have data that is bit data type. I'd like the Y axis to display "Yes"
for
> 1, "No" for Zero or Negative one.
> How can this be accomplished? Thanks in advance.
> --
> Tim Heuer
> heuert at Comcast dot net

Custom xml format with FOR XML EXPLICIT

I'm working on Sql Server 2005 xml capabilities, but I'm not able to obtain what I want.

Let's say I have a table with 10 fields: Field1, Field2, ..., Field10.

I would, with a "FOR XML" clause, obtain an xml document like this one:

<MyTable>
<Field1>F1value</Field1>
<Field2 Field3="F3value">F2value</Field2>
</MyTable>
<MyTable>
...
</MyTable>

I think correct way is with the "EXPLICIT" mode, but I'm not able to find the syntax to make Field3 become an attribute of the element generated from Field2.

Does someone knows if it's possible and, if it is, how?

Any help will be truly appreciated.

Easier to do this

select Field1 as "Field1",
Field3 as "Field2/@.Field3",
Field2 as "Field2"
from MyTable
for xml path('MyTable')

|||Thank you so much!

This is exactly what I was looking for.sql

custom xml data type

When I try to create a custom xml datatype I get the following error:
CREATE TYPE myOwnXMLType FROM xml;
Msg 15226, Level 16, State 1, Line 1
Cannot create user defined types from an XML datatype.
Is there anything I can do ? Other types work fine (int, nvarchar(max)
etc.). I use SQL Server 2005 Standard Edition.
Alex Voit wrote:
> When I try to create a custom xml datatype I get the following error:
> CREATE TYPE myOwnXMLType FROM xml;
> Msg 15226, Level 16, State 1, Line 1
> Cannot create user defined types from an XML datatype.
> Is there anything I can do ? Other types work fine (int, nvarchar(max)
> etc.). I use SQL Server 2005 Standard Edition.
The documentation lists the following allowed base types:
bigint
binary(n)
bit
char(n)
datetime
decimal
float
image
int
money
nchar(n)
ntext
numeric
nvarchar(n | max)
real
smalldatetime
smallint
smallmoney
sql_variant
text
tinyint
uniqueidentifier
varbinary(n | max)
varchar(n | max)
The xml data type is not listed as an allowed base type for CREATE TYPE
FROM.

Martin Honnen -- MVP XML
http://JavaScript.FAQTs.com/
|||We did not allow CREATE TYPE on the XML datatype. Please file a request at
http://connect.microsoft.com/sqlserver/feedback if this is a functionality
that you need.
Best regards
Michael
"Martin Honnen" <mahotrash@.yahoo.de> wrote in message
news:euWAnmrpHHA.4196@.TK2MSFTNGP06.phx.gbl...
> Alex Voit wrote:
> The documentation lists the following allowed base types:
> bigint
> binary(n)
> bit
> char(n)
> datetime
> decimal
> float
> image
> int
> money
> nchar(n)
> ntext
> numeric
> nvarchar(n | max)
> real
> smalldatetime
> smallint
> smallmoney
> sql_variant
> text
> tinyint
> uniqueidentifier
> varbinary(n | max)
> varchar(n | max)
>
> The xml data type is not listed as an allowed base type for CREATE TYPE
> FROM.
>
> --
> Martin Honnen -- MVP XML
> http://JavaScript.FAQTs.com/

custom xml data type

When I try to create a custom xml datatype I get the following error:
CREATE TYPE myOwnXMLType FROM xml;
Msg 15226, Level 16, State 1, Line 1
Cannot create user defined types from an XML datatype.
Is there anything I can do ? Other types work fine (int, nvarchar(max)
etc.). I use SQL Server 2005 Standard Edition.Alex Voit wrote:
> When I try to create a custom xml datatype I get the following error:
> CREATE TYPE myOwnXMLType FROM xml;
> Msg 15226, Level 16, State 1, Line 1
> Cannot create user defined types from an XML datatype.
> Is there anything I can do ? Other types work fine (int, nvarchar(max)
> etc.). I use SQL Server 2005 Standard Edition.
The documentation lists the following allowed base types:
bigint
binary(n)
bit
char(n)
datetime
decimal
float
image
int
money
nchar(n)
ntext
numeric
nvarchar(n | max)
real
smalldatetime
smallint
smallmoney
sql_variant
text
tinyint
uniqueidentifier
varbinary(n | max)
varchar(n | max)
The xml data type is not listed as an allowed base type for CREATE TYPE
FROM.
Martin Honnen -- MVP XML
http://JavaScript.FAQTs.com/|||We did not allow CREATE TYPE on the XML datatype. Please file a request at
http://connect.microsoft.com/sqlserver/feedback if this is a functionality
that you need.
Best regards
Michael
"Martin Honnen" <mahotrash@.yahoo.de> wrote in message
news:euWAnmrpHHA.4196@.TK2MSFTNGP06.phx.gbl...
> Alex Voit wrote:
> The documentation lists the following allowed base types:
> bigint
> binary(n)
> bit
> char(n)
> datetime
> decimal
> float
> image
> int
> money
> nchar(n)
> ntext
> numeric
> nvarchar(n | max)
> real
> smalldatetime
> smallint
> smallmoney
> sql_variant
> text
> tinyint
> uniqueidentifier
> varbinary(n | max)
> varchar(n | max)
>
> The xml data type is not listed as an allowed base type for CREATE TYPE
> FROM.
>
> --
> Martin Honnen -- MVP XML
> http://JavaScript.FAQTs.com/

custom wordbreaker

Is it possible to create a custom word breaker for SQL server? I've found
documentation for sharepoint and other technologies but SQL server appears
to be different and there are very few articles about customization (beyond
editing the junk word lists) for it.Can you provide some more information on what you are trying to do here? Are
you looking for some kind of a parsing routine that parses a character
string based on the occurrence of white space and punctuation?
Anith|||The problem I'm trying to address is that all the standard word breakers
don't handle chemical compound names correctly. For example AZ-113 might be
a valid term but even if i stick it in double quotes, the word breaker turns
it into two seperate terms 'AZ' and '113'. I need a way to have it keep
these as specific terms.
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:e58Ee#EFFHA.628@.TK2MSFTNGP15.phx.gbl...
> Can you provide some more information on what you are trying to do here?
Are
> you looking for some kind of a parsing routine that parses a character
> string based on the occurrence of white space and punctuation?
> --
> Anith
>|||Clyde Seigle wrote:
> The problem I'm trying to address is that all the standard word
> breakers don't handle chemical compound names correctly. For example
> AZ-113 might be a valid term but even if i stick it in double quotes,
> the word breaker turns it into two seperate terms 'AZ' and '113'. I
> need a way to have it keep these as specific terms.
>
I'm not sure you've answered the question Anith asked. What is a
word-breaker as you are using it? Is it a function on the client, a
library you are using, etc.? What exactly do you need it to do and when
does it need to do this? For example, are you more interested in
breaking up the words in a text column for display in an application or
are you breaking up words at insert time in the database?
If you can do this on the application side, I'd recommend you look at a
Regular Expression library that Microsoft provides. There's a COM
version installed with Windows (in VBScript.dll) and there's a version
for .Net. Regular expressions can be a little daunting at first, but
provide a great way to search and validate all kinds of text.
David G.|||Sorry for not being clear and, in fact, I realize that this post is
misplaced (should be in ...fulltext). My question relates to the FullText
indexer that is part of SqlServer. It has a built-in word breaker that is
uses to do it's full text indexing. This is where I'm having the problems.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:#fn3YRJFFHA.2756@.TK2MSFTNGP15.phx.gbl...
> Clyde Seigle wrote:
> I'm not sure you've answered the question Anith asked. What is a
> word-breaker as you are using it? Is it a function on the client, a
> library you are using, etc.? What exactly do you need it to do and when
> does it need to do this? For example, are you more interested in
> breaking up the words in a text column for display in an application or
> are you breaking up words at insert time in the database?
> If you can do this on the application side, I'd recommend you look at a
> Regular Expression library that Microsoft provides. There's a COM
> version installed with Windows (in VBScript.dll) and there's a version
> for .Net. Regular expressions can be a little daunting at first, but
> provide a great way to search and validate all kinds of text.
>
> --
> David G.
>|||Regrettably with both OS's Win2k and Win2003 the wordbreakers will break
AZ-113 as two separate words. Your best bet is to convert all such phrases
or tokens in your searches and content to AZ113.
Hilary Cotter
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
"Clyde Seigle" <clydeSeigle@.nospam.nospam> wrote in message
news:u8ayJlRFFHA.2156@.TK2MSFTNGP10.phx.gbl...
> Sorry for not being clear and, in fact, I realize that this post is
> misplaced (should be in ...fulltext). My question relates to the FullText
> indexer that is part of SqlServer. It has a built-in word breaker that is
> uses to do it's full text indexing. This is where I'm having the problems.
>
> "David Gugick" <davidg-nospam@.imceda.com> wrote in message
> news:#fn3YRJFFHA.2756@.TK2MSFTNGP15.phx.gbl...
>|||Clyde,
Yes, it is best to discuss this subject (custom wordbreaker) in the fulltext
newsgroup... First a couple of very important questions on your environment
and the language of the text you are FT Indexing. Could you post the full
output of the following SQL code?
use <your_database_name_here>
go
SELECT @.@.language
SELECT @.@.version
sp_configure 'default full-text language'
EXEC sp_help_fulltext_catalogs
EXEC sp_help_fulltext_tables
EXEC sp_help_fulltext_columns
EXEC sp_help <your_FT-enable_table_name_here>
go
The above information is most important in helping troubleshoot the common
word breaking issues, I've seen in this newsgroup over many years. Note, for
SQL Server 2000, the word breakers you are using are specific to the OS
platform that your SQL Server is installed on. See
http://groups.google.com/groups?q=langwrbk+infosoft for a discussion on
Win2K's infosoft.dll vs. WinXP & Win2003's langwrkb.dll wordbreaker issues.
Regards,
John
--
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"Clyde Seigle" <clydeSeigle@.nospam.nospam> wrote in message
news:u8ayJlRFFHA.2156@.TK2MSFTNGP10.phx.gbl...
> Sorry for not being clear and, in fact, I realize that this post is
> misplaced (should be in ...fulltext). My question relates to the FullText
> indexer that is part of SqlServer. It has a built-in word breaker that is
> uses to do it's full text indexing. This is where I'm having the problems.
>
> "David Gugick" <davidg-nospam@.imceda.com> wrote in message
> news:#fn3YRJFFHA.2756@.TK2MSFTNGP15.phx.gbl...
>

Custom Weeks

In CODE section below, I'm grouping the Sum of Freight by the w/year. We
have a custom year begin and end year table that the DDL section will
create. Thus, I use the t_w table to calculate our custom ws with w
1 of any year starting with the date in the w_beginyeardate field and the
last w of the year ending on the w_endyeardate date value.
Is there a way I could return the same results created by my CODE section in
Northwind except use custom ws derived from my t_w table? Also, I also
need a fix to properly sort the w/year field from start to end w/year
field.
CODE:
SELECT CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
CAST(DATEPART(yyyy, OrderDate) AS char(4)) AS wnum, SUM(Freight) AS
sumFreight
FROM Orders
GROUP BY CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
CAST(DATEPART(yyyy, OrderDate) AS char(4))
ORDER BY CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
CAST(DATEPART(yyyy, OrderDate) AS char(4))
DDL ****************************************
*****
USE [Northwind]
GO
CREATE TABLE [t_w] (
[w_id] [int] IDENTITY(1,1) NOT NULL,
[w_beginyeardate] [datetime] NULL,
[w_endyeardate] [datetime] NULL,
[w_year] [int] NULL
) ON [PRIMARY]
GO
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19951226', '19961230', '1996')
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19961231', '19971229', '1997')
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19971230', '19981228', '1998')
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19981229', '19981227', '1999')
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19991228', '20001225', '2000')A sub-query, like
SELECT CAST(DATEDIFF(dd, (SELECT w_beginyeardate FROM t_w WHERE
w_year=DATEPART(yyyy, o.OrderDate)), o.OrderDate)/7 +1 AS varchar(2))
would get you the custom w number for a given date, but you can't use
sub-queries in a GROUP BY clause. The solution here is to create a function.
The function below formats OrderDate into yyyy-ww
CREATE FUNCTION udfCustomWFormat (@.date datetime)
RETURNS varchar(7)
AS
BEGIN
DECLARE @.output varchar(7)
SELECT @.output = CAST(DATEPART(yyyy, @.date) AS char(4)) + '-'
+ RIGHT('0' + CAST(DATEDIFF(dd, (SELECT w_beginyeardate FROM t_w
WHERE w_year=DATEPART(yyyy, @.date)), @.date) / 7 + 1 AS varchar(3)), 2)
RETURN @.output
END
You can then use the function to both group and order by
SELECT dbo.udfCustomWFormat(OrderDate), SUM(Freight) AS sumFreight
FROM Orders
GROUP BY dbo.udfCustomWFormat(OrderDate)
ORDER BY dbo.udfCustomWFormat(OrderDate)
"Scott" wrote:

> In CODE section below, I'm grouping the Sum of Freight by the w/year. W
e
> have a custom year begin and end year table that the DDL section will
> create. Thus, I use the t_w table to calculate our custom ws with we
ek
> 1 of any year starting with the date in the w_beginyeardate field and t
he
> last w of the year ending on the w_endyeardate date value.
> Is there a way I could return the same results created by my CODE section
in
> Northwind except use custom ws derived from my t_w table? Also, I al
so
> need a fix to properly sort the w/year field from start to end w/yea
r
> field.
>
> CODE:
> SELECT CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4)) AS wnum, SUM(Freight) AS
> sumFreight
> FROM Orders
> GROUP BY CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4))
> ORDER BY CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4))
>
> DDL ****************************************
*****
> USE [Northwind]
> GO
> CREATE TABLE [t_w] (
> [w_id] [int] IDENTITY(1,1) NOT NULL,
> [w_beginyeardate] [datetime] NULL,
> [w_endyeardate] [datetime] NULL,
> [w_year] [int] NULL
> ) ON [PRIMARY]
> GO
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19951226', '19961230', '1996')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19961231', '19971229', '1997')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19971230', '19981228', '1998')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19981229', '19981227', '1999')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19991228', '20001225', '2000')
>
>
>|||You almost have it. Please run my DDL below (I simulated my production db).
The only thing wrong is for example at the end of 2004, your w 53 2004
should be w 1 2005. If you run my example below, you'll see no w 1
2005. otherwise, the wly sums are correct. 2004 should only have 52
ws.
I think this is happening because you aren't taking the year ending dates
into consideration.
DDL *********************************
CREATE TABLE [dbo].[test_prod](
[prod_id] [int] IDENTITY(1,1) NOT NULL,
[prod_date] [datetime] NULL,
[log_count] [int] NULL
) ON [PRIMARY]
CREATE TABLE [t_w] (
[w_id] [int] IDENTITY(1,1) NOT NULL,
[w_beginyeardate] [datetime] NULL,
[w_endyeardate] [datetime] NULL,
[w_year] [int] NULL
) ON [PRIMARY]
GO
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19951226', '19961230', '1996')
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19961231', '19971229', '1997')
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19971230', '19981228', '1998')
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19981229', '19981227', '1999')
insert into t_w (w_beginyeardate, w_endyeardate, w_year) values
('19991228', '20001225', '2000')
CREATE FUNCTION udfWFormat (@.date datetime)
RETURNS varchar(7)
AS
BEGIN
DECLARE @.output varchar(7)
SELECT @.output = CAST(DATEPART(yyyy, @.date) AS char(4)) + '-'
+ RIGHT('0' + CAST(DATEDIFF(dd, (SELECT w_beginyeardate FROM t_w
WHERE w_year=DATEPART(yyyy, @.date)), @.date) / 7 + 1 AS varchar(3)), 2)
RETURN @.output
END
insert into test_prod (prod_date, log_count) values
('20041220', '6456')
insert into test_prod (prod_date, log_count) values
('20041221', '5830')
insert into test_prod (prod_date, log_count) values
('20041222', '3480')
insert into test_prod (prod_date, log_count) values
('20041227', '6542')
insert into test_prod (prod_date, log_count) values
('20041228', '6669')
insert into test_prod (prod_date, log_count) values
('20041229', '6524')
insert into test_prod (prod_date, log_count) values
('20041230', '6541')
insert into test_prod (prod_date, log_count) values
('20050104', '6370')
insert into test_prod (prod_date, log_count) values
('20050105', '6926')
insert into test_prod (prod_date, log_count) values
('20050106', '5002')
insert into test_prod (prod_date, log_count) values
('20050107', '6736')
insert into test_prod (prod_date, log_count) values
('20050108', '5822')
-- execute to see results
SELECT dbo.udfWFormat(prod_date), SUM(log_count) AS SumOflog_count
FROM dbo.test_prod
GROUP BY dbo.udfWFormat(prod_date)
ORDER BY dbo.udfWFormat(prod_date)
"Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
news:EBE692C6-1006-4E89-8ED9-985ED5F58F7B@.microsoft.com...
>A sub-query, like
> SELECT CAST(DATEDIFF(dd, (SELECT w_beginyeardate FROM t_w WHERE
> w_year=DATEPART(yyyy, o.OrderDate)), o.OrderDate)/7 +1 AS varchar(2))
> would get you the custom w number for a given date, but you can't use
> sub-queries in a GROUP BY clause. The solution here is to create a
> function.
> The function below formats OrderDate into yyyy-ww
> CREATE FUNCTION udfCustomWFormat (@.date datetime)
> RETURNS varchar(7)
> AS
> BEGIN
> DECLARE @.output varchar(7)
> SELECT @.output = CAST(DATEPART(yyyy, @.date) AS char(4)) + '-'
> + RIGHT('0' + CAST(DATEDIFF(dd, (SELECT w_beginyeardate FROM t_w
> WHERE w_year=DATEPART(yyyy, @.date)), @.date) / 7 + 1 AS varchar(3)), 2)
> RETURN @.output
> END
> You can then use the function to both group and order by
> SELECT dbo.udfCustomWFormat(OrderDate), SUM(Freight) AS sumFreight
> FROM Orders
> GROUP BY dbo.udfCustomWFormat(OrderDate)
> ORDER BY dbo.udfCustomWFormat(OrderDate)
> "Scott" wrote:
>|||Yep, I realized my mistake about 15 minutes after my post, but couldn't get
back to it until after a few hours. This should do it:
DROP FUNCTION udfCustomWFormat
GO
CREATE FUNCTION udfCustomWFormat (@.date datetime)
RETURNS varchar(7)
AS
BEGIN
DECLARE @.output varchar(7)
SELECT @.output = CAST(w_year AS char(4)) + '-'
+ RIGHT('0' + CAST(DATEDIFF(dd, w_beginyeardate, @.date) / 7 + 1 AS
varchar(3)), 2)
FROM t_w WHERE @.date BETWEEN w_beginyeardate AND w_endyeardate
RETURN @.output
END
SELECT dbo.udfCustomWFormat(OrderDate), SUM(Freight) AS sumFreight
FROM Orders
GROUP BY dbo.udfCustomWFormat(OrderDate)
ORDER BY dbo.udfCustomWFormat(OrderDate)
The function should now pick up the dates in late December correctly. For
example,
select dbo.udfCustomWFormat('19951228') results in 1996-01
Your example t_w table only goes to 2000, but you are running it against
a table that has dates in 2005; is the table cyclic?
"Scott" wrote:

> You almost have it. Please run my DDL below (I simulated my production db)
.
> The only thing wrong is for example at the end of 2004, your w 53 2004
> should be w 1 2005. If you run my example below, you'll see no w 1
> 2005. otherwise, the wly sums are correct. 2004 should only have 52
> ws.
> I think this is happening because you aren't taking the year ending dates
> into consideration.
> DDL *********************************
> CREATE TABLE [dbo].[test_prod](
> [prod_id] [int] IDENTITY(1,1) NOT NULL,
> [prod_date] [datetime] NULL,
> [log_count] [int] NULL
> ) ON [PRIMARY]
>
> CREATE TABLE [t_w] (
> [w_id] [int] IDENTITY(1,1) NOT NULL,
> [w_beginyeardate] [datetime] NULL,
> [w_endyeardate] [datetime] NULL,
> [w_year] [int] NULL
> ) ON [PRIMARY]
> GO
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19951226', '19961230', '1996')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19961231', '19971229', '1997')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19971230', '19981228', '1998')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19981229', '19981227', '1999')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year) value
s
> ('19991228', '20001225', '2000')
> CREATE FUNCTION udfWFormat (@.date datetime)
> RETURNS varchar(7)
> AS
> BEGIN
> DECLARE @.output varchar(7)
> SELECT @.output = CAST(DATEPART(yyyy, @.date) AS char(4)) + '-'
> + RIGHT('0' + CAST(DATEDIFF(dd, (SELECT w_beginyeardate FROM t_w
> WHERE w_year=DATEPART(yyyy, @.date)), @.date) / 7 + 1 AS varchar(3)), 2)
> RETURN @.output
> END
> insert into test_prod (prod_date, log_count) values
> ('20041220', '6456')
> insert into test_prod (prod_date, log_count) values
> ('20041221', '5830')
> insert into test_prod (prod_date, log_count) values
> ('20041222', '3480')
> insert into test_prod (prod_date, log_count) values
> ('20041227', '6542')
> insert into test_prod (prod_date, log_count) values
> ('20041228', '6669')
> insert into test_prod (prod_date, log_count) values
> ('20041229', '6524')
> insert into test_prod (prod_date, log_count) values
> ('20041230', '6541')
> insert into test_prod (prod_date, log_count) values
> ('20050104', '6370')
> insert into test_prod (prod_date, log_count) values
> ('20050105', '6926')
> insert into test_prod (prod_date, log_count) values
> ('20050106', '5002')
> insert into test_prod (prod_date, log_count) values
> ('20050107', '6736')
> insert into test_prod (prod_date, log_count) values
> ('20050108', '5822')
>
> -- execute to see results
> SELECT dbo.udfWFormat(prod_date), SUM(log_count) AS SumOflog_count
> FROM dbo.test_prod
> GROUP BY dbo.udfWFormat(prod_date)
> ORDER BY dbo.udfWFormat(prod_date)
>
> "Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
> news:EBE692C6-1006-4E89-8ED9-985ED5F58F7B@.microsoft.com...
>
>|||First, thanks big for solving this head-hurter. My t_w table does have
the last 5 years plus always 1 year in advance. I had the old years so it'd
work in northwind.
what did you mean by the table being "cyclic"?
"Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
news:602D1125-A792-40A5-B505-7B31B7524A94@.microsoft.com...
> Yep, I realized my mistake about 15 minutes after my post, but couldn't
> get
> back to it until after a few hours. This should do it:
> DROP FUNCTION udfCustomWFormat
> GO
> CREATE FUNCTION udfCustomWFormat (@.date datetime)
> RETURNS varchar(7)
> AS
> BEGIN
> DECLARE @.output varchar(7)
> SELECT @.output = CAST(w_year AS char(4)) + '-'
> + RIGHT('0' + CAST(DATEDIFF(dd, w_beginyeardate, @.date) / 7 + 1 AS
> varchar(3)), 2)
> FROM t_w WHERE @.date BETWEEN w_beginyeardate AND w_endyeardate
> RETURN @.output
> END
> SELECT dbo.udfCustomWFormat(OrderDate), SUM(Freight) AS sumFreight
> FROM Orders
> GROUP BY dbo.udfCustomWFormat(OrderDate)
> ORDER BY dbo.udfCustomWFormat(OrderDate)
> The function should now pick up the dates in late December correctly. For
> example,
> select dbo.udfCustomWFormat('19951228') results in 1996-01
> Your example t_w table only goes to 2000, but you are running it
> against
> a table that has dates in 2005; is the table cyclic?
> "Scott" wrote:
>|||Just curious - what kind of ws start on TUES?
William Stacey [MVP]
"Scott" <sbailey@.mileslumber.com> wrote in message
news:%23UoMFlnCGHA.3876@.tk2msftngp13.phx.gbl...
> In CODE section below, I'm grouping the Sum of Freight by the w/year.
> We have a custom year begin and end year table that the DDL section will
> create. Thus, I use the t_w table to calculate our custom ws with
> w 1 of any year starting with the date in the w_beginyeardate field
> and the last w of the year ending on the w_endyeardate date value.
> Is there a way I could return the same results created by my CODE section
> in Northwind except use custom ws derived from my t_w table? Also, I
> also need a fix to properly sort the w/year field from start to end
> w/year field.
>
> CODE:
> SELECT CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4)) AS wnum, SUM(Freight) AS
> sumFreight
> FROM Orders
> GROUP BY CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4))
> ORDER BY CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4))
>
> DDL ****************************************
*****
> USE [Northwind]
> GO
> CREATE TABLE [t_w] (
> [w_id] [int] IDENTITY(1,1) NOT NULL,
> [w_beginyeardate] [datetime] NULL,
> [w_endyeardate] [datetime] NULL,
> [w_year] [int] NULL
> ) ON [PRIMARY]
> GO
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19951226', '19961230', '1996')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19961231', '19971229', '1997')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19971230', '19981228', '1998')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19981229', '19981227', '1999')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19991228', '20001225', '2000')
>
>
>|||That the start and end year dates repeat in a pattern, every 5 years or so.
I
got from your second post that you were adjusting your data to fit Northwind
so a solution could be tested (and that's appreciated!)
I noticed when I ran the query against Northwind, one of the years (1996 I
think) shows up as having 53 ws in it. The difference between the year
start date and end date for 1996 in your sample is 370 days, so that does go
beying 52 ws. However, in a "normal" year, my math shows the last day of
the year being in w 53. It needs some twing. If I have time, I'll post
an adjusted version later.
"scott" wrote:

> First, thanks big for solving this head-hurter. My t_w table does have
> the last 5 years plus always 1 year in advance. I had the old years so it'
d
> work in northwind.
> what did you mean by the table being "cyclic"?
>
> "Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
> news:602D1125-A792-40A5-B505-7B31B7524A94@.microsoft.com...
>
>|||Should have been this way from the start.
CREATE FUNCTION udfCustomWFormat (@.date datetime)
RETURNS varchar(7)
AS
BEGIN
DECLARE @.output varchar(7)
SELECT @.output = CAST(w_year AS char(4)) + '-'
+ RIGHT('0' + CAST(CEILING(DATEDIFF(dd, w_beginyeardate, @.date) / 7.00)
AS
varchar(3)), 2)
FROM t_w WHERE @.date BETWEEN w_beginyeardate AND w_endyeardate
RETURN @.output
END
Now the last (364th) day of the year shows up as being in w 52. For years
that go beyond 364 days, you will still end up with a w 53 out of this
function.
"scott" wrote:

> First, thanks big for solving this head-hurter. My t_w table does have
> the last 5 years plus always 1 year in advance. I had the old years so it'
d
> work in northwind.
> what did you mean by the table being "cyclic"?
>
> "Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
> news:602D1125-A792-40A5-B505-7B31B7524A94@.microsoft.com...
>
>|||Are these calendar ws starting with Sunday?
William Stacey [MVP]
"Scott" <sbailey@.mileslumber.com> wrote in message
news:%23UoMFlnCGHA.3876@.tk2msftngp13.phx.gbl...
> In CODE section below, I'm grouping the Sum of Freight by the w/year.
> We have a custom year begin and end year table that the DDL section will
> create. Thus, I use the t_w table to calculate our custom ws with
> w 1 of any year starting with the date in the w_beginyeardate field
> and the last w of the year ending on the w_endyeardate date value.
> Is there a way I could return the same results created by my CODE section
> in Northwind except use custom ws derived from my t_w table? Also, I
> also need a fix to properly sort the w/year field from start to end
> w/year field.
>
> CODE:
> SELECT CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4)) AS wnum, SUM(Freight) AS
> sumFreight
> FROM Orders
> GROUP BY CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4))
> ORDER BY CAST(DATEPART(w, OrderDate) AS varchar(2)) + '-' +
> CAST(DATEPART(yyyy, OrderDate) AS char(4))
>
> DDL ****************************************
*****
> USE [Northwind]
> GO
> CREATE TABLE [t_w] (
> [w_id] [int] IDENTITY(1,1) NOT NULL,
> [w_beginyeardate] [datetime] NULL,
> [w_endyeardate] [datetime] NULL,
> [w_year] [int] NULL
> ) ON [PRIMARY]
> GO
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19951226', '19961230', '1996')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19961231', '19971229', '1997')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19971230', '19981228', '1998')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19981229', '19981227', '1999')
> insert into t_w (w_beginyeardate, w_endyeardate, w_year)
> values
> ('19991228', '20001225', '2000')
>
>
>|||what's the difference in this 2nd correct function and the 1st or previous
correct function?
"Mark Williams" <MarkWilliams@.discussions.microsoft.com> wrote in message
news:D4583358-03D7-4EAD-9B4C-F1E69B884861@.microsoft.com...
> Should have been this way from the start.
> CREATE FUNCTION udfCustomWFormat (@.date datetime)
> RETURNS varchar(7)
> AS
> BEGIN
> DECLARE @.output varchar(7)
> SELECT @.output = CAST(w_year AS char(4)) + '-'
> + RIGHT('0' + CAST(CEILING(DATEDIFF(dd, w_beginyeardate, @.date) / 7.00)
> AS
> varchar(3)), 2)
> FROM t_w WHERE @.date BETWEEN w_beginyeardate AND w_endyeardate
> RETURN @.output
> END
> Now the last (364th) day of the year shows up as being in w 52. For
> years
> that go beyond 364 days, you will still end up with a w 53 out of this
> function.
> "scott" wrote:
>