Passing Temp Table Values Into A UDF
Jul 20, 2005
This one is interesting...
Is there any way to pass a joined parameter into a UDF as I'm attempting below?
I have a temp table that I'm trying to create:
create table #t3
(bmkPerson int primary key,
LangCode nchar(5),
SName varchar(1000)
)
insert into #t3
select t2.bmkPerson, t2.LangCode,
select SName from SName_trans_udf(t2.LangCode)
from #t2 t2
Thanks in advance,
Renae
Join Bytes!
View 1 Replies
ADVERTISEMENT
Apr 9, 2014
Below are my temp tables
--DROP TABLE #Base_Resource, #Resource, #Resource_Trans;
SELECT data.*
INTO #Base_Resource
FROM (
SELECT '11A','Samsung' UNION ALL
[Code] ....
I want to loop through the data from #Base_Resource and do the follwing logic.
1. get the Resourcekey from #Base_Resource and insert into #Resource table
2. Get the SCOPE_IDENTITY(),value and insert into to
#Resource_Trans table's column(StringId,value)
I am able to do this using while loop. Is there any way to avoid the while loop to make this work?
View 2 Replies
View Related
Dec 13, 2006
Hi,
I've got following code to sync two identical tables between servers.
I first create a #temp table and truncate it so that I'm left with just structure. Next thing I want to do is insert the result of a subquery into the #temp table for later use but for some reason the #temp table remains empty...
As you can see below I've tried 2 approaches to get the result in the #temp table but without success...
Can someone help me coz its getting rather annoying...
thx in advance
Code:
/***** set instance to query from *****/
declare @frominstance varchar(30)
set @frominstance = 'SERVER1INSTANCE1'
/***************************************/
declare @SQL nvarchar(4000)
-- create empty table to insert in next step
select * into #temp from tableTest where id = '1'
truncate table #temp
-- execute query to insert values from SERVER1 into table #temp
set @SQL=N'select * into #temp from ['+@frominstance+'].dbTest.dbo.tableTest tbl where tbl.id not in (select id from tableTest)'
exec sp_executesql @SQL
-- ALTERNATIVE FOR PREVIOUS execute query to insert values from SERVER1 into table #temp
set @SQL=N'select * from ['+@frominstance+'].dbTest.dbo.tableTest tbl where tbl.id not in (select id from tableTest)'
insert into #temp
exec sp_executesql @SQL
select * from #temp -- test to see what in the #temp table
drop table #temp
View 1 Replies
View Related
Jun 6, 2005
Hello,
I am receiving the following error:
Column name or number of supplied values does not match table definition
I am trying to insert values into a temp table, using values from the table I copied the structure from, like this:
SELECT TOP 1 * INTO #tbl_User_Temp FROM tbl_User
TRUNCATE TABLE #tbl_User_Temp
INSERT INTO #tbl_User_Temp EXECUTE UserPersist_GetUserByCriteria @Gender = 'Male', @Culture = 'en-GB'
The SP UserPersist_GetByCriteria does a
"SELECT * FROM tbl_User WHERE gender = @Gender AND culture = @Culture",
so why am I receiving this error when both tables have the same
structure?
The error is being reported as coming from UserPersist_GetByCriteria on the "SELECT * FROM tbl_User" line.
Thanks,
Greg.
View 2 Replies
View Related
May 23, 2008
Hello,
I have created a temporary table that has an identity and default values that it creates and sets but also it needs to get values from a sub query for the final insert into the temp table. I have my create temp table, and my insert into set up but my select is confusing me since some of the values I need to select are determined as they are entered into the temp table. Is there a way to alias them or not put them in the select? If I leave them out it says there are more values in the insert than in the select.
Create Table #TempLabTestConfigImport
(temp_id int identity(1,1),system_id int default 2250, labtestkey nvarchar(10) null,
valuecode nvarchar(10)null, value_description nvarchar(50) null,
value_code_system varchar(10) default 'L',value_type char(2) null,
units nvarchar(5) null,sequence_number int null, table_name nvarchar(50) null,
field_name nvarchar(50) null,created_by int default 57,create_timestamp datetime default getdate(),
modified_by int default 57,modify_timestamp datetime default getdate(),
row_timestamp datetime default getdate())
/*CTE and sub query that combines the data for import and inserts it into temp table*/
With labtestcheck (labtestcode)
as
(
select a.labtestcode
from EMR_temp_labtest_configupdate a
Where Not Exists (Select * From lab_test_add_conf b where b.labtest_key = a.labtestcode)
)
Insert Into #TempLabTestConfigImport
(temp_id,system_id,labtestkey,valuecode,value_description,value_code_system,
value_type,units,sequence_number,table_name,field_name,created_by,create_timestamp,modified_by,
modify_timestamp, row_timestamp)
SELECT temp_id,system_id,
l.labtestcode,t.valuecode,t.valuedesc,value_code_system,
t.valuetype,t.units,t.SequenceCount,t.tablename,t.fieldname, created_by,
create_timestamp,modified_by,modify_timestamp, row_timestamp
FROM labtestcheck l
INNER JOIN
(
select t.labtestcode,b.valuecode,b.valuedesc,b.valuetype,b.units,
row_number() over (partition by t.labtestcode order by b.valuecode) as SequenceCount,
b.tablename,b.fieldname
from EMR_temp_labtest_configupdate a
inner join emr_zseg_code_descriptions b on a.zsegcode = b.zsegcode
inner join labtestcheck t on t.labtestcode = a.labtestcode)t
ON t.labtestcode=l.labtestcode
View 2 Replies
View Related
Jul 25, 2004
Hello everyone :)
I have a temp table that looks like this (as a result of two seperate inserts into it):
RowNumber starttime endtime
----------- ----------- -----------
1 l 0 l NULL
2 l 360 l NULL
3 l 720 l NULL
4 l 1020 l NULL
5 l 1380 l NULL
6 l NULL l 180
7 l NULL l 540
8 l NULL l 900
9 l NULL l 1200
10 l NULL l 1440
I need some help getting it to look like this (with No NULL cell values)!
RowNumber starttime endtime
----------- ----------- -----------
1 l 0 l 180
2 l 360 l 540
3 l 720 l 900
4 l 1020 l 1200
5 l 1380 l 1440
PLEASE help I have been looking at this for the past 3 days and can't figure it out! :o
View 6 Replies
View Related
Jul 10, 2015
DECLARE @Query varchar(8000)
Create Table
#tempCountRichard (Status varchar(50), Number Varchar(1000)
Set @Query = 'Insert Into #tempCountRichard
Select Count(Status),
[code]...
With the following SQL. When I select from the temp table I return the right count but my second column doesn't return anything.
Count Status
1010 2000
1111 2222
When I run the query that is being inserted into the the temp table I return the correct results
Count Status
1010 Pass
2000 Pass with Obs
1111 Fail
2222 None
how to select the data from the temp table exactly the same way it was inserted. As I need to select the exact same data from the insert.
View 23 Replies
View Related
Feb 22, 2007
I have to select several field values from a table and need to assign them to different variables in my SP.Here's what I do now:
declare @ReceiverEmail nvarchar(50)
SET @ReceiverEmail=(SELECT Email FROM Users WHERE UserCode=@UserCodeOwner)
declare @UsernameSender nvarchar(50)
SET @UsernameSender=(SELECT Username FROM Users WHERE UserCode=@UserCodeOwner)As you can see I have to search the Users table twice: once for the Email and a second time for the Username...and all that based on the SAME usercode...:SSo, is there an option where I only have to search the table once and return the Email and UserName fields and assign them to my variables (without using a temp table....)?
View 4 Replies
View Related
Jul 20, 2005
HiI need some help on achieving the following:I wrote a querie which collects Data out of three Tables, the Resultlooks like this:SET NOCOUNT ONDECLARE @ROWINTDECLARE @CURPTNO CURSORSET @CURPTNO = CURSORFORSELECT * FROM TEMPOPEN @CURPTNOFETCH NEXT FROM @CURPTNOINTO @ROWWHILE (@@FETCH_STATUS = 0)BEGINSELECT ONE.CYNO, ONE.ROLE, ONE.ROL_BEZ, ONE.PTNO, ONE.NOCY, TWO.TEXTAS NOCY_TEXTFROM(SELECT CY.CYNO,RE.CYNO AS RECYNO, RTRIM(RE.ROLE) AS ROLE, RTRIM(V_ROLE.TEXT) ASROL_BEZ,RE.PTNO AS PTNO, RTRIM(RE.NAME) AS SACHBEARBEITER, RE.NOCYFROM CYRIGHT OUTER JOINRE ON RE.CYNO = CY.CYNOINNER JOINV_ROLE ON RE.ROLE = V_ROLE.CODEWHERE (RE.PTNO IN(SELECT PT.PTNOFROM PTWHERE PT.PTNO IN(@ROW)AND V_ROLE.LANGUAGE = PT.CLANG))) AS ONELEFT JOIN(SELECT V_NOCY.CODE, V_NOCY.TEXTFROM V_NOCYINNER JOINPT ON PT.CLANG = V_NOCY.LANGUAGEAND PT.PTNO IN (SELECT PT.PTNOFROM PTWHERE PT.PTNO IN(@ROW))) AS TWOON ONE.NOCY = TWO.CODEFETCH NEXT FROM @CURPTNOINTO @ROWENDCLOSE @CURPTNODEALLOCATE @CURPTNOThe Result looks like this:RS1:6313,1300,Architekt,99737505,NULL,NULL2392762,100,Bauherr,99737505,NULL,NULLRS2:2693265,100,Bauherr,99756900,NULL,NULLNULL,1,Planer,99756900,2,Bauherr macht Pläne selberRS3:2691919,100,Bauherr,99755058,NULL,NULL2691962,6000,Kontakt,99755058,NULL,NULLMy Problem is, that I need to have all the Resultsets in one Table atthe end.So my further undertaking was to create a Temp Table with theexpectation to receive all the resultsets in one Step.The TSQL for this looks like that:SET NOCOUNT ONCREATE TABLE #CYRE_TEMP(CYNOINT NULL,ROLEINT NULL,ROL_BEZVARCHAR (60) NULL,PTNOINT NULL ,NOCYINT NULL,TEXTVARCHAR (60) NULL)GODECLARE @CYNOINT,@ROLEINT,@ROL_BEZVARCHAR (60),@PTNOINT,@NOCYINT,@TEXTVARCHAR (60),@ROWINT,@CURPTNOCURSORSET @CURPTNO = CURSOR FORSELECT PTNO FROM TEMPOPEN @CURPTNOFETCH NEXT FROM @CURPTNOINTO @ROWWHILE (@@FETCH_STATUS = 0)BEGININSERT INTO #CYRE_TEMP (CYNO, ROLE, ROL_BEZ, PTNO, NOCY, TEXT)VALUES(@CYNO,@ROLE ,@ROL_BEZ ,@PTNO ,@NOCY ,@TEXT)SELECT @CYNO = ONE.CYNO,@ROLE = ONE.ROLE,@ROL_BEZ = ONE.ROL_BEZ,@PTNO = ONE.PTNO,@NOCY = ONE.NOCY,@TEXT = TWO.TEXTFROM(SELECT CY.CYNO, RTRIM(RE.ROLE) AS ROLE, RTRIM(V_ROLE.TEXT) ASROL_BEZ,RE.PTNO AS PTNO, RTRIM(RE.NAME) AS SACHBEARBEITER, RE.NOCYFROM CYRIGHT OUTER JOINRE ON RE.CYNO = CY.CYNOINNER JOINV_ROLE ON RE.ROLE = V_ROLE.CODEWHERE (RE.PTNO IN(SELECT PT.PTNOFROM PTWHERE PT.PTNO =@ROWAND V_ROLE.LANGUAGE = PT.CLANG))) AS ONELEFT JOIN(SELECT V_NOCY.CODE, V_NOCY.TEXTFROM V_NOCYINNER JOINPT ON PT.CLANG = V_NOCY.LANGUAGEAND PT.PTNO IN (SELECT PT.PTNOFROM PTWHERE PT.PTNO =@ROW)) AS TWOON ONE.NOCY = TWO.CODEFETCH NEXT FROM @CURPTNOINTO @ROWENDCLOSE @CURPTNODEALLOCATE @CURPTNOSELECT * FROM #CYRE_TEMPDROP TABLE #CYRE_TEMPGOAnd the Output looks like this now:Q1:NULL,NULL,NULL,NULL,NULL,NULL2392762,100,Bauherr,99737505,NULL,NULLNULL,1,Planer,99756900,2,Bauherr macht Pläne selberCan someone help me getting all the 6 Rows into one Table as Output?I appreciate any available Help on this..Ssscha
View 1 Replies
View Related
Dec 28, 2006
Hi,
I am using a SQL back end to dynamically populate an asp.net report/page.
As the data I'm interrogating is created from a tree control, I'm having to use a recursive function to retrieve the data into a series of ID values. This all happens at the moment in a DataTable manipulated with c# code. So my ID values end up in this datatable.
My problem is that I am then performing a crosstab query in SQL Server 2000 and these ID are required as part of that query.
Should I create a temp table and join this into the query or should i feed in a series of ID values into a where clause?
Any help gratefully appreciated.
Thanks.
John
View 2 Replies
View Related
May 8, 2014
I would like to know if the following sql can be used to obtain specific columns from calling a stored procedure with parameters:
/* Create TempTable */
CREATE TABLE #tempTable (MyDate SMALLDATETIME, IntValue INT)
GO
/* Run SP and Insert Value in TempTable */
INSERT INTO #tempTable (MyDate, IntValue)
EXEC TestSP @parm1, @parm2
If the above does not work or there is a better way to accomplish this goal, how to change the sql?
View 1 Replies
View Related
Jun 24, 1999
I think this is a very simple question, however, I don't know the
answer. What is the difference between a regular Temp table
and a Global Temp table? I need to create a temp table within
an sp that all users will use. I want the table recreated each
time someone accesses the sp, though, because some of the
same info may need to be inserted and I don't want any PK errors.
thanks!!
Toni Eibner
View 2 Replies
View Related
Jun 12, 2008
Hi all,
I have a store procedure which updates one row of a table. I need to use a trigger, so that it will also update another row in the same table. Like Debit and Credit. Somehow I am not able to pass variables from SP to trigger. Below are my SP and Trigger codes.
STORE PROCEDURE ALTER PROCEDURE dbo.Transfer
(@online varchar(50),
@amount smallmoney,@toaccount varchar(10)
)
AS
Begindeclare @total smallmoney declare @total1 smallmoney
set @total1=1
select @total=TotalAmount from Customers where OnlineID=@online
if @total>=@amount
set @total=dbo.Calulator(@total,@amount)
else
set @total1=0
End
update Customers set TotalAmount=@total where OnlineID=@online
RETURN @total1
TRIGGER ALTER TRIGGER dbo.Updcust ON Customers
FOR update
AS
BEGINdeclare @total2 smallmoney
declare @total3 smallmoneydeclare @amount smallmoney
declare @toaccount varchar(10)
select @total2=TotalAmount from Customers where AccountNumber=8776450012
set @total3=@total2+@amount
UPDATE Customers set TotalAmount=@total3 where AccountNumber=8776450012
END
please help
View 4 Replies
View Related
Feb 17, 2005
Hi...
I'm creating a procedure to fetch rows from table. One field will come come as IN(). Its the condition. That field is numeric field (note down), i would like to pass the In values as parameter.
eg: procedurename @fieldvalue varchar(100)
as
begin
...
WHERE fieldname IN(@fieldvalue)
while executing the procedure how to pass the value... or procedure itself has problem...?
Help me...
Tx in Advance...
View 2 Replies
View Related
Apr 28, 2008
Well is there a way to pass the hardcoded values in a package externally
like for example if in a file system task i have specified the location for moving my files after processing, this will be a harcoded value how can i pass it externally so i have not to go into the package if in case i have modify it to some other location.
View 9 Replies
View Related
May 25, 2015
For finding size values of temp database:
select * from sys.master_files -
size column value here is 1024 for .mdf,size here for .ldf is 64
select * from tempdb.sys.database_files -
size column value here is 3576 for .mdf,size here for .ldf is 224
Why is there a difference and not the same. size columns in the above 2 tables for temp db's do they represent different values ?
View 1 Replies
View Related
May 6, 2014
I have 2 identical tables one contains current settings, the other contains all historical settings.I could create a union view to display the current values from table A and all historical values from table B, butthat would also require a Variable to hold the tblid for both select statements.
Q. Can this be done with one joined or conditional select statement?
DECLARE @tblid int = 501
SELECT 1,2,3,4,'CurrentSetting'
FROM TableA ta
WHERE tblid = @tblid
UNION
SELECT 1,2,3,4,'PreviosSetting'
FROM Tableb tb
WHERE tblid = @tblid
View 9 Replies
View Related
Nov 12, 2007
Hello.
I need to store 2 values that i retrive from a databse into variables so i can check them towards what is typed into the textboxes for my login script iv built. How can i do this?1 string myConnectionString = @"Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersalhoDocumentsIntrapointWebApp_DataIntrapoint.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
2
3 SqlConnection myConnection = new SqlConnection(myConnectionString);
4 SqlCommand cmd = new SqlCommand("SELECT [username], [password] FROM [company] WHERE (([username] = @username) AND ([password] = @password))");
5 cmd.Parameters.AddWithValue("username", TextBoxUsername.Text);
6 cmd.Parameters.AddWithValue("password", TextBoxPassword.Text);
7
8 myConnection.Open();
9
10 //how do i pass the values retrived into variables, like string usrname and string password?
11
12 myConnection.Close();
View 13 Replies
View Related
Mar 21, 2008
I have a stored procedure. Into this stored procedure i need to pass values to a 'IN' statement from asp.net. So when i am passing it , it should b in like a string variable with the ItemIds separated by commas. the procedure i have is :
create procedure SelectDetails
@Id string
as
Select * from DtTable where itemid in(@Id)
Here the itemid field in DtTable is of type int. Now when i execute the produre it is showing error as the Itemid is int and i am passing a string value to it.
How can i solve this problem?
View 4 Replies
View Related
May 7, 2008
I am doing report development against OLAP (Cube). I have a parameter which is a multi-value parameter, and I need to pass this as a parameter into a sub-report (pass all the values selected in this multi-value from the main report to sub report parameter).
Is this even possible? If yes how do I achieve this.
Currenty I sent like Fields!Region.Value(0), but I want to send actually Fields!Region.Value() (meaning all selected).
Any help ASAP is appreciated.
View 3 Replies
View Related
Apr 20, 2007
Hi,
I'm trying to pass multiple values to a single parameter from a report to a second report. For instance I want to pass the values a user selected in the original report, such as the countries a user select under a Country filter, and once the second report is called, I want that report to filter on those same countries, right now I can only pass one of the values selected to the second report. If someone can let me know if this is possible it'd be much appreciated, thanks in advance.
View 1 Replies
View Related
Nov 12, 2015
In t-sql 2012, I want to run a query where the value is normally an int value. I want to supply a large volume of custID values that are normally int values. I have tried to use a cast and convert values and that does not work. The query that I am trying to use is the following:
DECLAREÂ @custID varchar(200)
set @custID = '72793,60546,91069'
select * from table
where in (@custID)
Thus can you show me the t-sql 2012 that I can use to accomplish my goal?
View 12 Replies
View Related
Aug 29, 2006
Version: ASP.Net 2.0Language: C#Hello Everyone!I'm saving data from a function to an SQL Server 2000 db via a stored procedure. There are a few fields which are conditional and thus need not be passed to the procedure everytime. Under those circumstances I need to store null values in the fields.The problem is if I the value of the parameter as null, VS throws the error that a required parameter is not passed. I tried setting 'IsNullable' property of the parameter to true but it works for only those fields who are declared NULL in the stored procedure (For e.g. @DOB DATETIME = NULL).Strangely, this works well in classic ASP.Does anyone know how to accomplish this? Note, altering stored procedures is not an option for me.Thanks a lot!
View 4 Replies
View Related
Jun 7, 2007
Hi, I don't want to pass in parameter values in the url to get a certain record from my database (for a better search engine result) so instead i'm using webuser controls (this is a must) with Public Values that should be read by the SqlDataSource. So in the page that contains the usercontrol there is something like:UserControl.Value = "myvalue"Now I want the SqlDataSource in the usercontrol to read this value and pass it into a query (in the parameter of the WHERE statement, eg.: @recordID = myvalue).Thanks in advance!
View 1 Replies
View Related
Dec 28, 2007
I have a SQL query that goes like this
"select * from Product where ProductID in (1,2,3)"
How can i create a stored procedure where a single input parameter can take multiple values?
Can anyone help me with this?
View 4 Replies
View Related
Feb 13, 2008
Hi All, I'm a newbie learning windows applications in visual basic express edition, am using sqlexpress 2005 So i have a log in form with username and password text fields.the form passes these values to stored procedure 'CheckUser' Checkuser then returns a value for groupid. If its 1 they are normal user, if its 2 its admin user. Then opens another form called Organisations, and closes the log in form. However when i run the project, and enter a username and password and press ok ti tells me that there is incorrect syntax beside a line. I have no idea, and I'm sure that there is probably other things wrong in there. here is the code for the login button click event: Public Class Login Dim connString As String = "server = .SQL2005;" & "integrated security = true;" & "database = EVOC"
'Dim connString As String = _ '"server = .sqlexpress;" _ '& "database = EVOC;" _ '& "integrated security = true;"
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Login_Log_In.Click ' Create connection
Dim conn As SqlConnection = New SqlConnection(connString) ' Create command
Dim cmd As SqlCommand = New SqlCommand() cmd.Connection = conn cmd.CommandText = "CheckUser"
Dim inparam1 As SqlParameter = cmd.Parameters.Add("@Username", SqlDbType.NVarChar) inparam1.Value = Login_Username.ToString Dim inparam2 As SqlParameter = cmd.Parameters.Add("@Password", SqlDbType.NVarChar) inparam2.Value = Login_Password.ToString inparam1.Direction = ParameterDirection.Input inparam2.Direction = ParameterDirection.Input 'Return value
Dim return_value As SqlParameter = cmd.Parameters.Add("@return_value", SqlDbType.Int) return_value.Direction = ParameterDirection.ReturnValue cmd.Connection.Open() Dim rdr As SqlDataReader = cmd.ExecuteReader Dim groupID As Integer
groupID = return_value.Value
If groupID < 0 Then
MessageBox.Show("Access is Denied") Else Dim Username = Me.Login_Username Dim org As New Organisations org.Show() End If
conn.Close()
End Sub The stored procedure code is ok as i know it works as it should, but if it helps the code is: ALTER PROCEDURE [dbo].[CheckUser] -- Add the parameters for the stored procedure here
@UserName nvarchar(50) = N'', @Password nvarchar(50) = N''
ASBEGIN
-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.
SET NOCOUNT ON; -- Insert statements for procedure here
IF (SELECT COUNT(*) FROM dbo.EVOC_Users WHERE Username=@Username AND Password=@Password)=1BEGINPRINT 'User ' + @Username + ' exists'
SELECT TOP 1 UserGroup FROM dbo.EVOC_Users WHERE Username=@Username AND Password=@PasswordRETURN (SELECT TOP 1 UserGroup FROM dbo.EVOC_Users WHERE Username=@Username AND Password=@Password)ENDELSE BEGINPRINT 'User ' + @Username + ' does not exist'
RETURN (-1)ENDEND
All help greatly appreciated to get me past this first hurdle in my first application!! CheersTom
View 16 Replies
View Related
Mar 4, 2008
Hi friends, I m facing an error while i m passing the values in query as special characters like (',"). anyone can help me?code will be more preferable.Thank you.
View 1 Replies
View Related
May 7, 2008
Hello. im tryinng to build an application that has a girdview with values from 2 different tables. The select query i have used in a stored procedure works great but when i try to write something to update into 2 different tables I cant figure out how to do it.
This is the first time im writing stored procedures but from what i can tell i need to do 2 seperate updates to insert mu values.
im using the AdventureWorksLT database provided by microsoft to experiment with and my gridview consists of 2 tables populated by the following stored procedure:ALTER PROCEDURE dbo.GetSomething AS
SELECT Customer.CustomerID, Customer.LastName, Customer.FirstName, CustomerAddress.AddressID, CustomerAddress.AddressType FROM SalesLT.Customer, SalesLT.CustomerAddress
WHERE Customer.CustomerID = CustomerAddress.CustomerID
RETURN
What id like to do is to make the GridView editable and then send the all thee values back so the changes are saved in both tables. Could anyone help me write a stored procedure that gets the values from the fields in the gridview that is beeing changed and send them back to the tables?
View 4 Replies
View Related
Sep 16, 2004
I have written a function as below to pass some value and get aNOTHER VALUE DURING THE RUNTIME
-----------------------------------------------
Sub ExpiaryDate(ByVal Expr1 As String, ByVal Expr2 As String)
Dim strSQLDDL As String = "SELECT STATMENT "
Dim SQlCommand As New SQlCommand(strSQLDDL, mySqlConnection)
SQlCommand.CommandType = CommandType.Text
Dim Colleague_CN As String = Int32.Parse(Expr1)
Dim Course_ID As String = Int32.Parse(Expr2)
Dim parameterEventType_ID As SqlParameter = _
New SqlParameter("@Colleague_CN", SqlDbType.NVarChar, 50)
parameterEventType_ID.Value = Colleague_CN
SQlCommand.Parameters.Add(parameterEventType_ID)
Dim parameterCourse_ID As SqlParameter = _
New SqlParameter("@Course_ID", SqlDbType.NVarChar, 50)
parameterCourse_ID.Value = Course_ID
SQlCommand.Parameters.Add(parameterCourse_ID)
Dim myDataAdapter As SqlDataAdapter = New _
SqlDataAdapter(SQlCommand)
myDataAdapter.Fill(DivisionDataSet, "ExpiaryDate")
myDataAdapter.Update(DivisionDataSet, "ExpiaryDate")
DivisionDataSet.AcceptChanges()
End Sub
Everything was fine as far as i am passing an integer.
Now i need to pass a combination of numbers and letters( NVarChar)
HOW DO I GETAROUND THIS PROBLEM
WHEN I USE THIS FUNCTION I GET ERRORS
SOMETHING LIKE..... Input string was not in a correct format.
INDICATES --Dim Colleague_CN As String = Int32.Parse(Expr1.ToString)
AS AN ERROR
CAN ANYBODY PLEASE HELP
HOW DO I PASS A NVarChar instead
THANKS
View 4 Replies
View Related
Apr 25, 2007
i want to pass a value from one user defined function to another how do i do it.E.g
My first function calulate a value which is to be used by another function for calculation
my 2nd function is given below
Create Function Avg_WLPD_CFS(@Res float,@TotDay int)
Returns float
As
Begin
Return(@Res/@TotDay)
end
the value @Res is calculated from first function, how do i pass this value to the above function.
View 1 Replies
View Related
Feb 28, 2008
I'm want to pass empty parm value to a stored procedure. I'm new at this stuff and not sure how to do this. To make it work I can put values in parms and it works great. I don't want to populate some of the fields in the table with values. The fields are cnty,dist,beat,convertedkey. Anyone know how I can get it done? Code below. Thanks for your help!
int shift = Convert.ToInt16(dr.Cells[1].Value.ToString());
int prior = Convert.ToInt16(dr.Cells[2].Value.ToString());
string lname = Convert.ToString(dr.Cells[3].Value.ToString());
string fname = Convert.ToString(dr.Cells[4].Value.ToString());
string unit = Convert.ToString(dr.Cells[5].Value.ToString());
string handle = Convert.ToString(dr.Cells.Value.ToString());
int badge = Convert.ToInt16(dr.Cells[7].Value.ToString());
string cnty = Convert.ToString('1');
string dist = Convert.ToString('1');
int beat = Convert.ToInt16(1);
int convertedkey = Convert.ToInt16(1);
char action = 'I';
char assign = 'Y';
var db = new dpoffassignedDataContext();
var q = db.SP_DpAssignAllOfficers(action, convertedkey, shift, prior, lname, fname, unit, handle, cnty, dist, beat, badge, assign);
Stored procedure below;
ALTER PROCEDURE SP_DpAssignAllOfficers
(
@action nvarchar(1),
@int_id int,
@shift int,
@prior int,
@lname nvarchar(20),
@fname nvarchar(20),
@unit nvarchar(5),
@handle nvarchar(10),
@cnty nvarchar(10),
@dist nvarchar(10),
@beat int,
@badge int,
@assign char
)
AS
INSERT
INTO dpofficers(dpo_prior,dpo_lname,dpo_fname,dpo_unit,dpo_handle,dpo_cnty,dpo_dist,dpo_beat,dpo_badge,dpo_shift)
VALUES (@prior,@lname,@fname,@unit,@handle,@cnty,@dist,@beat,@badge,@shift)
View 6 Replies
View Related
Apr 18, 2006
how can i send a column of values to the stored procedure for filtering that stored procedure values...?
View 1 Replies
View Related
Aug 13, 2007
I have a custom list(say a list for account numbers, account numbers starting with 13 form a group, then starting with 14 form a group and like that)
and then there are tables inside this list. the report will be displayed based on the values of this custom list.
i also have a drill through report for this. now when i pass fields!accountnumber.uniquename for this list only the first of the group values say 130001 is selected..
what shud i do to select the whole grp??
thanks!
View 4 Replies
View Related