Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Function To Call Function By Name Given As Parameter


I want to write function to call another function which name is
parameter to first function. Other parameters should be passed to
called function.
If I call it function('f1',10) it should call f1(10). If I call it
function('f2',5) it should call f2(5).

So far i tried something like

CREATE FUNCTION [dbo].[func] (@f varchar(50),@m money)
RETURNS varchar(50) AS
BEGIN
return(select 'dbo.'+@f+'('+convert(varchar(50),@m)+')')
END

When I call it select dbo.formuła('f_test',1000) it returns
'select f_test(1000)', but not value of f_test(1000).

What's wrong?

Mariusz




View Complete Forum Thread with Replies

Related Forum Messages:
Function Call With Table As Parameter
Hi all, I want to use a function with a tabel object as parameter. Doessomeone know a method to do this. I have read that a table as parameteris invalid.

View Replies !
Using A Scalar Valued Function As A Parameter Of A Table Valued Function?
Ok, I'm pretty knowledgable about T-SQL, but I've hit something that seems should work, but just doesn't...
I'm writing a stored procedure that needs to use the primary key fields of a table that is being passed to me so that I can generate what will most likely be a dynamically generated SQL statement and then execute it.
So the first thing I do, is I need to grab the primary key fields of the table.  I'd rather not go down to the base system tables since we may (hopefully) upgrade this one SQL 2000 machine to 2005 fairly soon, so I poke around, and find sp_pkeys in the master table.  Great.  I pass in the table name, and sure enough, it comes back with a record set, 1 row per column.  That's exactly what I need.
Umm... This is the part where I'm at a loss.  The stored procedure outputs the resultset as a resultset (Not as an output param).  Now I want to use that list in my stored procedure, thinking that if the base tables change, Microsoft will change the stored procedure accordingly, so even after a version upgrade my stuff SHOULD still work.  But... How do I use the resultset from the stored procedure?  You can't reference it like a table-valued function, nor can you 'capture' the resultset for use using the  syntax like:
DECLARE @table table@table=EXEC sp_pkeys MyTable
That of course just returns you the RETURN_VALUE instead of the resultset it output.  Ugh.  Ok, so I finally decide to just bite the bullet, and I grab the code from sp_pkeys and make my own little function called fn_pkeys.  Since I might also want to be able to 'force' the primary keys (Maybe the table doesn't really have one, but logically it does), I decide it'll pass back a comma-delimited varchar of columns that make up the primary key.  Ok, I test it and it works great.
Now, I'm happily going along and building my routine, and realize, hey, I don't really want that in a comma-delimited varchar, I want to use it in one of my queries, and I have this nice little table-valued function I call split, that takes a comma-delimited varchar, and returns a table... So I preceed to try it out...
SELECT *FROM Split(fn_pkeys('MyTable'),DEFAULT)
Syntax Error.  Ugh.  Eventually, I even try:
SELECT *FROM Split(substring('abc,def',2,6),DEFAULT)
Syntax Error.
Hmm...What am I doing wrong here, or can't you use a scalar-valued function as a parameter into a table-valued function?
SELECT *FROM Split('bc,def',DEFAULT) works just fine.
So my questions are:
Is there any way to programmatically capture a resultset that is being output from a stored procedure for use in the stored procedure that called it?
Is there any way to pass a scalar-valued function as a parameter into a table-valued function?
Oh, this works as well as a work around, but I'm more interested in if there is a way without having to workaround:
DECLARE @tmp varchar(8000)
SET @tmp=(SELECT dbo.fn_pkeys('MyTable'))
SELECT *
FROM Split(@tmp,DEFAULT)

View Replies !
Call A Function
Does anybody knows how to call a function from one VB source file to another VB source file?? 
 
I have create a MDI parent form, now i want to call the function of the child form from the parent form.  Does anyone know this??

View Replies !
Function Call
can i make a function call from stored procedure

View Replies !
Need Help Understanding A Call To A Sql Function
Can someone help me to understand a stored procedure I am learning about? At line 12 below, the code is calling a function named"ttg_sfGroupsByPartyId" I ran the function manually and it returns several rows/records from the query. So I am wondering? does a call to the function return a temporary table? And if so, is the temporary table named PartyId? If so, the logic seems strange to me because earlier they are using the name PartyId as a variable name that is passed in.
 
1  ALTER              PROCEDURE [dbo].[GetPortalSettings]2  (3     @PartyId    uniqueidentifier,45  AS6  SET NOCOUNT ON7  CREATE TABLE #Groups8  (PartyId uniqueidentifier)910 /* Cache list of groups user belongs in */11 INSERT INTO #Groups (PartyId)12 SELECT PartyId FROM ttg_sfGroupsByPartyId(@PartyId)

View Replies !
Call Custom SQL Function In ASP.NET
I made an SQL function in MSSQL2000. This is a function that get's a calculated heat emission. When I run the Query in MSSQL2000 the function works. It calculates every emission for every row. When I call this SQL function in VS2005, it says it does not recognize the function. Does anyone know what this may cause? thank you. For the people who are bored, I added the SQL statement. The error is at the function

SELECT TOP 15 tbProducts.prod_code, tbProductProperties.prop_height, tbProductProperties.prop_length, tbProductProperties.prop_type, tbProductProperties.prop_default_emission, tbProductProperties.prop_weight, tbProductProperties.prop_water_volume, tbProductProperties.prop_n_value, GetHeatEmission(50,70,20,[prop_default_emission],[prop_n_value]) AS customEmission FROM tbProductClassification INNER JOIN tbProducts ON tbProductClassification.clprod_fk_prod_id = tbProducts.prod_id INNER JOIN tbProductProperties ON tbProducts.prod_id = tbProductProperties.prop_fk_prod_id WHERE (tbProductClassification.clprod_fk_class_id = 3327) AND (prop_height >= '030') AND (prop_height = '060') AND (prop_length

View Replies !
SQL Server Call C++ Function?
Hi,

Does anyone know if/how SQL server can call a function in a C++ library?

Cheers,

Xiaobing

View Replies !
Overload Function Call
Hi,

I want to write one function like that

dbo.function( number , 1 , 2 ) ,

but I would like to overload, and send char or number

dbo.function( number, 'abx' , ' xpto' ).

I would like to keep the same name, Can I do this? or Do I need to write to differents functions

 

thanks,

 

View Replies !
Call Function For Inner Join
 

I have a procedure which has query
like Query 1.
 
Query 1
 
Select Clinetid
from clinet
inner join  {


select centerid from GetChildCenter(@Centerid)
union
select centerid from getParentCenter(@Centerid)
} as Center c

 on c.Centerid = client.Centerid
 
 
Query 2
 
declare @Center table ( centerid int)
insert into @Center

select centerid from getchildCenter(@Centerid) union all select centerid from getparentcenter(@Centerid)
 
Select Clinetid
from clinet
inner join  @Center c on c.Centerid = client.Centerid



 
 
I just want to know which one is better performance wise..
because there is millions of rows for table center which is used by function getChildCenter() and GetparentCenter()
 
 

View Replies !
Trying To Call A Function On A Weekly Timer
I'm not sure this is the place for this question, but not sure where else to go.  I've written asp.net  code to read from a sql server 2005 db and send out customized emails based on user info.Currently the process gets rolling by clicking a button in a web page.The client doesn't want to click a button, they want to run the email sender on a timer.How can I set up my function to run on a timer either in asp.net or more likely called from sql server? 

View Replies !
Call Function From Stored Procedure
Hi All,
I'll admit that I'm not the greatest at stored procedure/functions but I want to learn as much as possible.  So I have two questions:
1) I had VS2005 autogenerate a sqldatasource that created Select/Insert/Update stored procedures.  When Updating a record and calling the stored procedure, I want to query another table (we'll call it tblBatchNo) that has only one record, Batchno.  I want to put that current batchno into the Update statement and update the record with the current batchno.  Can someone point me in the right direction?  Remember that I'm still a beginner on this subject.
2) Can someone provide any links to online tutorials on t-sql?
Thanks in advance.
Curtis

View Replies !
Call Store Procedure From Function
Hi,is there any method to call a store procedure into a function?ThanksFabio

View Replies !
Can Delete 'dbo.' Schema When Call Function In SP
Hi:

We found the problem that when the SP call function,there must have 'dbo.' before the function.Does it necessarily?Can delete 'dbo.' schema when call function in SP?

View Replies !
How To Call A Function Using OLE DB Command Tranformation
Hello

 

i am trying to call a function from the SQL server using Ole DB command Transformation using [dbo].[ConvertToDate] ?,?,?,?

there are no errors while executing this transformation

but this function returns a value

Now i need to capture this value how do i do that using the OLE DB command Transformation or any other transformation

 

Thanks

View Replies !
How To Bind Return Value From Function Call
I have a function that I need to call from an execute sql task. I want to bind the return value from the function to an ssis variable.
 
Can someone please show me an example of what the function syntax needs to look like in order for this to work? I know that with sp's, you need to explicitly state the column names.
 
I have tried many things without success.
 
Thanks

View Replies !
Call Function In Data Flow
 

how can you call a sql function in data flow? I have a function that calculate age base on the data in two columns . I would like to call this function in data flow to calculate the age..
 
 

View Replies !
Trying To Call The Function A Web Service From Transact-SQL
I currently have the fllowing Stored Procedure.  When I pass the the Url of the web service in the parameters, I'm having a sp_OAMethor read response failed error. 

I don't know how to pass the parameter as well as the name of the function in the Web Service I'm calling.  Maybe I'm all wrong here with this code too?

Thanks for any help.

 

ALTER PROCEDURE [dbo].[pTAPServiceWeb]

@sUrl varchar(200),

@response varchar(8000) out

AS

DECLARE @obj int

DECLARE @hr int

DECLARE @status int

DECLARE @msg varchar(255)

EXEC @hr = sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT

IF @hr < 0

BEGIN

RAISERROR('sp_OACreate MSXML2.ServerXMLHttp failed', 16, 1)

RETURN

END

EXEC @hr = sp_OAMethod @obj, 'Open', NULL, 'GET', @sUrl, false

IF @hr < 0

BEGIN

SET @msg = 'sp_OAMethod Open failed'

GOTO err

END

EXEC @hr = sp_OAMethod @obj, 'send'

IF @hr < 0

BEGIN

SET @msg = 'sp_OAMethod Send failed'

GOTO err

END

EXEC @hr = sp_OAGetProperty @obj, 'status', @status OUT

IF @hr < 0

BEGIN

SET @msg = 'sp_OAMethod read status failed'

GOTO err

END

-- IF @status <> 200

-- BEGIN

-- SET @msg = 'sp_OAMethod http status ' + str(@status)

-- GOTO err

-- END

EXEC @hr = sp_OAGetProperty @obj, 'responseText', @response OUT

IF @hr < 0

BEGIN

SET @msg = 'sp_OAMethod read response failed'

GOTO err

END

EXEC @hr = sp_OADestroy @obj

RETURN

err:

EXEC @hr = sp_OADestroy @obj

RAISERROR(@msg, 16, 1)

RETURN

GO

View Replies !
Function Call In Insert Statment
Hi

 

i m trying to call a function in insert statment

Insert Into (value, value1)

Value(@value, dbo.function(@value1)

dbo.function returns a value,

when i test the function in querry builder all goes fine.

In my program i become a error

"Parameterized Query '' ' expects parameter @value1 , which was not supplied."

I m using visual studio , tableadapter.update function to insert datarecords in db

 

thx for help

 

View Replies !
Function Call In Dataset Query
Hello Guys,

 

I have a question that seems easy but I can not figure out...

 

Premise:

Have Custom code that fixes Divide by Zero Errors in SSRS. I have added the code to the Custom Code area in Report Properties correctly.

 

I have a Dataset that has a calculation for a column within a select statement

 

Query Pseudocode:

 

select ...[FRC%]=convert(decimal(13,2),sum(cost))/convert(decimal(13,2),sum(income))...
,year
from

(subquery"blah" )

Union

(Subquery"blah")

 

Custom Code:

 

Public Function SafeDiv(ByVal numerator as Double, ByVal denominator as Double) as Double
    if denominator = 0 then
        return 0
    else
        return numerator/denominator
    end if
End Function

 

How To use:

 

If you have a field that does division and you need to eliminate the divide by zero error that occurs with SSRS then type =code.SafeDiv(first,second) in the field.

 

Problem:

How do I add this code reference in the following dataset select statement

 

select ...[FRC%]=convert(decimal(13,2),sum(cost))/convert(decimal(13,2),sum(income))...
,year
from

(subquery"blah" )

Union

(Subquery"blah") table1

 







 

I tried to do this:

from this:

[FRC%]=convert(decimal(13,2),sum(cost))/convert(decimal(13,2),sum(income)) ...

to this

[FRC%]=code.Safediv(convert(decimal(13,2),sum(cost)),convert(decimal(13,2),sum(income))) ...







 

But it did not work...gave me this error:

 

TITLE: Microsoft Report Designer
------------------------------

An error occurred while executing the query.
Cannot find either column "code" or the user-defined function or aggregate "code.safediv", or the name is ambiguous.

------------------------------
ADDITIONAL INFORMATION:

Cannot find either column "code" or the user-defined function or aggregate "code.safediv", or the name is ambiguous. (Microsoft SQL Server, Error: 4121)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=4121&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------








Help!

 

P.S.

this is a Matrix report and this select statement is within one of the datasets that fill a matrix.

 

 

View Replies !
How To Call A Userdefined Function Within A Stored
Hello All,
How do i call a user defined function from within a stored procedure,
I have created a simple function which takes firstname and lastname as parameters and returns the concatenated name string.
That part works.


declare @fullname varchar(400)
@fullName=getFullName(@firstname,@lastname)


As always thanks for all your input

View Replies !
Problem With Nested Function Call (UDFs)
Hello Folks,I encountered a problem with SQL server 2000 and UDFs.I have a scalar UDF and a table UDF where I would like the scalar UDFto provide the argument for the table UDF like in:SELECT*FROMtransaction_tWHEREtrxn_gu_id in (select get_trxns_for_quarter(get_current_quarter( GetDate() ) ))'get_current_quarter' returns an integer which is a GUID in a tablecontaining business quarter definitions, like start date, end date.'get_current_quarter' is a scalar UDF.'get_trxns_for_quarter' will then get all transctions that fall intothat quarter and return their GUID's in a table.'get_trxns_for_quarter' is a table UDF.This doesn't seem to work at all. Regardless whether I provide thenamespace (schema) calling the scalar UDF or not. Error message isjust different.Both functions operate correctly invoked un-nested.The whole expression does work fine if I turn 'get_trxns_for_quarter'into a scalar UDF as well, e.g. by returning just one trxn_gu_id withe.g. MAX() in a scalar datatype. But of course that's no good to me.It also works fine if I select the result of 'get_current_quarter'into a variable and pass that variable into 'get_trxns_for_quarter'.But that's no good to me either since then I cannot use the wholething embedded into other SELECT clauses.Both UDF's are non-deterministic but I couldnt see how that would havean impact anyway.Never mind the syntax on that example or anyhting, I tried all theobvious and not so obvious stuff and it really seems to come down tothe fact that one UDF is scalar and the other one is not. However, Idid not come across any type of information saying that this cannot bedone.Have you any ideas?Any help would be greatly appreciated.Carsten

View Replies !
How To Call A Function From A Column Formula In My MS SQL Table
Good day!

What is the syntax on calling a function from a column formula in an MS SQL table.

I created a table, one column's value will be coming from a function. And at the same time, I will pass parameters to the function. How do I do this? Is this correct?

SELECT dbo.FunctionName([Parameter1, Parameter2])

But i can't save the table, "Error validating the formula".

Pls. help
Thanks a lot.

View Replies !
Why Does A Function Call Require Two Part Naming?
Hi,
I just found out that when I create a user defined scalar function, I must call it using dbo.[myFunctionName]. Why won't it work w/out dbo? Why are stored procedures able to use omit dbo?
 
Also, what is dbo specifying? I'm very unfamiliar with sql server security. Is this the user, schema, role? What's a schema? lol. Thanks.

View Replies !
How To Use The OLEDB Command To Call A Oracle Function?
HI,

I want to use the OLEDB command to call a oracle function, but i havnt found any materials about how to do that, my oracle function is as below:

CREATE OR REPLACE function GET_ZONEID_FROM_SYFZ(ycz varchar2,xc varchar2,strat_id varchar2)
return varchar2 IS
 zone_id_result varchar2(10) ;
begin
 PKG_DM_DQ.GET_ZONEID_FROM_SYFZ(ycz,xc,strat_id,zone_id_result);
 return zone_id_result;
end;

In OLEDB command transformation component, i fill the sql command with "select GET_ZONEID_FROM_SYFZ(?,?,?) from dual", but i dont have it worked.

The error message is :provider can not derive parameter information and setparameterinfo has not been called.

Who have any idea about how to make it work?

Thanks ~~

 

View Replies !
Need Call A DB Function In The Middle Of The Dataflow Process
 
All,
 
 I have to use a field that is calculated in a data flow process and call a database function (return a value) to do anther calculation; then return a value back to the data flow.  I tried OLD DB Command but I cannot configure to return a value back to the same data flow.
If there any transformations that can call a DB function and get a value from the function in the middle of the data flow process?  Need more detailed instruction.
 
The data flow is Like:
 
SourceDB à New_filed 1 = field1 + filed2 à New_filed 2= DB_function (New_filed 1) à Destination DB
 
 
Thanks in Advance
Jessie
 

View Replies !
Is Possible To Call A VB.NET Function Within Derived Transformation Editor
Hi,
 
In a nut shell I want to be able to instruction some Data Analysts on how to modify SSIS packages using the simpliest solutions possible. This is because there are many different data sources and some of these data sources have a huge number of fields, and yes you guessed it these data sources are subject to change on a regular basis.
 
A very common task they will need to do is to modify an SSIS package to do a to transform of a source date string format of "YYYYMMDD" into a date data type field within a table.
 

Similar threads have advised the use of the Data Flow Transformations->Derived Column for this sort of thing.
 
So within the Expression Text box I have inserted the following SSIS compatible SQL to convert the above string into a british format date data type; -
 



Code Snippet
(SUBSTRING(DOB_SRC,8,2) + "/" + SUBSTRING(DOB_SRC,5,2) + "/" + SUBSTRING(DOB_SRC,1,4))
 
 


 
But really what I want to be able to do is to instruct the Data Analysts to do is something like; -
 
ConvertTextToDate(DOB_SRC)
 
Where I previously defined that behaviour of ConvertTextToDate as a public VB.NET function.
 
Can someone please help. I'm pretty certain I'm not the only one with this type of requirement.
 

Thanks in advance,
 
Kieran.

View Replies !
Inncorrect Or Unssuported Http Function Call
I am creating a vb.net app for a windows ce handheld device. I am using replication to create the database on the handheld. I am getting this error when this error:

View Replies !
Call Excel Function - XIRR From The Report
Hi,
I need to call an excell function, xIRR, from my report.
How can I do that?

Thanks,

Igor

View Replies !
SOLVED: How To Call Scalar Function From JDBC
As an example, I have a scalar function called TRIM that takes a VARCHAR parameter, does a LTRIM(TRIM(VARCHAR)), and returns the result.

How can I call this function from java using JDBC?  I have only had luck calling basic stored procedures, but I need to call functions as well.

Thanks,  Ken

View Replies !
Function Call To Progress Linked Server
I have a Progress DB set up as a linked server.

To get the data through to SQL Server 2005 in a useable format i need to use the progress PRO_ELEMENT function call. How do I delimit this so it gets passed to the progress DB.

I've tried

SELECT

{fn PRO_ELEMENT(fldarr1,1,1)} as fld1

from ls1..pub.tab

 

This just returns an unknown function message which I believe is on the SQL Server end of the call.

This statement works fine through Business Objects.

 

Any help greatfully received.

View Replies !
User Defined Function To Stored Procedure Call?
Hello,
 
Can we call stored procedure from user defined function and vice-versa??
 
Thanks in advance.
 

View Replies !
What Type Of Permission Needed To Call ListJobs() Function
I'm working on Application that requires me to check and display status of reports running on report server. My application calling ListJobs() function of Job class part of Reporting Services Web Service API. When i run my application i'm getting insufficient previleges error. So i need to find out what type of permission i need  to excute ListJobs().

This is very important part of my app. Please help me out.


Thanks,

Viral Patel

View Replies !
Setting The Column Property Description With A SQL Function Call
I am trying to figure out how to set the Description of a Column in my database table by making a SQL function call. I know that I can go into Microsoft Studio Express and type in each desciption for each column. I just have about 1000 variables and each variable's description is in an Excel spreadsheet. I want to be able to build SQL code that will set each of the 1000 variables own description.

Thanks for any help.

Wesley Marshall

View Replies !
Unsupported HTTP Function Call Was Made Error.
 

Hi experts,

I'm new to this forum.  I have been searching around for the solution to the problem that i'm having, and I can solve it.  I'm having the same problem as the title say....unsupported HTTP function call....The thing is that it worked on my development server.  When I transfer all the source to a new pc and execute it, it failed with the error in the subject.  I uninstalled and reinstalled everything.  I ran the http://iissvrname/iisvirtualdir/sscesa20.dll and I get this "SQL Server CE Server Agent" which tell me that IIS & SQL CE are setup correctly.  Here is the error log:

Source: Microsoft SQL Server 2000 windows CE edition
Number: 80004005
NativeError: 28017
Description: An incorrect or unsupported HTTP function call was made.
[,,,,,]
Param = 0
Param = 0
Param = 0
Param =
Param =
Param =

I'm running SQL 7 on the PC and using RDA to pull data from SQL7 db to the PocketPC.

Please help!!!

Thanks!

View Replies !
An Incorrect Or Unsupported HTTP Function Call Was Made Error
Hi All,

I've got this error "An incorrect or unsupported HTTP function call was made"

I can't browse SQL CE Agent using IE also.

How to solve this error? TQ

 

View Replies !
Can I Apply A Database Function Or Assembly Call In An Expression For Filter Data?
I need to translate a user€™s regional setting into one of our own language codes before I send it through as a filter to the model query.  If our language codes were the same, the filter would look like this in the report filter -
                     Language Code = GetUserCulture()
Which translates to this in the database query (for us english) -
                        table.language_code = 'EN-us'
And of course I need it to look like this -
                             table.language_code = 'ENG'
 
I would like the logic to be globally available to all report writers (ie not forcing each report writer to have an iif or case stataement).  I was thinking custom assemblies or maybe a database function, but at this level of the filter, I cannot seem to figure out how to embed a database function call to apply to the filter criteria like this
              Language Code = dbo.ConvertFcnIWrote(GetUserCulture())
Or how I would access the custom assembly in the filter expression.
 
Do you have a recommended implementation for this situation?
 
Thanks,
Toni Fielder

View Replies !
Please Help Me To Resolve The 28017 Error (An Incorrect Or Unsupported HTTP Function Call Was Made), Thanks A Lot.
Now I need to synchonize the data in Pocket PC to the remote sql server database.

I have configured the publication and the virtual directory in the server. When the Pocket PC directly connects to the server (that to say, the Pocket PC connects to the server through the ActiveSync), the data can be synchronized successfully. But when the Pockec PC connects to another computer () through the ActiveSync (this computer connects to the server through the network), the data cannot be synchronized. But when I run the application in the emulator in the same computer, the data can be synchonized with the server.

 

using the following codes, the error message is:

Error Code: 80004005

Message:

Minor Err: 28017

Source: Microsoft SQL Server 2005 Mobile Edtion.

 

private void ShowErrors(SqlCeException ex)
        {
            SqlCeErrorCollection oErrors = ex.Errors;

            StringBuilder oStrBld = new StringBuilder();

            Exception oInner = ex.InnerException;

            foreach (SqlCeError oErr in oErrors)
            {
                oStrBld.Append("Error Code: " + oErr.HResult.ToString("X"));
                oStrBld.Append("Message   : " + oErr.Message);
                oStrBld.Append("Minor Err.: " + oErr.NativeError);
                oStrBld.Append("Source    : " + oErr.Source);

                foreach (int iNumPar in oErr.NumericErrorParameters)
                {
                    if (iNumPar != 0)
                        oStrBld.Append("Num. Par.  : " + iNumPar);
                }
                foreach (String sErrPar in oErr.ErrorParameters)
                {
                    if (sErrPar != String.Empty)
                        oStrBld.Append(" Err. Par.  : " + sErrPar);
                }
                MessageBox.Show(oStrBld.ToString(), "SqlCeException");
                oStrBld.Remove(0, oStrBld.Length);
            }
        }


The environment is:

Client:

Sql mobile (sql ce 3.0)

 

Server:

windows 2003 server

sql server 2000 with sp4

IIS 6

 

And I'm quite sure the virtual directory is correct.

 

Any body can help me? It's urget for me, thanks in advance.

 

 

 

View Replies !
Function Parameter
I am writing a function which will take two parameters. One the fieldto be returned from a table and second parameter is the ID of therecord to be returned.Problem is it's not returning the value of the field specified in theparameter but instead returns the parameter itself. Is there afunction that will get the parameter to be evaluted first?ALTER FUNCTION [dbo].[getScholarYearData](-- Add the parameters for the function here@FieldName varchar(50), @ScholarID int)RETURNS varchar(255)ASBEGIN-- Declare the return variable hereDECLARE @ResultVar varchar(255)-- Add the T-SQL statements to compute the return value hereSELECT @ResultVar=EXECUTE(@FieldName)FROM dbo.qmaxScholarYearID INNER JOINdbo.tblScholarYears ONdbo.qmaxScholarYearID.ScholarID = dbo.tblScholarYears.ScholarID ANDdbo.qmaxScholarYearID.MaxOfScholarYearID =dbo.tblScholarYears.ScholarYearID-- Return the result of the functionRETURN @ResultVarEND

View Replies !
Parameter In Function
Hi,

this has started from me wanting to write a report that allowed the user to choose from a drop down list of how many months they want the report to cover. IE i want the report for the last 3 months, or 5 months or ...

To do this i created a report with a value list parameter (values are negative integers to give the necessary start date for the reported rows) and had that parameter in the where clause, along the lines of ...
select *blah*
from *blah*
where ( *myfield* > dateadd (mm, @MonthParam, GetDate())

i get a sql error (ie an error from the database not reporting services) saying that the variable hasnt been declared.

I have worked around the problem in this instance but is there a 'feature' in RS that means report parameters cannot take part in functions?


TIA

View Replies !
How Specify The Variable As Parameter For A Function
I could successfully modify the package level variable using a script component (Control Flow Level) and execute the data flow task after this script component. The OLE DB Command has one parameter for which I'm using one of the user variable. Here's the SQL statement.

SELECT     Year_Key, Year_Name, Year_Short_Name, Year_Number, Year_Start_Date, Year_End_Date
FROM         d_Time_School_Year
WHERE     (Year_Key = ?)

This works fine. But I want to pass the year_key to a function which accepts a parameter. The SQL should be like this

SELECT     Year_Key, Year_Name, Year_Short_Name, Year_Number, Year_Start_Date, Year_End_Date
FROM        fn_TimeDimension (?)


But SSIS doesn't like this. When I click on parameters command button I get and error like this

"Parameters cannot be extracted from the SQL command. The provider might not help.........

Syntax error, Permission Violation,  or the non-specific error(Microsoft SQL native Client)"

Any clue how to utilize the variables in a SQL which gets data from a function instead of a table?

Thanks

Jemini Joseph

View Replies !
Can't Use Parameter With DateAdd Function??
Hi, I encountered a strange error today.  I have an Integer parameter "hours" that I am trying to use in my SQL Query. 

DATEADD(hh, @hours, @startTime)

It works if I have it set such as DATEADD(hh, 8, @startTime), but I need that parameter there for what I need.

I get this error: 

Error Source:  System.Data
Error Message:  Failed to convert parameter value from Decimal to DateTime.  I tried a variety of CInt and other conversion functions to no avail. 

 

 

Any ideas?

View Replies !
Multi-value Parameter And Function
I have a report with the following dataset query:



Code Snippet
SELECT    ..., 
       dbo.getActivitySinceBeginningYear(..., @countryId ,...) AS HoursYear
FROM         ....
WHERE cast(detail.COUNTRY_ID as nvarchar(max)) IN  (@countryId)  
AND ...
GROUP BY ...
 
 


countryId is defined as a String multi-valued parameter.
The getActivitySinceBeginningYear is defined as follows:
 



Code Snippet
ALTER FUNCTION dbo.getActivitySinceBeginningYear
(
...
@countryId ntext,
...
)
RETURNS decimal(18,5)
AS
BEGIN
declare @return decimal(18,5)
set @return = 0.0

SELECT @return = SUM(detail.HOURS_WORKED)
FROM ...
inner join charlist_to_table(@countryId, Default) f on detail.COUNTRY_ID = f.str
WHERE ...
RETURN @return
END
 
 
This function works as expected if I transmit one ID or several.
The report works fine if I check only one ID.
If I check several IDs, the report displays this error:
Procedure or function dbo.getActivitySinceBeginningYear has too many arguments specified.
 
Why???
 
My second problem is with the Where clause:



Code Snippet
WHERE cast(detail.COUNTRY_ID as nvarchar(max)) IN  (@countryId) 
 
 
If I do:



Code SnippetWHERE detail.COUNTRY_ID  IN  (@countryId) 
 
 
I have the following error:
Conversion failed when converting the nvarchar value '3,5' to data type int.
(I transmitted 3 and 5 for countryId)
 
That's why I tried to use a cast, but the data returned by the query is wrong when I transmit several value.
??

View Replies !
Using A Cursor As A Function Parameter
 

I've created a function that converts the rows of a column into a delimited string using a passed cursor and delimiter character.  In the past I did this in Oracle and called it as shown in the following example:
 
SELECT Table1.ID, Table1.FirstName, Table1.LastName, fnDelimitRows(CURSOR(SELECT Table2.CourseName FROM Table2 WHERE Table2.StudentID = Table1.ID), ',') AS AssignedCourses FROM Table1

 
23   John   Smith      CS101,MT200,BIO100
43   Julio   Johnson   CS200,ENG100,MT300

 
 
How would I pass a cursor into a function in SS like I did above in Oracle?
 
Thanks!

View Replies !
Function Help: Parameter Query
What SQL Function Criteria string replaces [forms]![myForm].[myField]?

I have a function that I want to pass criteria to from a drop down list.   I tried using the same Access string in the Function but it does not work.

View Replies !
Passing Parameter In Function
I have to pass 3parameters in function,
@begindate,@enddate and @group_type..
but in @group_type should be - state,zipcode and country from salestable

inview :vwstzipcont
create view vwstzipcont
as
select distinct s2.stype,s3.itemnmbr,s2.docdate,s3.state,s3.zipcode,s3.country from Salestable s3
left outer join (select distinct stype,docdate from salesdisttable) s2
on s2.stype = s3.stype
where s2.soptype = 2
go

create function mystzipcont

( @begindate datetime, @enddate datetime, @group_type char(70))

RETURNS TABLE
AS
RETURN
(Select distinct t.docdate,t.itemnmbr,t.index,t.group_type from
(
select distinct
vs.docdate,vs.itemnmbr,

p.index From Pubs P

inner join vwstzipcont vs

on vs.index = p.index

Where (vs.docdate between @begindate and @enddate)
and @group_type ) as t


order by t.itemnmbr,t.docdate

end

how can i assign @group_type variable or t.group_type? in s3.state,s3.zipcode,s3.country
can anyone tell me? what condition should be in where clause for this variable?

thanks

View Replies !
Table Name As Function Parameter
I'm trying to write a function that I can run with passing the table name as a parameter. I want to return an integer. The tables wll be differnet types (different colums) but they all have a similar field that i want to get a count of. Someting alng the lines of this:

Create FUNCTION [dbo].[fn_GetItemsToPromote]
(
@TableName nvarchar(100)
)
RETURNS int
AS
BEGIN
Declare @SQL nvarchar(500)
return select count(*) from [@TableName]where promote = 1
END

It doesnt like the @TableName. Can anyone show me how to do this correctly?

Thanks!

View Replies !
Retrieving Result Set From Dynamically Called Stored Procedure Or Function In A Function
Is there any way I can retrieve the result set of a Stored Procedurein a function.ALTER FUNCTION dbo.fn_GroupDeviceLink(@groupID numeric)RETURNS @groupDeviceLink TABLE (GroupID numeric, DeviceID numeric)ASBEGINDeclare @command nvarchar(255)SELECT @command = Condition// @command is an SQL string or stored procedue nameFROM DeviceGroupWHERE GroupID = @groupIDINSERT @groupDeviceLinkEXEC @commandRETURNENDIs there any way i can do anything like this. @command is a variableholding the name of a stored produre. I need to run that storedprocure and return the values in such a way that they can be used in aSELECT StatementMy goal is SELECT * FROM Device INNER JOINdbo.fn_GroupDeviceLink(@groupID) ON ....this fn_GroupDeviceLink should run the proper stored procedure andreturn the values. What i also want to do is play with that result setof the specific stored procedure before i return it. Is this possible?If not, what is the work arround?ThanksMark

View Replies !
How To Pass Parameter In Max Aggregate Function
i have on table temp and it has column name fhID, now that column name and table name comes as parameter in stored procedure from c#.
now stored procedure has code somthing like below
@column nvarchar(50)
@tbname nvarchar(50) 
            -- both are parameter comes from c#
decalre @maxid
select   @maxid=max(@column) from @tbname
          rather than prints the maximum values of "fhid" it prints column name itself.
now i how can i achive actual working of max function using parameter.
is there any other way to pass parameter in aggregate function or it is not allowed to pass.???
plz help me,
thanks
vishal parekh
          'fhid'
now how can

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved