473,803 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored Procedure retrieve Parameter values from variable

2 New Member
Is there any way to get parameter value from variable

like

@Param1 varchar(50)
@Param2 varchar(50)
set Param1 ='value1'

while --condition--
begin
---statement---
@Param2='Param1 '

---?How can I retrieve the value of Parameter that is in @Param2
so I can get data of Parameter that

At last I can get value of @Param1 from @Param2 i.e. 'value1'
Sep 27 '07 #1
3 3323
azimmer
200 Recognized Expert New Member
Is there any way to get parameter value from variable

like

@Param1 varchar(50)
@Param2 varchar(50)
set Param1 ='value1'

while --condition--
begin
---statement---
@Param2='Param1 '

---?How can I retrieve the value of Parameter that is in @Param2
so I can get data of Parameter that

At last I can get value of @Param1 from @Param2 i.e. 'value1'
It depends on what you want to do it after you got it. If you can process it clear an short, compile a statement in a variable then execute it:
Expand|Select|Wrap|Line Numbers
  1. declare @Param1 varchar(50)
  2. declare @Param2 varchar(50)
  3. declare @sql varchar(128)
  4. set @Param1 ='value1'
  5. set @Param2='Param1'
  6. set @sql='print '''+@Param1+''''
  7. exec(@sql)
  8.  
It's OK so long as you can confine your processing to an SQL string. The only way I know of to "bring" the value of anything "out of" the exec "context" is to insert it into a table. So if you need a lot of calculations you have to set up an extra table for this...
Sep 27 '07 #2
DhruviTrivedi
2 New Member
It depends on what you want to do it after you got it. If you can process it clear an short, compile a statement in a variable then execute it:
Expand|Select|Wrap|Line Numbers
  1. declare @Param1 varchar(50)
  2. declare @Param2 varchar(50)
  3. declare @sql varchar(128)
  4. set @Param1 ='value1'
  5. set @Param2='Param1'
  6. set @sql='print '''+@Param1+''''
  7. exec(@sql)
  8.  
It's OK so long as you can confine your processing to an SQL string. The only way I know of to "bring" the value of anything "out of" the exec "context" is to insert it into a table. So if you need a lot of calculations you have to set up an extra table for this...
thank you,

I want to know is this possible using @param2 to get value of @Param1

set @sql='print '''+@Param1+''' '

here i want to use @param2 to get value that is stored in @Param1

using
declare @Param1 varchar(50)
declare @Param2 varchar(50)
declare @sql varchar(128)
set @Param1 ='value1'
set @Param2='Param1 '
print ''+'@'+ @Param2 +''+''

this I get
@Param1

but i need value stored in @Param1
Sep 28 '07 #3
Balthar
1 New Member
thank you,

I want to know is this possible using @param2 to get value of @Param1

set @sql='print '''+@Param1+''' '

here i want to use @param2 to get value that is stored in @Param1

using
declare @Param1 varchar(50)
declare @Param2 varchar(50)
declare @sql varchar(128)
set @Param1 ='value1'
set @Param2='Param1 '
print ''+'@'+ @Param2 +''+''

this I get
@Param1

but i need value stored in @Param1

You are getting the value '@Param1' in your output because you have assigned 'Param1' to the variable @Param2.

Expand|Select|Wrap|Line Numbers
  1. set @Param2='Param1'
What you should have typed on this line is...

Expand|Select|Wrap|Line Numbers
  1. set @Param2 = @Param1
This will assign the value that the variable @Param1 contains to @Param2.

Hope this helps.
Oct 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
9014
by: Bill Kellaway | last post by:
Hi there - this should be fairly simple for someone. Basically I can't figure out how to pass the parameters from ASP to a Stored Procedure on SQL. Here's my code: I just need to help in learning how to pass these varibables from ASP to the SP.
3
22149
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due to the failure of println statements placed afterwards). I get the following error after trying to...
0
6707
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
4
45147
by: laurenq uantrell | last post by:
I need to get the value of an output parameter back into my VBA function calling a stored procedure. I'm using the following construction to append a new record in a SQL Server table: Function ThisFunctionInsertsANewRecord() On Error GoTo myErr Dim cmd As ADODB.Command
2
5463
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
2
2546
by: Bari Allen | last post by:
ASP Classic question: I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First varchar(80) OUTPUT , @Second varchar(80) OUTPUT , @Third varchar(80) OUTPUT , @Amount as numeric(18,0) OUTPUT
7
3471
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function 'UpdateRegistrant' expects parameter '@EMail', which was not supplied. The field value was null in the database and not changed in the FormView so is null going back into the stored procedure. I'm stumped and would greatly appreciate any suggestions.
7
9718
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason for this being to stop the user thinking the application has frozen when in fact it is just waiting for a long SP to complete. Another reason for doing it like this is that I also have had a problem in the past where the SP takes longer than the...
4
4364
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier Architecture. The Stored Procedures are used through TableAdaptors, which in turn are used by Class Files. I wish to be able to return this new ID value using the Stored
9
4148
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table. When calling the stored procedure from VB.NET, in the CommandText, can I just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with "INSERT_INTO_MYTABLE" then do the following : OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.