Showing posts with label requires. Show all posts
Showing posts with label requires. Show all posts

Wednesday, March 7, 2012

Function default parameter

I am creating a udh function that requires to know the current date.
Since GetDate() can't be used inside a UDF I thought
I would use a date parameter with a default value of GetDate()
i.e.:
Create function dbo.ufn_GetWeekAreaAvailability(
@.WeekId int,
@.AreaId char(1),
@.Now DateTime = GetDate()
) Returns
or
Create function dbo.ufn_GetWeekAreaAvailability(
@.WeekId int,
@.AreaId char(1),
@.Now DateTime = (Select GetDate())
) Returns
These do not even compile
However
Create function dbo.ufn_GetWeekAreaAvailability(
@.WeekId int,
@.AreaId char(1),
@.Now DateTime = GetDate
) Returns
Does but when I call it it
Select * from dbo.ufn_GetWeekAreaAvailability(1,'1',Default)
It tells me that string cannot be converted to a date
Server: Msg 241, Level 16, State 1, Procedure ufn_Test, Line 0
Syntax error converting datetime from character string.
Any Idea...
Thanks
Fred
Hi Fred,
You can't use a function as the default value for a parameter, only
literals. You can use a view that just returns the value of GETDATE() for
example:
CREATE VIEW vw_getdate
AS
SELECT GETDATE() AS getdate
but the view will be accessed each time the function is executed, which
means that you can end up with having different values for each execution.
The safest is not to use a default value and just pass in the value for
GETDATE().
Jacco Schalkwijk
SQL Server MVP
"Fred" <Fred@.discussions.microsoft.com> wrote in message
news:7315A12D-37ED-4F5F-8855-2DFE1F2153E6@.microsoft.com...
>I am creating a udh function that requires to know the current date.
> Since GetDate() can't be used inside a UDF I thought
> I would use a date parameter with a default value of GetDate()
> i.e.:
> Create function dbo.ufn_GetWeekAreaAvailability(
> @.WeekId int,
> @.AreaId char(1),
> @.Now DateTime = GetDate()
> ) Returns
> or
> Create function dbo.ufn_GetWeekAreaAvailability(
> @.WeekId int,
> @.AreaId char(1),
> @.Now DateTime = (Select GetDate())
> ) Returns
> These do not even compile
> However
> Create function dbo.ufn_GetWeekAreaAvailability(
> @.WeekId int,
> @.AreaId char(1),
> @.Now DateTime = GetDate
> ) Returns
> Does but when I call it it
> Select * from dbo.ufn_GetWeekAreaAvailability(1,'1',Default)
> It tells me that string cannot be converted to a date
> Server: Msg 241, Level 16, State 1, Procedure ufn_Test, Line 0
> Syntax error converting datetime from character string.
> Any Idea...
>
> Thanks
>
>
> --
> Fred

Function default parameter

I am creating a udh function that requires to know the current date.
Since GetDate() can't be used inside a UDF I thought
I would use a date parameter with a default value of GetDate()
i.e.:
Create function dbo.ufn_GetWeekAreaAvailability(
@.WeekId int,
@.AreaId char(1),
@.Now DateTime = GetDate()
) Returns
or
Create function dbo.ufn_GetWeekAreaAvailability(
@.WeekId int,
@.AreaId char(1),
@.Now DateTime = (Select GetDate())
) Returns
These do not even compile
However
Create function dbo.ufn_GetWeekAreaAvailability(
@.WeekId int,
@.AreaId char(1),
@.Now DateTime = GetDate
) Returns
Does but when I call it it
Select * from dbo.ufn_GetWeekAreaAvailability(1,'1',Default)
It tells me that string cannot be converted to a date
Server: Msg 241, Level 16, State 1, Procedure ufn_Test, Line 0
Syntax error converting datetime from character string.
Any Idea...
Thanks
--
FredHi Fred,
You can't use a function as the default value for a parameter, only
literals. You can use a view that just returns the value of GETDATE() for
example:
CREATE VIEW vw_getdate
AS
SELECT GETDATE() AS getdate
but the view will be accessed each time the function is executed, which
means that you can end up with having different values for each execution.
The safest is not to use a default value and just pass in the value for
GETDATE().
--
Jacco Schalkwijk
SQL Server MVP
"Fred" <Fred@.discussions.microsoft.com> wrote in message
news:7315A12D-37ED-4F5F-8855-2DFE1F2153E6@.microsoft.com...
>I am creating a udh function that requires to know the current date.
> Since GetDate() can't be used inside a UDF I thought
> I would use a date parameter with a default value of GetDate()
> i.e.:
> Create function dbo.ufn_GetWeekAreaAvailability(
> @.WeekId int,
> @.AreaId char(1),
> @.Now DateTime = GetDate()
> ) Returns
> or
> Create function dbo.ufn_GetWeekAreaAvailability(
> @.WeekId int,
> @.AreaId char(1),
> @.Now DateTime = (Select GetDate())
> ) Returns
> These do not even compile
> However
> Create function dbo.ufn_GetWeekAreaAvailability(
> @.WeekId int,
> @.AreaId char(1),
> @.Now DateTime = GetDate
> ) Returns
> Does but when I call it it
> Select * from dbo.ufn_GetWeekAreaAvailability(1,'1',Default)
> It tells me that string cannot be converted to a date
> Server: Msg 241, Level 16, State 1, Procedure ufn_Test, Line 0
> Syntax error converting datetime from character string.
> Any Idea...
>
> Thanks
>
>
> --
> Fred

Friday, February 24, 2012

Full-text search across multiple tables

Hello,
We are developing an application against an MS SQL Server 2000 database
which requires that we implement full-text searching across columns in
multiple tables. The research that we have conducted seems to indicate
that this is not directly possible within SQL Server 2000. And we can
find no way to implement this as the catalogs that are generated are
table specific.
As a work-around, we are planning to create a secondary table used
strictly for searching which is going to denormalize and combine the
searchable data into one catalog. We just want to confirm that this is
the recommended approach or if there is an alternate solution anyone
has used. Please note that upgrading to SQL Server 2005 is not an
option.
Thanks.
John Fleming
jfleming@.misicompany.com
You might be able to use the ability to full text index an indexed view in
SQL 2005. Other than that you are correct, all you can do is try to create a
child table containing both tables and do some resolution back to the base
tables based on the key.
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
"John" <jflemingnj@.gmail.com> wrote in message
news:1137167503.574033.165460@.g47g2000cwa.googlegr oups.com...
> Hello,
> We are developing an application against an MS SQL Server 2000 database
> which requires that we implement full-text searching across columns in
> multiple tables. The research that we have conducted seems to indicate
> that this is not directly possible within SQL Server 2000. And we can
> find no way to implement this as the catalogs that are generated are
> table specific.
> As a work-around, we are planning to create a secondary table used
> strictly for searching which is going to denormalize and combine the
> searchable data into one catalog. We just want to confirm that this is
> the recommended approach or if there is an alternate solution anyone
> has used. Please note that upgrading to SQL Server 2005 is not an
> option.
> Thanks.
> John Fleming
> jfleming@.misicompany.com
>

Sunday, February 19, 2012

Full-text search across multiple tables

Hello,
We are developing an application against an MS SQL Server 2000 database
which requires that we implement full-text searching across columns in
multiple tables. The research that we have conducted seems to indicate
that this is not directly possible within SQL Server 2000. And we can
find no way to implement this as the catalogs that are generated are
table specific.
As a work-around, we are planning to create a secondary table used
strictly for searching which is going to denormalize and combine the
searchable data into one catalog. We just want to confirm that this is
the recommended approach or if there is an alternate solution anyone
has used. Please note that upgrading to SQL Server 2005 is not an
option.
Thanks.
John Fleming
jfleming@.misicompany.comYou might be able to use the ability to full text index an indexed view in
SQL 2005. Other than that you are correct, all you can do is try to create a
child table containing both tables and do some resolution back to the base
tables based on the key.
--
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
"John" <jflemingnj@.gmail.com> wrote in message
news:1137167503.574033.165460@.g47g2000cwa.googlegroups.com...
> Hello,
> We are developing an application against an MS SQL Server 2000 database
> which requires that we implement full-text searching across columns in
> multiple tables. The research that we have conducted seems to indicate
> that this is not directly possible within SQL Server 2000. And we can
> find no way to implement this as the catalogs that are generated are
> table specific.
> As a work-around, we are planning to create a secondary table used
> strictly for searching which is going to denormalize and combine the
> searchable data into one catalog. We just want to confirm that this is
> the recommended approach or if there is an alternate solution anyone
> has used. Please note that upgrading to SQL Server 2005 is not an
> option.
> Thanks.
> John Fleming
> jfleming@.misicompany.com
>

Full-text search across multiple tables

Hello,
We are developing an application against an MS SQL Server 2000 database
which requires that we implement full-text searching across columns in
multiple tables. The research that we have conducted seems to indicate
that this is not directly possible within SQL Server 2000. And we can
find no way to implement this as the catalogs that are generated are
table specific.
As a work-around, we are planning to create a secondary table used
strictly for searching which is going to denormalize and combine the
searchable data into one catalog. We just want to confirm that this is
the recommended approach or if there is an alternate solution anyone
has used. Please note that upgrading to SQL Server 2005 is not an
option.
Thanks.
John Fleming
jfleming@.misicompany.comYou might be able to use the ability to full text index an indexed view in
SQL 2005. Other than that you are correct, all you can do is try to create a
child table containing both tables and do some resolution back to the base
tables based on the key.
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
"John" <jflemingnj@.gmail.com> wrote in message
news:1137167503.574033.165460@.g47g2000cwa.googlegroups.com...
> Hello,
> We are developing an application against an MS SQL Server 2000 database
> which requires that we implement full-text searching across columns in
> multiple tables. The research that we have conducted seems to indicate
> that this is not directly possible within SQL Server 2000. And we can
> find no way to implement this as the catalogs that are generated are
> table specific.
> As a work-around, we are planning to create a secondary table used
> strictly for searching which is going to denormalize and combine the
> searchable data into one catalog. We just want to confirm that this is
> the recommended approach or if there is an alternate solution anyone
> has used. Please note that upgrading to SQL Server 2005 is not an
> option.
> Thanks.
> John Fleming
> jfleming@.misicompany.com
>

Full-text search across multiple tables

Hello,
We are developing an application against an MS SQL Server 2000 database
which requires that we implement full-text searching across columns in
multiple tables. The research that we have conducted seems to indicate
that this is not directly possible within SQL Server 2000. And we can
find no way to implement this as the catalogs that are generated are
table specific.
As a work-around, we are planning to create a secondary table used
strictly for searching which is going to denormalize and combine the
searchable data into one catalog. We just want to confirm that this is
the recommended approach or if there is an alternate solution anyone
has used. Please note that upgrading to SQL Server 2005 is not an
option.
Thanks.
John Fleming
jfleming@.misicompany.com
You might be able to use the ability to full text index an indexed view in
SQL 2005. Other than that you are correct, all you can do is try to create a
child table containing both tables and do some resolution back to the base
tables based on the key.
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
"John" <jflemingnj@.gmail.com> wrote in message
news:1137167503.574033.165460@.g47g2000cwa.googlegr oups.com...
> Hello,
> We are developing an application against an MS SQL Server 2000 database
> which requires that we implement full-text searching across columns in
> multiple tables. The research that we have conducted seems to indicate
> that this is not directly possible within SQL Server 2000. And we can
> find no way to implement this as the catalogs that are generated are
> table specific.
> As a work-around, we are planning to create a secondary table used
> strictly for searching which is going to denormalize and combine the
> searchable data into one catalog. We just want to confirm that this is
> the recommended approach or if there is an alternate solution anyone
> has used. Please note that upgrading to SQL Server 2005 is not an
> option.
> Thanks.
> John Fleming
> jfleming@.misicompany.com
>

Full-text search across multiple tables

Hello,

We are developing an application against an MS SQL Server 2000 database
which requires that we implement full-text searching across columns in
multiple tables. The research that we have conducted seems to indicate
that this is not directly possible within SQL Server 2000. And we can
find no way to implement this as the catalogs that are generated are
table specific.

As a work-around, we are planning to create a secondary table used
strictly for searching which is going to denormalize and combine the
searchable data into one catalog. We just want to confirm that this is
the recommended approach or if there is an alternate solution anyone
has used. Please note that upgrading to SQL Server 2005 is not an
option.

Thanks.

John Fleming
jfleming@.misicompany.comYou might be able to use the ability to full text index an indexed view in
SQL 2005. Other than that you are correct, all you can do is try to create a
child table containing both tables and do some resolution back to the base
tables based on the key.

--
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

"John" <jflemingnj@.gmail.com> wrote in message
news:1137167503.574033.165460@.g47g2000cwa.googlegr oups.com...
> Hello,
> We are developing an application against an MS SQL Server 2000 database
> which requires that we implement full-text searching across columns in
> multiple tables. The research that we have conducted seems to indicate
> that this is not directly possible within SQL Server 2000. And we can
> find no way to implement this as the catalogs that are generated are
> table specific.
> As a work-around, we are planning to create a secondary table used
> strictly for searching which is going to denormalize and combine the
> searchable data into one catalog. We just want to confirm that this is
> the recommended approach or if there is an alternate solution anyone
> has used. Please note that upgrading to SQL Server 2005 is not an
> option.
> Thanks.
> John Fleming
> jfleming@.misicompany.com