SQL Server :: Pass Values To Sproc From Sproc?
Jan 9, 2011[Code]....
pass values to sproc from sproc?
[Code]....
pass values to sproc from sproc?
I have a table with about 300 OrgID's that I would like to pass into this sproc as the @Org_ID, so I don't have to do them one at a time. How would I do that?
insert into tblRelClients (client_ID, clientRel_ID)
select c1.client_ID, c2.client_ID from tblclients c1 inner join tblclients c2 on c2.OrgID = c1.OrgID
where c1.OrgID = @Org_ID
Anyone know how to do this? I was thinking about making a sproc with something like
select * from users where @group not in member_of
select * from users where @group in member_of
Since I'm dead tired, that's not supposed to be a real query...just an approximation ;)
I have been trying to get this sproc to return all users if null is passed to it from @UserName and a single users if a username is passed to @Username.Can anyone see where I'm going wrong?
[Code]....
In my project, I've been told to create a sproc to get some data. Fine. No problem. However, as we're moving away from a solution created by an external consultant I've had to spend a couple of days trying to figure out how the tables are linked. Sure... However, the big problem is that since this consultant is not supposed to know about this move just yet, I've been told to put my sproc in our production database (same server), and I've been unable to find any good info on this on google S
View 8 Replies[Code]....
I want to keep the old password if the user leaves the password field blank, otherwise store the new password.
I have also tried "IS NOT NULL" instead of "= NULL", but without success. I've tried to send in an empty string and a DBNull value but it never keeps the old password.
i want to get first picture of any album in photo table. i want get output table for show to the datalist control.i need to get albumid in output
so i create a sproc similar this:
create PROC USP_GETFirstPhoto
@ALBUMID INT OUTPUT,
@CATEGORY NVARCHAR(50) OUTPUT ,
@CAPTION NVARCHAR(50) OUTPUT
AS
SELECT @ALBUMID = A.AlbumID,@CATEGORY=A.Category,@CAPTION=TMP.Caption FROM Albums A
CROSS APPLY
( SELECT top 1 * FROM Photos
WHERE AlbumID=A.AlbumID
)TMP
order by A.AlbumID
DECLARE @x INT,@y NVARCHAR(50),@z NVARCHAR(50)
EXEC USP_GETFirstPhoto @x output,@y output,@z output
select @x,@y,@z
but when i exec this proc i have a recorde not a result set
with this query i have resultset
SELECT * FROM Photos
CROSS APPLY (
SELECT TOP 1 AlbumID FROM Photos
GROUP BY AlbumID)TMP
I'm trying to call a linked server, SS2000 that has NText field and instert that data into an nvarchar(120) field on SS2008.
If I execute the SPROC from SS2008 Management Studio, it works fine. If I try to call the SPROC from my ASP.NET 3.5 web application, I don't get any errors, but the data doesn't get updated.
I'm using the following SPROC:
CREATE PROCEDURE [dbo].[usp_UpdateMilestoneDescription]
@UID int
AS
BEGIN
[Code]....
i have a stored procedure with multiple parameters. and several statement which utilities a specific set of queries. therefore, every time its not necessary data will be passed through the parameters, so how can i make "providing data to parameter" optional
My stored procedure:
[Code]....
I've built a Formview, but need to implement some back end functionality - I have a dataset with stored procedures, and am using ObjectDataSources. I've put an asp:button on the page and called it btnDelete, but how do I call the stored procedure ?
Something along the lines of
[Code]....
I want to be able to click on the Delete button, and have it call the stored procedure to delete the record from the dataset...but I don't know C# well enough to be able to work out what the code should be..
Why am I getting two records inserted into the table, when I'm expecting and needing one? The VB code below is checking whether the HTTP is secure or not, and if it is then execute the SPROC. But for whatever reason, I'm getting two records inserted about 5 seconds apart. Does anyone know why and how to fix? I just need one record.
SPROC [Code]....
VB [Code]....
GLOBAL.ASAX [Code]....
I have a list of numbers I need to submit one at a time to a stored procedure to add to a table. I don't know any other way around this. The database for this is an AS400 so it's not like using mssql server. I have a connection string and use the SQLDatasource controls to select data because I can select a stored procedure with it to call. Now I need to do an update and if it was just one time of submitting information I would do it the same way. But I need to submit each number till I do them all. How can I do this? Do I still use a sqldatasource control and set the value to be pulled from like a session var and just loop through setting the session and then sqlds.databind over and over? I added a DBML but can't do that with the as400 stored procedures as far as adding them like I do mssql.
View 5 RepliesFirst I am using Entity Framework 3.5.
I have been listening volumes about this entity framework and though to have a dive in it. I got 3 tables and got the entities and model setup for my database, upto the point where I tried to execute sproc with the datacontext class. I added the sproc to Function Import but as Function Import does not support returning custom dataset that m sproc generates. I googled and found to create Complex Type, but here is the problem, "Get Column Information" in Add Function Import is disabled for me . why the heck its disabled, how to make this work and don't want to revert to older approach just that I could not execute sproc with EF.
[Code]....
View 2 RepliesI'm trying to call a linked server, SS2000 that has NText field and insert that data into an nvarchar(120) field on SS2008.
If I execute the SPROC from SS Management Studio, it works fine.
If I try to call the SPROC from my web application, I don't get any errors, but the data doesn't get updated.
I'm using the following SPROC:
[code]....
I have a sproc that will insert a new record into Table1. Next I need to Insert into another table the scope_identity of the inserted record. How do I incorporate the scope_identity value as the insert parameter in the second insert statement?
View 3 RepliesI know the following sproc is vulnerable to SQL injection:
[Code]....
I would like to write a call to this sproc that uses SQL injection to execute the additional command:
[Code]....
That way, I can demonstrate the vulnerability of the sproc to SQL injection and test any revised implementations of the sproc using the same test call.
Problem is, SQL injection is harder than I thought! I just can't seem to do it.
Can anyone provide me with text for the sproc call to execute the additional command?
I have to be able to dynamically change the sproc name that is used in a Linq to SQL query. I see in the dbml designer this:
[Function(Name="dbo.InsertUnknownMessage")]
I am trying to update a records by calling a SPROC throgh my SQLDataAdapter.Here is my code in this order :
[Code]....
I have looked for parms which are field names with the @ in front but I can't seem to locate them in my code.I could use the assistance of a fresh pair of eyes.
Depending on the data returned from a Stored Procedure, I need to add specific controls to a page and then when they are populated by the user, write them back to the database. What is the easiest way of doing this?
View 9 RepliesI have created a view called business this runs sucessfully ,but the problem is how will i use dynamic values in place of 12.925432,77.5940171 ,I want to pass parameter in sql query from c# code behind.
create view [dbo].[business] as
SELECT Id,
Name1,
ZipCode,
StreetName,
StreetNumber,
[Code]...
I have an SQL Function with the following SQL within:
SELECT StockID FROM (SELECT DISTINCT StockID,
ROW_NUMBER() OVER(ORDER BY DateAdded DESC) AS RowNum
FROM Stock
WHERE CategoryCode LIKE @CategoryID) AS Info
WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1
I have a Parameter @CategoryID - however I need to take in a category ID such as "BA" and translated this to a list of Category IDs such as "IE","EG" etc so my WHERE clause looks like:
WHERE (CategoryCode LIKE 'IE' OR CategoryCode LIKE 'EG') AS Info
I have a Lookup Table which contains the "BA" code and then all the real category codes this means such as "IE" and "EG".How do I have the CategoryID expand to multiple "OR" statements in my SQL Function?
At the moment the query as shown can cope with one CategoryID such as "IE", this is done as I want a category page such as category.aspx where a parameter "BA" is passed such as category.aspx?category=BA and this page will list all items with the category codes "EG" and "IE".
The reason I need this is there is a "parent" category code which has multiple "children" category codes which are different to the parent code. I am using ASP.NET and .NET 3.5 on the front-end if this helps.
In my application I have 7 listboxes.Each list box has morethan 100 listitems.
the best way to pass the selected listitem values(including text values also) to stored procedure in sql server 2005.
i have one scenario in which i have to pass values from one page to another for that currently i am using querystring but now the values are more so i want to remove querystring and i dont want to user session as well and so i have tried using Hiddenfields but after redirecting to another page the values are cleared from all the hidden fields.
View 14 RepliesHow to pass values between ASCX ?/
View 1 Replies