in my table data are stored many times ...I want select the only one data from the repeated data
select ven.Id,ven.Vendor_Name from Purchase_Requsition pur,Item_master itm,Approved_Vendors ven where itm.Item_Id=pur.Item_masterItem_Id and ven.Id=itm.Approved_VendorsId and pur.Request_StatusId=1 and pur.StatusId<>4
ID VENDOR_NAME 1 Ranbaxy 1 Ranbaxy 1 Ranbaxy 2 cipla
I have stored procedure which selects records from an SQL table based on a bunch of user-input parameters.Just discovered that if a record in the table has null values in some of the columns (I haven't figured out which ones yet), then the SELECT is not returning the record (even if it satisfies all the parameters).The SELECT statement is supposed to allow for nulls, and I've been over it a bunch of times and am not sure what I'm doing wrong.Or do I need to get rid of all the null values in the SQL table, and prevent new ones from being introduced?
I have an update function in my data layer which is defined as:
public int UpdateRBTable(parameters ...) This calls a SQL Server Stored Procedure to perform an update function on the database.
The process does its job for updating the table. However, the stored procedure has a return value (which indicates how many rows were updated), but this return value is not returned to the application. The application always shows that a zero was returned from the stored procedure.
I have a select statement in a stored procedure and want to be able to retrieve the key column value (PRODUCTID)and return it as Output when Select statement is executed on input Parameter (NAME).
addition, return two further output values (COST,TOTAL).
note the grid control expects to receive all values at once! so i need to get out these values at the same instance of execution.
Select productID,COST,QUANTITY,NAME,TOTAL,DATE FROM PRODUCTS WHERE NAME=@NAME
I have a page that lists products from a table based on the querystring. So if I say foo.aspx?fam=1 all the products from family 1 will be listed. How can I make my code list all the values if query string is empty? My SQL command would have to be different...can't really see how I can do this.
This code works just fine for me to select * from x,y,z. However what I want to do is retrieve the values return and assign them to variables. How do I go about this?
I am having difficulty selecting data from 2 tables that do no share a primary key value. For instance, I have an actual table, a forecast table, and a GLText table. I may have an actual value but not a forecast value but I need them to appear in the same Query (like the query results shown below). I can get all values to appear in each table but have been unsuccessful in getting all values from both tables.
I have dropdownlist of dates and depending on the date that the user selects from list, I would like to filter records that fall between the startyear and finishyear columns in the datasource. (My the problem is that I do not know how to declare the Startyear and Endyear from the query in the code as they appear underlined - probably the BETWEEN syntax is wrong too).
yYear = DropDownList1.Text Using connection As New SqlConnection("Data Source=CHRIS-PCSQLEXPRESS;Initial Catalog=TorGHL;Integrated Security=True") Dim cmd As String cmd = "SELECT BarDetails.*, MenuHeadingId AS Expr1 FROM BarDetails WHERE (MenuHeadingId = 2)" & "WHERE " & yYear & " BETWEEN " & "(" & StartYear & ")" & " AND " & "(" & EndYear & ")" connection.Open() Dim dapubcb As New SqlDataAdapterDim sqlcomm As New SqlCommand(cmd, connection) dapubcb.SelectCommand = sqlcomm Dim dspubcb As New DataSet("BarDetails") dapubcb.Fill(dspubcb, "BarDetails")
In my asp.net page I pass paremeters to a stored procedure and then inside a try blog the foloving line: affectedRows = ssqldbsorce.insert
never returns expected result from stored procedure.
Inside stored procedure event if I explicitely write the following line "return 5" for example, it never returns 5, only -1, 1, 2
For example here a very simple one without output parameters(I still should be able to return a value without output parameters, right?):
ALTER PROCEDURE [dbo].[createUser] @regCode varchar(10) AS SELECT * FROM dbo.reg_code WHERE reg_code=@regCode .... ---other statements, and for the sake of the example lets return 5 RETURN 5
Is there something wrong with doing it thi way, here is also a tutorial, according to which it should work just fine: [URL]
Is there another way maybe in the assp.net page to capture the value in the variable from a stored procedure.
Here is the deal. I need to create a Stored Procedure that has 2 SELECT statements. Now in ASP.NET, I know that a DataSet can have multiple tables and the DataAdapter can do just that. I am stuck with a scenario where I need to get a value from the first SELECT statement which will later be used in the second SELECT statement. I am creating a SP that passes one parameter (@AnswerID). Which should give me 2 resultsets. See below SELECT statements.
[Code]....
So how do I get the QuestionID from the first SELECT statement?
Basically I am creating a Questionnaire that has Question Dependacies. So from the above SQL statements I would like to display the Question Title with it's relevant answer options but depending on the previous Answer selected hence the @AnswerID parameter.
The reason why I want to use 2 SELECT statements is because I don't want to have 2 roundtrips to th server. So in my code the DataAdapter should return 2 resultsets and fill the DataSet.
If there is any another solution that can prevent 2 roundtrips to the server, I would most definitely like to know how to do it.
I have a table called 'Customer' that contains customer information. One of the fields is named "CustomerType". Each record in the 'Customer' table will contain the value of either "C", "I", or "O".
I have a form that contains a "check box list" named "Type". There are 3 values in the "check box list". The values are "C", "I", and "O". The user can select one or more of these values. I have a button on the form named "btnRunQuery.
When the user clicks on the button "btnRunQuery" I want to exectute a query that selects the records contained in the "Customer" table where the value in the field "CustomerType" equal the values the user selected in the "check box list". Example: If the user selected "C" and "O", then I want the select query to select all records that contain either "C" or "O" in the field "CustomerType".
I assume that what I need to do is to capture the values that the user selected in the "check box list" and put them in a variable. Then I need to format the "Where" statement in the query and add a "Parameters.AddWithValue" command.
In reference to this question that I just asked, [URL] it appears that for some reason, an empty text box's value is not being fed to SQL Server as NULL, as it ought to be.
i am writing a website that has a social networking element to it, and i want to display mutual friends of the person being viewed with the person that is viewing.
is it possible to search one database table and look for matching entries using 2 different usernames? if so how would i do it?
SELECT * FROM tblstock WHERE Devicestatus=('Active') AND Model like '%"&criteria &"%'The statement above is a snippit from my code. My problem is that the search won't understand a space between say two words.?so if the user puts in DELL COMPUTER it won't return anything!? But if they put in DELL on its own it finds the record that says DELL COMPUTER?!!I'm just a bit confused that's all...
I cant seem to find a good example of how to build the query logic. We are allowing users to search based on lat/long and need to add radius as another parameter. So you enter 29.30125 as the latitude and -95.04590 as the longitude and pick say 15miles as the radius, i need to return all records that fall within that radius.. can someone suggest a good site to review this type of query?
When can I use Stored Procedure? Is this useful for looping into multiple SELECT statements to return single value? How? Can anyone post some sample codes? I have text query and notice that my web application is slow and want to find ways to speed it up. Is there any possible ways aside from Stored Procedures?
i have been having trouble trying to find out what is wrong with my sql select query... i wanted to select a sessionID by comparing the tourID and dates. the dates datatype at the database is datetime and the value of itemSessionDate is in string. i tried to convert itemSessionDate to date and dateAndTime but it gave me mm/dd/yyyy while the date in my database is dd/mm/yyyy hh:mm:ss. so i thought i can try using the itemSessionDate string as it has the same value as the one return from the database. but it keeps on goin to the if not reader.hasRows and quit the statement
* 100 AS PERCENTAGE FROM support.SRFILE INNER JOIN BSFLBWF AS BSFLBWF_1 ON BSFLBWF_1.Incidentx = SRFILE.SRONUMBER WHERE (BSFLBWF_1.Closex IS NULL) AND (BSFLBWF_1.DedTypex = 'School' OR BSFLBWF_1.DedTypex = 'LAN-MLE') UNION ALL
The rest of the query continues as the above albeit selecting the same data from different tables and works fine.
The issue I have is that I want to Select some more data (another SELECT query) but with a different Where clause e.g. WHERE (BSFLBWF_1.KPIx NOT LIKE 'KPI%' OR BSFLBWF_1.KPIx NOT LIKE 'Proactive%') AND (BSFLBWF_1.Availabilityx LIKE '')
The problem is that this WHERE clause returns data which the above in bold has null values for (and thus doesnt work). Im still selecting the same data its just the WHERE Clause has changed. Is it possible to run such a query? If so, can it be done via a sub query?
While using an insert query for a certain table, can I used a select statement to know whether there's an already existing value in the stored procedure using a return value where insert occurs? Or do I need to separate a procedure?