Can't get this query right.

Have a table full of organizations and I want to select those with a unique name. But I also need any ID as well. But that seems to conflict with Group By. It doesn't matter which id.

orgName, id

Posted On: Sunday 11th of November 2012 09:24:43 PM Total Views:  315
View Complete with Replies

Related Messages:

Can't get this query right.   (140 Views)
Have a table full of organizations and I want to select those with a unique name. But I also need any ID as well. But that seems to conflict with Group By. It doesn't matter which id. orgName, id
Can't get the OUTPUT from my sp!   (124 Views)
I'm a novice at writing stored procedures and I can't see why this won't work. I get the following error message when I call the sp below Must pass parameter number 3 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'. I'd really appreciate a bit of help as I am really stuck. Iain Code: CREATE PROCEDURE dbo.uspInsertPersonalInvoice ( @ClientID smallint = 6, @InvoiceTotal smallmoney, @TheScope int OUTPUT ) AS SET NOCOUNT ON INSERT INTO dbo.Personal_Invoice (DateCreated, ClientID, InvoiceTotal, DateSent) VALUES (GETDATE(), @ClientID, @InvoiceTotal, GETDATE()) SET @TheScope = SCOPE_IDENTITY() SET NOCOUNT OFF and to call it Code: DECLARE @TheID int exec dbo.uspInsertPersonalInvoice @ClientID = 6 , @InvoiceTotal = 257.96 , @TheID OUTPUT SELECT @TheID
getting a list of foreign keys   (121 Views)
Im currently trying to generate my add screens in a ASP.NET application. To do so I would like to make selectboxes for the foreign keys. to do so I need a query(or any other sollution) to get a list with all the foreign keys for every table. There should be system tables to get this from, I just don't know where to select it from. Could any1 help me out here Thank in advance, Timo
Where can I get SQL Analyzer or FREE equivalent?   (125 Views)
I am trying to install an ASP (Visual Basic) application. It uses a Microsoft SQL database. The installation instructions are: 1. unzip the .zip file to a Web shared (alias or virtual created via IIS) folder 2. create a database on your SQL server 3. execute the included portal.sql script on the new database 4. update the database connection strings in config.asp for your SQL server database I completed steps 1 and 2. Now I must exicute portal.sql. How can I exicute portal.sql I called my hosting company and they said that they do not provide any tools to do this but I should download SQL Analyzer. Where can I download SQL Analyzer If it is not free, is there a free tool that could be used, if so, where could I download it
Need to get server date regardless of the client date setting   (219 Views)
Hi I am new to this forum, Vivek.P from Bangkok. working as a junior software engineer in a shipping corporation. Actually I need to get the date and time from the server. We have been using Getdate() statement, but when the user changes the date setting in their local machine to thai date setting (ex: 19-apr-2554),getdate() statment which returns the server date is automatically changing to the format of the local machine setting. I need to get the exact format of the date as in the server. Is there any way to do it
Clustering SQL Server 2005 is keep getting fail. Please help (URGENT)   (130 Views)
experts, Ive been given a task to for Clustering SQL Server 2005. Im trying to install Cluster SQL Server installation but its keep getting fail. After I provide with all the details Setup comes up to the stage where it says SQL Server setup is preparing to make requested configuration changes After few minutes I get a message saying Setup failed to start on remote machine. Check the Task scheduler event log on the remote machine. Im using to machines as active and passive notes and I know both are up and running fine. Now Im not sure why Im keep having the above error message and what is causing this problem & also where and which task scheduler event log it is asking me to go and check. Can anybody think of anything which can cause the problem
Group Common Rows togethers, display one of the items in the group based on criteria   (137 Views)
As an example: select height,weight,age from sometable group by height,weight,age Suppose there is a 4th column: Gender Suppose there are columns of values 64 inches, 125lbs, 18yrs old , Female 64 inches, 125lbs, 18yrs old , Male In this case, the row i want displayed is the one for the Male. That is, if all the other columns are the same, display only the one for male. How would I do soemthing liek this simply
Where can we get Service Pack release info ????   (159 Views)
Hi Everyone, Am new to SQL Server Administration. My question, is there is any standard official web-site where we can know all the service pack related information and what is the latest hot fix inofrmation , what is the latest SQL Server database version that Microsoft released. Basically am searching for the service packs in Google and that to if someone tells that SP1 has released for SQL 2008. As a DBA, just want to know where can we get this information so that we will be aware of Service Pack releases and so on ....
Cant get the stored procedure to work.   (143 Views)
So I'm having trouble with this Stored Procedure. I wanted to make it so that when the user enters the information, the datetime part would be optional. Like say, If the user doesnt enter the data, it would automatically use the system to do it and if the user does enter the data manually, the visit_datetime field would get filled. Here's my code. create procedure dbo.p_add_visit_improved @visit_member_id int, @visit_hh_id int, @visit_datetime datetime as INSERT INTO foodpantry_household_visits (visit_member_id, visit_hh_id, visit_datetime) values (@visit_member_id, @visit_hh_id, getdate())
Cant get them at once   (106 Views)
Hi ! I need a simple code to join all these tables in one table!
@@Identity - problem getting data back   (181 Views)
I have some asp that should be inserting a shopper into my SQL Server DB. Code: ' call a stored procedure to create a new shopper sql = "execute sp_InsertShopper" set rsShopper = dbShopper.execute(sql) session("idShopper") = rsShopper("idShopper") And here is the Code for sp_InsertShopper: Code: /* Utilized to insert a new shopper into the database */ Create Procedure sp_InsertShopper AS insert into shopper(chrUserName, chrPassword) values('','') select idShopper = @@identity I checked the DB and the shopper is being created but the session is not storing the ID. Any Ideas Matt
ASP script for getting size of database?   (139 Views)
Is there an ASP script that I can use to find the size of my database
Stored procedure to get data into Excel format from MS SQL database   (233 Views)
Hi I need to write a procedure to extract data from few tables and put it in Excel format...How do i go about it....EVEn if my procedure works how to put the result in excel format...Please somebody guide me..
How to get just inserted value??   (142 Views)
Hi frends i have a table with an auto increment field which is the primary key as well. now how to get the just incremented value and also how do we insure that no one can increment that value until we have done i mean that 2 users, simultaneousley cannot insert 2 same value. i know this has been asked many times, but search is not helping!! thanx
Decimal value from database gets converted to int in app   (227 Views)
Hi all I am returning a decimal value from a stored procedure from my database to my app and in the application the value gets rounded off to integer. I have tried Cdec function and formatcurrency function but no luck. In the stored procedure I used the output statement and return statement. I use @Price as decimal(9, 2) output
getting values   (145 Views)
How to get recordset from Stored procedure?   (180 Views)
I have stored procedure with couple input parameters (MS SQL) which creates temporary table and returns recordset as the result from that tamporary table. Stored procedure works ok on its own. I need to get that recordset in ASP but it doesn't work !! Set cmd = Server.CreateObject("ADODB.Command") cmd.ActiveConnection = Conn cmd.CommandType = adCmdStoredProc cmd.CommandText = "PROC_DrawingTest" cmd.Parameters.Append(cmd.CreateParameter("jobno", adVarChar, adParamInput, 20, Session("JobNumber"))) cmd.Parameters.Append(cmd.CreateParameter("strdwgs ", adVarChar, adParamInput, 1000, sqlstr)) Set rec = cmd.Execute() If not rec.EOF then - here I have an error Error Type: ADODB.Recordset (0x800A0E78) Operation is not allowed when the object is closed. Please, help!
How to get QueryString in SQL Reporting Services?   (112 Views)
Hi , I'm using SQL Reporting Services as my reporting tools for my ASP.Net system. Can anyone tells me how to get QueryString in SQL Reporting Services For example, my user in Customer Dbs Enquiry Screen wish to printout Customer details, user hit "Print" button, in my old ASP system, I use this "http://iisserver/printCust.aspCustID=A123" to call printCust.asp to print Customer A123 in html format. Now I use SQL Reporting Services, how to let it know user wish to print CustID=A123 as above case
probs getting data in datagrid to load   (425 Views)
hi. i am new to sql databases and am currently trying to get the table to populate with data from the database cnCMS. I have been following the ADO.NET step by step text but, when i compile, i keep getting a blank page. below is the method I am using for when the page loads. any ideas what i might be doing wrong any suggestion much appreciated. thanks in advance. Code: privatevoid BindDataGrid() { string sqlQuery = "SELECT AccountID, UserName, Password, " + "Email, ModifiedDate, CreationDate FROM Account"; cnCMSNET.Open(); SqlDataAdapter daAccount = new SqlDataAdapter(sqlQuery, cnCMS); daAccount.Fill(dsMaster2, "Account"); DataGrid1.DataSource = dsMaster2.Tables["Account"].DefaultView; DataGrid1.DataBind(); cnCMSNET.Close(); }
I cant view my triggers in SQL 2008   (158 Views)
, I have a problem in viewing the triggers, I cant display the triggers like the sp in SQL Server 2008, I can create them in the script but I have to select them in the script to view them, is there any way to view them like the sp.