Strored Procedure For Adding Play List

Dec 20, 2007

Hi...

Am working with asp.net with vb for a MusicProject..

In this I have playlist for particular User..ie User Selects Some Songs and clicks on AddToMyPlayList Button....

Here He can insert those songs into a new playlist or update the earlier..

the StroedProcedure is as follws:  'N' means NewPlayList  and 'E' means Existing

 ***************************************************************************************

CREATE PROCEDURE MUSIC_ADD_PLAYLIST   
(   
@PLAYLIST_NAME VARCHAR(255),   
@USER_ID VARCHAR(255), 
@ItemList NVARCHAR(4000), 
@delimiter CHAR(1), 
@FOLDERNAME VARCHAR(255) ,
@PLAYLISTTYPE CHAR(1)
)   
AS   
   
SET NOCOUNT ON 

  DECLARE @IDENT INT   
 

IF @PLAYLISTTYPE = 'N'

BEGIN
 
  INSERT INTO MUSIC_PLAYLIST   
  (   
   MUSIC_PLAYLIST_NAME,   
   MUSIC_PLAYLIST_USER   
  )   
     
  VALUES   
     
  (   
   @PLAYLIST_NAME,   
   @USER_ID   
  )   
   

  SELECT @IDENT=@@IDENTITY FROM MUSIC_PLAYLIST   
  
END
 
 IF @PLAYLISTTYPE='E'

 BEGIN

 SELECT @IDENT=MUSIC_PLAYLIST_ID FROM MUSIC_PLAYLIST WHERE MUSIC_PLAYLIST_USER=@USER_ID  AND MUSIC_PLAYLIST_NAME=@PLAYLIST_NAME

 END


  DECLARE @tempItemList NVARCHAR(4000) 
      SET @tempItemList = @ItemList 
   
      DECLARE @i INT     
      DECLARE @Item NVARCHAR(4000) 
   
      SET @tempItemList = REPLACE (@tempItemList, ' ', '') 
      SET @i = CHARINDEX(@delimiter, @tempItemList) 
   
      WHILE (LEN(@tempItemList) > 0) 
      BEGIN 
          IF @i = 0 
              SET @Item = @tempItemList 
          ELSE 
              SET @Item = LEFT(@tempItemList, @i - 1) 
         -- INSERT INTO @IDTable(Item) VALUES(@Item) 


 
   INSERT INTO MUSIC_SONGSLIST  
    (Music_PlayList_Id,Music_SongName,Music_Song_Location) 
    VALUES 
    (@IDENT,@ITEM,@FOLDERNAME+''+@ITEM) 
 
   
          IF @i = 0 
              SET @tempItemList = '' 
          ELSE 
              SET @tempItemList = RIGHT(@tempItemList, LEN(@tempItemList) - @i) 
          SET @i = CHARINDEX(@delimiter, @tempItemList) 
   
  END

GO

***************************************************************************************

Here the problem is am not getting the exact result means if i add 6 songs to a playlist it is adding only 4 songs to that particular playlist..

Please help me out

Thanks in Advance,

Madhavi

View 1 Replies


ADVERTISEMENT

Newbie Question: Adding A Single Value To A List In A Stored Procedure

Apr 20, 2006

I have two tables. UserIds is a collection of users, with UserId as the primary key. Contacts simply maps pairs of users. Think of it like IM, where one user can have multiple contacts.


UserIds
----------
UserId - int, primary key
Username etc

Contacts
-------------
UserId - int, the UserId of the user who has the contact
ContactUserId - int, the UserId of the contact

I also have a stored procedure named GetConnectedUserIds that returns all the contacts of a given user. It takes a single parameter, @UserId, the UserId of the user whose contacts I want to get. That's pretty simple:


SELECT ContactUserId FROM Contacts WHERE UserId=@UserId.

Now here's where I get over my head. I actually want that stored procedure to return the user's contacts AND the user's own ID. I want the SELECT statement above, but tack on @UserId to the end of it.

How do I do that?

Thanks in advance for any help. Feel free to answer here or to point me to a useful resource.



Nate Hekman

View 5 Replies View Related

Strored Procedure Question

Oct 23, 2007

 
Hi All
  I am using SQL server 2005.
  I have wriiten the Stored Procedure.
  Once I modified anything in the Stored Procedure I use ALTER command and save it.
   But I am unable to save the comments with this ALTER command which I write in the beginnign of the Stored Procedure.
  I have given the example below.
 Also please tell me without using ALTER is there any way to save the stored procedure. 
  For Ex:   
/*************************************************************************************************************************************************************************************
* Procedure : pr_Generate_PaymentApproval_List
* * Called By : PPComponent.PPPayment.GetPaymentApprovalList
*  Description : This proc is use to retrieve payment approval info
*/
ALTER PROCEDURE dbo.pr_Generate_PaymentApproval_List (
@ins_id BIGINT, @disti_id BIGINT,
@geo_cd NCHAR(4) )
 --
--
Regards
Abdul
 

View 2 Replies View Related

TSQL Strored Procedure

Apr 26, 2006

I am having an issue when trying to pull data from Oracle into a sqlSERVER TABLE. I'm running into an issue because I am using to much temporary space in Oracle because the return set is so large. New to sqlserver, but in Oracle the solution would be to commmit the insert after so many records have been retrieved.



Here's the procedure I wrote I would think I need to add a cursor and a counter which be used to do a commit after so many rows have been retrieved. DOes so one have a procedure I could model mine after?



ALTER PROCEDURE [dbo].[SP_Load_BO]

-- Add the parameters for the stored procedure here

@p1 int = 0,

@p2 int = 0

AS

BEGIN



SET NOCOUNT ON;

INSERT INTO MERCHANT_BACKOFFICE_SQLSERVER

(MONTHYEAR,ALLIANCEID, merchantid,rptservid,scid,tabletype,tablenum,VOLUME, COST, COSTPLUS,DATELOAD)

SELECT convert(DATETIME,PERIOD) as PERIOD,

ALLIANCEID,

merchantid,

rpTSERVID,

scid,

tabletype,

tablenum,

Convert(numeric(10),Count) AS VOLUME,

Convert(numeric(24,6),COST) as COST,

Convert(numeric(24,6),COSTPLUS) as COSTPLUS,

convert(datetime,DATE_LOAD) as DATE_LOAD

from

OPENQUERY(INV,'

SELECT MER.MONTHYEAR AS PERIOD,

MER.ALLIANCEID,

MER.merchantid,

MER.RPTSERVID,

MER.SCID,

MER.TABLETYPE,

MER.TABLENUM,

SUM(MER.VOLUME) AS Count,

SUM(MER.COST) as Cost,

SUM(MER.COSTPLUS) as Costplus,

to_char((last_day(add_months(sysdate,-1))+1),''MM/DD/YYYY'') as DATE_LOAD

FROM

MERCHANT_BACKOFFICE_SERVICE MER

WHERE MER.allianceid <>516

group by MER.MONTHYEAR,

MER.ALLIANCEID,

MER.merchantid,

MER.RPTSERVID,

MER.SCID,

MER.TABLETYPE,

MER.TABLENUM')

END

View 5 Replies View Related

Can I Fill A Cursor From A Strored Procedure?

Nov 13, 2003

Basically, I have a complex stored procedure that combines two tables and fills a cursor.

I would like to fill another cursor in another stored procedure from the results of this first stored proc, rather than have to type it all in again.

The reason being that I am doing a one time import of some data from two tables into one new table based on some complex linking/querying.

Can I fill a cursor from the output of another stored procedure rather than an inline SELECT statement?

Does the sp I am using have to have cursor as an out parameter?

View 4 Replies View Related

Strored Procedure Within SQL Transaction Executes Much Longer

Jul 20, 2005

Hi,I have stored procedure (MS SQL Server 2000) which operateson around 600 000 rows (SELECT, UPDATE, INSERT)and executes in 5 minutes,when I put it in SQL transaction it slows down to more than 5 hours (!!)I have to admit that it is not problem with data locks (beside thatprocedurenothing else is executed on db),It is not also problem with that exact procedure, other proceduresalso slow down heavily when wrapped by SQL transactionvery very seldom stored procedure within transaction executescomparably long that its copy without transactionI guess it could be MS SQL Server 2000 configuration/tuning problem.Any ideas ?Chris

View 1 Replies View Related

Difference B/w User Defined Function And Strored Procedure

Jan 3, 2008

Pls tell me the main differences b/w user defined function and stored procedure .

View 2 Replies View Related

Adding Drop Down List In Report

Jan 10, 2006

I am using Visual Studio 2005 to create a report from a OLAP cube.

I am building a drop down list for user to select the desired branch. My mdx query as follow:

with
      member [Measures].[ParameterCaption] AS '[Company].[Branch].Currentmember.Member_Caption'
      member [Measures].[ParameterValue] AS '[Company].[Branch].Currentmember.Uniquename'
select 
    {[Measures].[ParameterCaption], [Measures].[ParameterValue]} on columns,
    {[Company].[Branch].ALLMEMBERS} on rows
from [Profit And Loss]

I would like to add a blank row in the result set, such that I can consider that as selecting ALL Branch

Any suggestions on what should I do?

View 1 Replies View Related

Adding Variables To The Watch Window / List ...

Feb 5, 2008

Not sure if this is a "user training" issue or a bug, I seem to have difficulty dragging and dropping variable(s) to the watch window. Is there a specific sequence I need to follow to enable this feature in BIDS? Appreciate any feedback.

View 5 Replies View Related

Adding Total To Paramter Drop Down List

Apr 30, 2008


I was trying to write an expression someting like this.

(CASE WHEN (GroupVar2 IN('CBank','DTC', 'EDirect')) THEN GroupVar2 ELSE 'InstLend' END) AS COALESCE(GroupVar2,'Total') AS GroupVar2


In GroupVar2 column, following values are available;


CBank
DTC
EDirect
InstLend
Inst-Load

I use this for a parameter in my report. I want to consider inst-Load as the same as InstLend. In drop down menu , I should see only InstLend. When I select it, I should get summation of InstLend and Inst-Load.
Also I should see 'Total' as one of the available value. So when I select total it should give me summation of all of above.

Can anyone help me to write this corretly?
Thanks

View 1 Replies View Related

Adding A Custom Named Instance To Windows Firewall Exception List

Aug 14, 2007

We install SQL Express 2005 with a custom named instance. Since a named instance uses dynamic ports, how can I add this named instance to the Windows Firewall exception list? Previously with MSDE 2000 we installed as default, then I added port 1433 to the Firewall exception list.

Is there a way to install SQL Express to a static port (programmatically)? Or, is there a better method, like adding the SQL custom named instance service to the firewall exception list?

View 1 Replies View Related

Integration Services :: Adding Values To A Drop Down List In Custom SSIS Task

May 12, 2015

I am writing my first custom SSIS task and I can see that, if I put a public property into the task, I see that property in the standard Properties window. If I add a property of type String, I can put a value in that property, in the task code, and when I instantiate the task in a package, I can see the value I entered.

To try and get a drop down list property in the Properties window, I declared a property of type Combobox, and indeed a drop down list appears in that property.

My problem is trying to get values in that property. I have used the test items:

    Property.Items.add("Fred")
    Property.Items.Add("Jim")

But I do not see the values in the drop down list. All I do see is one item with a value of "(none)".

View 3 Replies View Related

Does XML Play A Big Part Within A SQL Server DB?

Apr 7, 2008

I am going over XML within my SQL SERVER course, and find it quite hard.

I just want to ask, does XML play a big part within SQL SERVER?

Regards

Rob

View 4 Replies View Related

Do Sql 2005 And Access Not Play Well Together?

Mar 19, 2007

Does anyone know if I can't put Access 2003 and SQL 2005 on the same server together? I've got an old, well not that old, application that was farmed out coming back home and apparently it's backend is Access and the frontend is ASP, I think. Anyway, the power's that be would like to upgrade to SQL 2005 and would like everything on the same box together. I've heard rumors that's not possible... Does anyone have any ideas? Thanks a ton.

Nicole (not Anna) Smith

View 3 Replies View Related

Mising Dll To Play A Pc Game

Jul 30, 2007

hi cant i receive de direct page to downloads or upgrade de d3dx9_29.dll

View 1 Replies View Related

How Do You Know What Transation ID To Play Forward After Restore?

Jul 20, 2005

When you restore a backup from a point in time, how do you then knowwhich transaction ID to start with when you want to roll forward fromthat point in time to another point in time?

View 1 Replies View Related

How To Play Wav Data From Image Field In C#

Apr 9, 2008

I have .wav file data stored in an Image field in sql server 2005. Do you know of any sample code to play the sound in a windows forms app (C#)? (This post is just a lame effort to avoid about week of experiments.)

View 1 Replies View Related

Problem With Strored Proc

Jan 28, 2008

I have a stored Proc, which takes 30 min for execution. If I execute it twice it runs properly but when i do the same the third time, it gets stuck.. any reasoning for this..
I am using Insert into statements a lot here...

View 3 Replies View Related

Help With Error Handling Please Strored Procedures

Dec 31, 2004

I've got the folloing stored procedure


ALTER PROCEDURE AddUserData
(@login varchar (8),
@password varchar (8),
@fullName varchar (50),
@RoleID Int,
@statusID Int)
AS

if exists
(SELECT login, @errorReturn
FROM tbEmployee
WHERE login = @login)
return 55555
Else
INSERT INTO tbEmployee (login, password, fullname, RoleID, statusId)
VALUES (@login, @password, @fullName, @RoleID, @statusID)

RETURN @@error


the function that calls this stored procedure is this


Public Shared Function InsertUserData(ByVal login As String, ByVal password As String, ByVal fullName As String, ByVal StatusID As Integer, ByVal RoleID As Integer)

' Create the connection object
Dim connection As New SqlConnection(connectionString)
' Create and initilise the command object
Dim command As New SqlCommand("AddUserData", connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@password", SqlDbType.VarChar)
command.Parameters("@password").Value = password
command.Parameters.Add("@login", SqlDbType.VarChar)
command.Parameters("@login").Value = login
command.Parameters.Add("@fullName", SqlDbType.VarChar)
command.Parameters("@fullName").Value = fullName
command.Parameters.Add("@roleID", SqlDbType.Int)
command.Parameters("@roleID").Value = RoleID
command.Parameters.Add("@statusID", SqlDbType.Int)
command.Parameters("@statusID").Value = StatusID
' Open the connection
Try

connection.Open()
command.ExecuteNonQuery()

Finally
connection.Close()
End Try

End Function


now I'm trying to get ahold of the return value from the stored procedure so I can output a message to the user in a label control.

e.g the soted procedure checks to see if a user already exists if it does it returns 55555. how can I get ahold of this 55555 and place it in a variable in the function so I can then send it to another error function to display the approperate lable message ??

thanks all

View 3 Replies View Related

Strored Proc Change Timestamp?

Jul 12, 2004

Does anyone know of an internal procedure to return the timestamp of the last time a storedprocedure or table was modified?
Currently the object only lists the creation timestamp.

View 2 Replies View Related

Export Strored Procedures In MS Sql Server Management Studio

Jul 18, 2007

Hi,

Can anyone tell me how to export a batch of stored procedures in MS sql server Management studio?

Thanks.







View 1 Replies View Related

Can't Play Files: Video Series: SQL Server 2005 Express Edition For Beginners

Apr 20, 2006

I cannot play any of these video files in RealPlayer or in Windows Media Player. Any suggestions? Anyone else having this problem?

Thanks,

Brian

Video Series: SQL Server 2005 Express Edition for Beginners

C00D1199: Cannot play the file

View 6 Replies View Related

Need Help Adding Onto My Stored Procedure

Apr 6, 2005

calculate age:CREATE PROCEDURE selectage ASSELECT Age = datediff(yy, birthday, getdate()) + case when datepart(dy, birthday) <= datepart(dy, getdate()) then 0 else -1endFROM nopaymy ? is how do fix this problem:I add inWHERE (((Age)>= @age1 And (Age)<= @age2)) and it will complain about Age is not a column, so how would i store the underlined and bold Age aboves value?

View 6 Replies View Related

Adding New Stored Procedure

Mar 27, 2006

Currently I add a new stored procedure in Enterprise Manager by right-clicking Stored Procedure and clicking New Stored Procedure then copy/paste text of procedure into window displayed. Whenever we set up new customer, this process is repeated several times to get all of our stored procedures loaded.
Is there a way to automate this process?
Thanks

View 2 Replies View Related

Adding Stored Procedure

Jan 31, 2008



Hello,

What is the easiest way to add a strored prodedure in SQL- server? Sounds like silly question but it doesn´t seem that obvious to me.

BTW, I´m using SQL-server 2005.

Thanks in advance!

View 6 Replies View Related

Adding CLR Stored Procedure In ASP.Net Website

Apr 12, 2007

Hi all,I am creating a ASP.Net 2.0 website and in it I had to create a CLR stored procedure to do a complex sql procedure. Coming to the problem I created the CLR stored procedure as a different database project . I wanted to know whether its possible to add the CLR managed code into my exisiting ASP.Net project in which case I should get the dll for this stored procedure in order to deploy the stored proc in the SQL Server.Or is there some simplified approach to using clr stored procedures in an ASP.Net project.

View 2 Replies View Related

Adding A Variable To A Stored Procedure

Jul 19, 2007

Hi,I just try to add a variable (ORDER BY) to the end of a select statement and it doesn't work. I try so many things but im a newbie in SQL.Help!!!I want to add @OrderBy at the end of :-----------------SELECT *FROM AnnoncesWHERE CategoryID = @CategoryID AND DateOnCreate >= @DateFinale-----------------My declaration :Declare @OrderBy nvarchar(50)If @Sort = 'date_de' set @OrderBy = ' ORDER BY DateOnCreate DESC'Else  set @OrderBy = ' ORDER BY DateOnCreate ASC'

View 8 Replies View Related

Adding Procedure To SQL Server Express

May 18, 2006

I am adding (trying to add) a procedure (written by a friend of mine and someone who is experienced). I am adding it via the SQL Server Mgt. Studio Express. When I run it, it says that the command completed successfully, but it doesn't appear in the Procedure folder.

When I run my ASP 2.0 form that calls it, it says that it can't find the procedure.

Can anyone help me determine what to look for or what I might be doing wrong?

Thank you.

View 3 Replies View Related

Stored Procedure For Sorting A List

Mar 10, 2008

I have the following, which loads up a product search i now want to be able to sort it based on criteria such as price. This is what i have so far; String str = Session["subCategoryID"].ToString();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["streamConnectionString"].ConnectionString);SqlCommand command = new SqlCommand("stream_CategoryResults", conn);
command.Parameters.Add("@subCategoryID", SqlDbType.Int).Value = str;command.CommandType = CommandType.StoredProcedure;
conn.Open();SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
dgProducts.DataSource = reader;
dgProducts.DataBind();
conn.Close();
My question is would i need to have different stored procedures, for when loading it up, and when sorting it by price. This is what my stored procedure looks like;CREATE PROCEDURE stream_CategoryResultsByPrice
@subCategoryID INT
 AS
SELECT DISTINCT Companies.companyName, Companies.companyLogo,SubCategories.subCategoryName, Products.productPrice, Products.productInfoURL FROM Companies INNER JOIN Products ON Companies.companyID = Products.companyID INNER JOIN SubCategories ON Products.subcategoryID = SubCategories.subCategoryID WHERE SubCategories.subCategoryID=@subCategoryID

View 3 Replies View Related

Passing A List To Stored Procedure

Feb 12, 2001

Hello, I'd greatly appreciated if someone can help me out on this problem:
I'd like to pass a string (which is a multiple value in this case - "Smith", "Lee", "Jones", "Hanson") as an input parameter to a stored procedure. I'd like to use this string as part of the select statement:

exec sp_GetLN "smith, lee, jones, hanson"


In the stored procedure:
@strLN varchar <- "smith, lee, jones, hanson"

/*What do I need to do here to SET/REPLACE the original string so that the syntax can be accepted by the select statement??*/

SELECT * from tblCustomers
WHERE LASTNAME IN (@strLN)

It looks simple but I've been trying to get the syntax to work. What can I do to change the quote from ' to "?? Can I use char(34) like VB??
Your help is greatly appreciated~

Thank you

View 2 Replies View Related

Sending A List To A Stored Procedure

Feb 23, 2005

Hello

How can I send a list(s) of data into a stored procedure for processing?

For instance, I have a table: GroupContacts(groupname, userid, contactid).
At times I will be inserting X amount of records into it, X depends on how many contacts need to be added to a group by a user.

How can I send a list of (groupname, userid, contactid)'s into a stored procedure and then use some kind of for-loop to iterate through the list and insert the records?

Thanks
jenn

View 3 Replies View Related

Possible To Specifying A List As A Parameter To A Stored Procedure ?

Jul 26, 2006

I have been converting a VB 6 applications database queries into SQL Server 2000 stored procedures and have come up against a problem where lists are used in search conditions...For example a list of accounts are selected based on their account currency ID being equal to 1, 5, or 7. In the VB 6 query the string looks like....

SELECT tblAccount.txtName FROM tblAccount WHERE (tblAccount.intCurrencyId IN(1, 5, 7))

The list could contain a single value or upto 20 values. Is it possible to pass the currency list (i.e "1, 5, 7, ...") as a parameter to the stored procedure?

Any help much appreciated!

View 3 Replies View Related

Field List From A Stored Procedure

Apr 16, 2004

I am writing a utility that creates Java code to access a database. I am looking for a way to get a list of fields and types that are returned by an sproc. Is there any easy way to get this from the master? Do you need to parse the SQL? This list would be like what Visual Studio.NET shows, or interdev if I remember correctly.

Thanks,

Larry

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved