Data Comes Correct With Select But When Convert To Update - It Does Not Work

Jun 10, 2015

Consider the below script

CREATE TABLE #TEMP(Id int,CreatedBy varchar(30),ModfiedBy varchar(30))
CREATE TABLE #TEMP2 (ID int,SearchedBy varchar(30))

INSERT INTO #TEMP VALUES(1,'James',NULL)
INSERT INTO #TEMP VALUES(1,'James','George')
INSERT INTO #TEMP VALUES(1,'James','Vikas')

INSERT INTO #TEMP2(ID) VALUES(1)
INSERT INTO #TEMP2(ID) VALUES(1)
INSERT INTO #TEMP2(ID) VALUES(1)

Now i want to get the result as

;WITH CTE AS(
SELECT ROW_NUMBER() OVER(PARTITION BY Id ORDER BY ID ASC) AS RowNum ,*
FROM #TEMP
)
SELECT CASE WHEN RowNum=1 THEN CREATEDBY
WHEN RowNum > 1 THEN ModfiedBy
END
FROM CTE

But when i convert this select to update, i am missing something...

My update is

;WITH CTE AS(
SELECT ROW_NUMBER() OVER(PARTITION BY Id ORDER BY ID ASC) AS RowNum ,*
FROM #TEMP
)
UPDATE #TEMP2
SET SearchedBy =CASEWHEN RowNum=1 THEN CREATEDBY
WHEN RowNum > 1 THEN ModfiedBy
END
FROM CTE
WHERE #TEMP2.ID=CTE.ID

Only the first record gets updated...

View 9 Replies


ADVERTISEMENT

Need To Convert This Select Into An Update

Sep 18, 2001

In answering this question you could just tell me what you think would work rather than trying to test it.

The following query works correctly and returns rows with pairs of values repid and repid2. I need loop through a large table and update *its* repid2 with rm_repid2 for any rows where its repid value equals rm_repid but only for the pairs that result in the below query

SELECT
rm.repid AS rm_repid
,rm.repid2 AS rm_repid2
,rm.id2contact
,r.repid AS r_repid
,r.prim AS r_prim
FROM sfrep r JOIN sfrepmst rm ON r.repid=rm.repid2
WHERE rm.repid IN
(
'TEST01'
,'TEST02'
)

Returns

rm_repid rm_repid2 id2contact r_repid
-------- --------- ---------------------------------------- -------
TEST01 NEW01 John Smith NEW01
TEST02 NEW02 Ken Roberts NEW02

TIA

Doug

View 1 Replies View Related

How To Convert SELECT Into UPDATE SQL Statement

Apr 15, 2008

Hello!

I am trying to write an update t-SQL statement from the following select statement:

SELECT EduNextContacts.ssn
FROM EduNextContacts Left JOIN
EduContactsAuditChanges ON EduNextContacts.ssn = EduContactsAuditChanges.ssn AND
EduNextContacts.campaign_code = EduContactsAuditChanges.campaign_code
GROUP BY EduNextContacts.ssn
HAVING(SUM(CASE EduContactsAuditChanges.release_code WHEN '103' THEN 1 ELSE 0 END) +
SUM(CASE EduContactsAuditChanges.release_code WHEN '102' THEN 1 ELSE 0 END) >= 2)

I tried many versions of writing my update statement with no luck. My most recent version is as follows:


UPDATE EduNextContacts

SET EduNextContacts.overLMLimit = 'Y'

FROM EduNextContacts Left JOIN

EduContactsAuditChanges ON EduNextContacts.ssn = EduContactsAuditChanges.ssn AND

EduNextContacts.campaign_code = EduContactsAuditChanges.campaign_code

WHERE EduNextContacts.ssn = (SELECT DISTINCT EduContactsAuditChanges.ssn

FROM EduNextContacts Left JOIN

EduContactsAuditChanges ON EduNextContacts.ssn = EduContactsAuditChanges.ssn AND

EduNextContacts.campaign_code = EduContactsAuditChanges.campaign_code

GROUP BY EduContactsAuditChanges.ssn

HAVING(SUM(CASE EduContactsAuditChanges.release_code WHEN '103' THEN 1 ELSE 0 END) +

SUM(CASE EduContactsAuditChanges.release_code WHEN '102' THEN 1 ELSE 0 END) >= 2))


And gives the following error:

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.


Can anyone help shed some light on how to make an update statement from my SELECT query above?

Thanks in advance,
Harry

View 3 Replies View Related

Multiple Tables Used In Select Statement Makes My Update Statement Not Work?

Aug 29, 2006

I am currently having this problem with gridview and detailview. When I drag either onto the page and set my select statement to pick from one table and then update that data through the gridview (lets say), the update works perfectly.  My problem is that the table I am pulling data from is mainly foreign keys.  So in order to hide the number values of the foreign keys, I select the string value columns from the tables that contain the primary keys.  I then use INNER JOIN in my SELECT so that I only get the data that pertains to the user I am looking to list and edit.  I run the "test query" and everything I need shows up as I want it.  I then go back to the gridview and change the fields which are foreign keys to templates.  When I edit the templates I bind the field that contains the string value of the given foreign key to the template.  This works great, because now the user will see string representation instead of the ID numbers that coinside with the string value.  So I run my webpage and everything show up as I want it to, all the data is correct and I get no errors.  I then click edit (as I have checked the "enable editing" box) and the gridview changes to edit mode.  I make my changes and then select "update."  When the page refreshes, and the gridview returns, the data is not updated and the original data is shown. I am sorry for so much typing, but I want to be as clear as possible with what I am doing.  The only thing I can see being the issue is that when I setup my SELECT and FROM to contain fields from multiple tables, the UPDATE then does not work.  When I remove all of my JOIN's and go back to foreign keys and one table the update works again.  Below is what I have for my SQL statements:------------------------------------------------------------------------------------------------------------------------------------- SELECT:SELECT People.FirstName, People.LastName, People.FullName, People.PropertyID, People.InviteTypeID, People.RSVP, People.Wheelchair, Property.[House/Day Hab], InviteType.InviteTypeName FROM (InviteType INNER JOIN (Property INNER JOIN People ON Property.PropertyID = People.PropertyID) ON InviteType.InviteTypeID = People.InviteTypeID) WHERE (People.PersonID = ?)UPDATE:UPDATE [People] SET [FirstName] = ?, [LastName] = ?, [FullName] = ?, [PropertyID] = ?, [InviteTypeID] = ?, [RSVP] = ?, [Wheelchair] = ? WHERE [PersonID] = ? ---------------------------------------------------------------------------------------------------------------------------------------The only fields I want to update are in [People].  My WHERE is based on a control that I use to select a person from a drop down list.  If I run the test query for the update while setting up my data source the query will update the record in the database.  It is when I try to make the update from the gridview that the data is not changed.  If anything is not clear please let me know and I will clarify as much as I can.  This is my first project using ASP and working with databases so I am completely learning as I go.  I took some database courses in college but I have never interacted with them with a web based front end.  Any help will be greatly appreciated.Thank you in advance for any time, help, and/or advice you can give.Brian 

View 5 Replies View Related

Convert XML Data With Select Query And Insert Into Table?

Jun 19, 2014

I want to convert xml data with select query and insert into table.

Xml sample like this :

<ROOT>
<ROW>
<NAME>JHON</NAME>
<ADDRESS>
<ADDRESS1>
<CITY>LKO</CITY>
<STATE>UP</STATE>

[code]....

And data should be like this with select query :

NAME ADDRESS1CITY ADDRESS1STATE ADDRESS2CITY ADDRESS2STATE
JHON LKO UP DLI DELHI
YASH AAA HYR NULL NULL

I want simple query in form of above format.

View 8 Replies View Related

Correct Locking For Update

Dec 12, 2000

I would like a simple statement to select some rows and then update them. I would like to use SERIALIZABLE locking, will this do the trick. Below is my TSQL

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
begin tran
select * from patient_medication_dispersal_ where ddate =
convert(char(10),getdate(),101)

update patient_medication_dispersal_
set rec_status = 1 where ddate =
convert(char(10),getdate(),101) and rec_status =1

commit tran

View 2 Replies View Related

Got The Data With Select, How To Update?

May 13, 2007

Hi all, have a pretty simple query. but am new to workin in multiple tables. This statement shows
Items in table1 that exists in table2 that match a filter.

I would like to change this query to update the TOBEDELETED column to 'F' based on the same column and filter match.


SELECT ITEMS.ITEMNO, ITEMS.TOBEDELETED
FROM ITEMS
INNER JOIN QLOG
ON ITEMS.ITEMNO=QLOG.SOURCEID
WHERE QLOG.SOURCE= 'ITEMS'

Thanks all in advance

View 4 Replies View Related

How To Make A Correct Select

May 24, 2006

Could anyone help med with a select statement with a join between totables. It is to be used in a OLAP cube.I Havde table LedgerBudget and Table Admin. In table admin I can setupa from and to date and also a budgetmodel.The admin have ONE record per OLAP cube.The statement below works fine if I have stated a budgetmodel in tableAdmin.But if no budetmodel stated in table Admin, I want the statement toselect every ledgerbudget with active = 1 and allocatemethod = 0Could anyone help me with this.SELECT LTRIM(dbo.LEDGERBUDGET.ACCOUNTNUM) AS ACCOUNT_ID,dbo.LEDGERBUDGET.STARTDATE AS TRANSDATE, - dbo.LEDGERBUDGET.AMOUNT ASBUDGETFROM dbo.LEDGERBUDGET INNER JOINdbo.ADMIN ON dbo.LEDGERBUDGET.STARTDATE >=dbo.ADMIN.FROMDATE ANDdbo.LEDGERBUDGET.STARTDATE <= dbo.ADMIN.TODATEANDdbo.LEDGERBUDGET.MODELNUM =dbo.ADMIN.BUDGETMODELIDWHERE (dbo.LEDGERBUDGET.ACTIVE = 1) AND(dbo.LEDGERBUDGET.ALLOCATEMETHOD = 0)BR/Thanks

View 6 Replies View Related

Correct Syntax For An Update Stored Procedure

Nov 24, 2005

This is probably a very simple question but i would appreciate some helpwith the correct syntax for and update stored procedureI  have created  user form that allows the user to update the name and address fields in a datatable called  customers based on the input value customer ID =  ( datatable/Customers)customerIDI have got this far and then got lost:Create SP_UpdateCustomer(@customerID, @name, @address)As Update customers ( name, address)Where customerID =  @customerID GOCould anyone tell me what the correct sntax should be.many thanksMartin

View 3 Replies View Related

Correct Syntax For This Select In SQL Server?

Jun 22, 2007

This (demo) statement is fine in Access, and so far as I can see, shouldbe OK in SQL Server.But Enterprise Manager barfs at the final bracket. Can anyone helpplease?select sum(field1) as sum1, sum(field2) as sum2 from(SELECT * from test where id < 3unionSELECT * from test where id 2)In fact, I can reduce it to :-select * from(SELECT * from test)with the same effect - clearly I just need telling :-)cheers,Jim--Jima Yorkshire polymoth

View 4 Replies View Related

Insert,update,select Data From The Database?

Jan 31, 2008

Hi everyone..i m new to this field.. can anyone explain me with simple example onhow to insert,update,select data from the sqldatabase? i m using vwd 2005 express edition along with sql express edition. plz explain the simple example with code (C#) including how to pass connection strings etc.thank you.jack.  

View 6 Replies View Related

(Select All) In Multi-select Enabled Drop Down Parameters Doesn't Work

Apr 29, 2008

Hello all,
I have two mult-value parameters in my report. Both of them working with selecting one or more values. But, when I test using "(Select All)" values for both parameters , only one parameter works. The "available values" for these two parameters are both from the data set.

select distinct ProductType
from Product
order by ProductType

Any suggestion? thx


View 12 Replies View Related

Correct Syntax For ADO.net Recordset's Select Method.

Feb 17, 2006

I have a interger stored in x.

I want to use x in a SELECT statement like so :

SELECT * from aTable WHERE A_Column = x

This select statement is then assigned to and passed as a string like :

sql = "SELECT * from aTable WHERE A_Column = x"

How does the x get interpreted correctly ?

View 1 Replies View Related

SQL 2012 :: IsDate In SELECT To Validate / Correct Date

Dec 6, 2014

I am importing data from a legacy system. The date column is a varchar and in the destination DB it is a proper DateTime.

That said I have invalid data and need to clean / accommodate for it as I go. What I need is if the date is valid then insert it, if not then ue a default of '01/01/1900' I am doing the following and it is not working.

CASE
WHEN isDATE(RatifiedDate) = 1 THEN RatifiedDate
WHEN isDate(RatifiedDate) = 0 THEN '01/01/1900'
END as RatDate

<hr noshade size='1' width='250' color='#BBC8E5'>

View 6 Replies View Related

Transact SQL :: UPDATE Statement - Returns Correct Results When Running Separately

May 1, 2015

SQL Ver: 2008 (not r2)
Problem:  The following code returns correct results when moving variable declarations and update statement outside a stored procedure, but fails to return a value other than zero for the "COMPANY TOTAL" records.  The "DEPT TOTAL" result works fine both in and outside the sp.This may have to do with handling NULL values since I was getting warning message earlier involving a value being eliminated by an aggregate function involving a NULL.  I only got this message when running inside the sp, not when running standalone.  I wrapped the values inside the SUM functions with an ISNULL, and now return a zero rather than NULL for the "COMPANY TOTAL" records when running inside SP.All variable values are correct when running.

SQL CODE:
DECLARE 
     @WIPMonthCurrent date = (SELECT TOP 1 WIPMonth FROM budxcWIPMonths WHERE ActiveWIPPeriod = 'Y')
  select @WIPMonthCurrent as WIPMonthCurrent
  
[code]....

View 10 Replies View Related

Incorrect Syntax Near The Keyword CONVERT When The Syntax Is Correct - Why?

May 20, 2008

Why does the following call to a stored procedure get me this error:


Msg 156, Level 15, State 1, Line 1

Incorrect syntax near the keyword 'CONVERT'.




Code Snippet

EXECUTE OpenInvoiceItemSP_RAM CONVERT(DATETIME,'01-01-2008'), CONVERT(DATETIME,'04/30/2008') , 1,'81350'




The stored procedure accepts two datetime parameters, followed by an INT and a varchar(10) in that order.

I can't find anything wrong in the syntax for CONVERT or any nearby items.


Help me please. Thank you.

View 7 Replies View Related

Data Access :: What Is Correct Usage For Processing Data Adapter Rows

Sep 9, 2015

I have a table that is returning rows from a table query. It seems I have done it before but I cannot seem to get the right procedure to obtain the values. I will paste in the code below in which you will see my bad attempts at accomplishing what I need.

Dim uid As String
Dim pw As String
Dim em As String, fn, ln, mi As String
Dim par As String
Dim Field, n, j As Integer
Dim JJ As Integer

[code]...

View 3 Replies View Related

Update Does Not Work Well

Sep 29, 2006

Hello,I created a formview in a web page. The data are in a sql server express database.With this form, I can to create a new data, I delete it but I can't to modify the data.The app_data folder is ready to write data; the datakeynames element in formview web control declared. I replace the automated query created by VS 2005 by a strored procedure to see if the problem solved.The problem is the same with an update query or a update stored procedure...Have you an idea, please.Than you for your help.Regards.

View 1 Replies View Related

Update Does Not Work

Jan 9, 2007

Im working with a detailsview and when I try to edit something and then update, the changes are not saved.
I have 2 tables ("[etpi.admin].Ocorrencias" and "[etpi.admin].SMS") that store the data that Im trying to change. Since Im having problems with the name of tables, Im coding it manually, using SQL server management studio and VWD.
I believe my code can be wrong (Im new to vwd and C# world), so here it is:
UpdateCommand="UPDATE [etpi.admin].Ocorrencias SET [Status_Ocor] = @Status_Ocor, [Percentual] = @Percentual, [IDPriori] = @IDPriori, [Abertura] = @Abertura, [IDTecRes] = @IDTecRes, [Area] = @Area, [CodEquip] = @CodEquip, [Descricao] = @Descricao, [Destinatario] = @Destinatario, [Data_Implanta] = @Data_Implanta WHERE [etpi.admin].Ocorrencias.IDOcorre = @IDOcorre
UPDATE [etpi.admin].SMS SET [idSMS] = @idSMSWHERE [etpi.admin].SMS.IDOcorre = @IDOcorre"> 
<UpdateParameters><asp:Parameter Name="idSMS" Type="Int32" /><asp:Parameter Name="Status_Ocor" Type="String" /><asp:Parameter Name="Percentual" Type="Int32" /><asp:Parameter Name="IDPriori" Type="Int32" /><asp:Parameter Name="Abertura" Type="DateTime" /><asp:Parameter Name="IDTecRes" Type="Int32" /><asp:Parameter Name="Area" Type="String" /><asp:Parameter Name="CodEquip" Type="Int32" /><asp:Parameter Name="Descricao" Type="String" /><asp:Parameter Name="Destinatario" Type="String" /><asp:Parameter Name="Data_Implanta" Type="DateTime" /><asp:Parameter Name="IDOcorre" Type="Int32" /></UpdateParameters>
Thx.

View 9 Replies View Related

UPDATE DOES NOT WORK!!

Sep 10, 2007

hi all, i have created a gridview with the select,delete and insert commands working properly. but the update command does not work. when i edit a column and click the update button, it generates no errors but does not save the changes. it just brings back the original values. i dont know wats missing. can anyone help me?
this is part of my code:UpdateCommand="UPDATE [test101] SET Surname=@Surname, Names=@Names,Registration=@Registration,[Course code]=@Course_code,Grade=@Grade WHERE ID=@ID1 "<UpdateParameters>                <asp:Parameter Name="Surname" Type=String />                <asp:Parameter Name="Names" Type=String />                <asp:Parameter Name="Registration" Type=String />                <asp:Parameter Name="Course_code" Type=String />                <asp:Parameter Name="Grade"  Type=Int32 />                <asp:Parameter Name="ID1" Type=Int32 />            </UpdateParameters>

View 4 Replies View Related

Update Does Not Work!

Feb 11, 2008

I need to remove all white space i a column in order to succefully convert to int, but it does not seem to work in just this table.

I cannot understand why! I have done this a thousand times before!

I use:
update table1 set col1 = replace(col1, ' ', '')

datatype is varchar(10) not null

View 7 Replies View Related

Getting Correct Data From A Table

Dec 20, 2004

Hey,


I have a temp table with a column of all the same number. When I run my select statement I need it to bring back all the other data and just the single instance of the column with all the same numbers. How would I do this in my select statement?

For example, here is my table:

Here1One
There1Two
Up1Three
Down1Four
Back1Five


I need to bring back everything from column 1 and 3, but just the single instance of 1 from column 2 since it contains all the same number. All the data is collected in a single select statement.

Any suggestions?

Thanks

View 11 Replies View Related

Not Fething Correct Data ?

May 9, 2007

when i retreive the data from the client machine, it is not fething the latest data.



(The server is enterprise edition and the client machine we have sql server express)



The results seems to be flextuating. like some time (01.00 -12.00) it show correct data and some time (say 12.01 - 24.00 ) it does not



this issue happens for other objects (sp and fns )also created in database. appears and disappears alternatively

View 5 Replies View Related

Looping To Get Correct Data

May 30, 2007

I'm a newbie so I'll explain what I'm trying to achieve the best I can ...

I'd like to essentially loop through a SQL table to display the correct results. The workflow is the user query's the database and returns records (by property ID). In the return there are duplicate records being returned - in this case, two property owners returned with the same property ID.

How would I loop through the SQL statement in the application (code) to identify when the property id's are the same and display only one owner for that property?

Thanks!

View 3 Replies View Related

How To Retrive Correct Data

Nov 26, 2007





Code Block
SELECT
tce.TimeCardID,
tce.TimeCardExpenseID,
tc.DateCreated,
e.LoginID,
e.FirstName + ' ' + e.LastName AS FullName,
tce.ExpenseAmount,
tce.ExpenseDescription,
op.ProjectName,
op.ProjectDescription,
ec.ExpenseCode
FROM OPS_TimeCards tc
JOIN OPS_Employees e
ON e.EmployeeID = tc.EmployeeID
JOIN OPS_TimeCardExpenses tce
ON tc.TimeCardID = tce.TimeCardID
Join OPS_Projects op
ON op.ProjectID = tce.ProjectID
Join OPS_ExpenseCodes ec
ON ec.ExpenseCodeID = tce.ExpenseCodeID
WHERE e.LoginID = 'jross'
ORDER BY tc.DateCreated DESC






this query returns me the correct data....but i need to tweak the query so it does not duplicate rows....My tce.TimeCardID is a PK in its table and so is TimeCardExpenseID...but the problem is U can have many TimeCardExpenseID's for one timecard so my results look like

TimeCardID TimeCardExpenseID
1 2
1 3
1 4


I want my query to return the "TimeCardID" but i just want that one ID to represent all the TimeCardExpenseID's...but i can not get it to work and have no clue....

so if i do Select * From TimeCardID = '1'

it should return

TimeCardExpenseID
2
3
4

Any help on how to get this done....

View 4 Replies View Related

Update Database Won't Work

Oct 13, 2006

Hey Guys,

Could some help me out an tell me why this wont run.

I think I got an error at the bottom


USE InfoPathBudget
GO
UPDATE TOSS
SET ytdexpenses = SUM(monthlyExpenses)
SET ytdBudgeted = SUM(monthlyBudgeted)
SET ytdCapitalExpenses = SUM(monthlyCapitalExpenses)
SET ytdCapitalBudgeted = SUM(monthlyCapitalBudgeted)


I got this when I ran it
Server: Msg 157, Level 15, State 1, Line 2
An aggregate may not appear in the set list of an UPDATE statement.

View 1 Replies View Related

How Does UPDATE Statement Work?

May 11, 2007

Could someone tell where I can find out if it's true that duringUPDFATE SQL Serve deletes data from table, and then inserts new one.Thanks-A

View 4 Replies View Related

Return Correct Data For A Given Date?

Nov 15, 2012

I have two table one call Employee and the other table call Target Ratio. They are related via FK EmployeeID

tblEmployee
EmployeeID FirstName LastName
1 John Doe

tblTargetRatio
TargetRatioID EmployeeID EffectiveDate Ratio
1 1 1/1/2012 8
2 1 6/1/2012 5
3 1 9/1/2012 7

My question is how can I query tblTargetRatio table to return correct record for the following cases:

1 EmployeeID = 1 and Date = 03/12/2012 (Expecting Ratio = 8)
2 EmployeeID = 1 and Date = 10/10/2012 (Expecting Ratio = 7)
3 EmployeeID = 1 and Date = 08/12/2012 (Expecting Ratio = 5)

View 2 Replies View Related

Can't Make This Update Work - Advice??

Feb 26, 2008

Hi - I'm in a situation with a very large table, and trying to run an update that, any way I've approached it so far, seems to be taking unnacceptably long to run. Table has about 20 million rows, looks something like this:

ID - int, identity
Type - varchar(50)
PurchaseNumber - varchar(50)
SalesAmount - Money

ID Type PurchaseNumber SalesAmount
1 A 3834AA38384 20.32$
2 B 3834AA38384 11837.32$
3 C 3834AA38384 666.32$
4 C 887DF88U01H 23423.32$
5 A 887DF88U01H 12.32$
6 B OI83999FH28 4747.1$
7 D 38438495985 9384.6
8 E 02939DDJJWI 22.22$
9 F 07939SDFDF2 33.33$

The goal of the update is to make the [Type] uniform across [PurchaseNumbers], according to the max sales amount. For each PurchaseNumber a, set the type = the type of the row that has the MAX salesAmount. If there is only one entry for PurchaseNumber, leave the type alone. Expected update after completion would look like this:

ID Type PurchaseNumber SalesAmount
1 B 3834AA38384 20.32$
2 B 3834AA38384 11837.32$
3 B 3834AA38384 666.32$
4 C 887DF88U01H 23423.32$
5 C 887DF88U01H 12.32$
6 B OI83999FH28 4747.1$
7 D 38438495985 9384.6
8 E 02939DDJJWI 22.22$
9 F 07939SDFDF2 33.33$

I got this out of a warehouse, and it definitely isn't normalized well. Was considering breaking down into a better model, but I'm not yet sure if that would make the update easier.

I've been approaching this with sub-queries (finding all the PurchaseNumbers with more then one entry, then the max sales purchase of that purchase Number, then the type of that purchase number and sales amount to update all of that purchase number) but this not only ends up a little messy, but also very slow.

The only other detail that may be important is that out of the 20 million total rows, about 19.5 million purchaseNumbers are unique. So, really, there are only about 500k rows I actually have to update.

I've thought of a few ways to make this work, but none of them seem fast and wanted to see if anyone had a pointer. Thanks!

View 5 Replies View Related

Is There A Method To Convert Select * From Table To Select Field1,field2,...fieldn From Table ?

Nov 29, 2007

Is there a method to convert "Select * From Table" to "Select field1,field2,...fieldn From Table" ?
 
Thanks

View 1 Replies View Related

Import Data From Excel With Correct Format

Nov 30, 2005

Hi,    I have one column of data which is 15.678 but in the excel, i format it to 15.68 ( two decimal place, so in excel i should see 15.68), when i am trying to import the data from excel to sql server by using odbc connection, it still getting 15.678, how can i get the data from 15.678 to 15.68 ( what i see is wat i get).   Thanks for help.

View 7 Replies View Related

Problem Grabbing Correct Data On A Join

Apr 21, 2008

Hi folks,

I'm a little new to SQL programming but I'm learning. :)

I need to do a join on a table where I exclude records that have more than one urn (unique record number).

In the example table below I want to exclude both entries in the cr_urn column of 49074 & 49075.

cr_urn proc_urn crs_seq crp_seq crp_site

49073233311NULL
49074205111NULL
49074261512NULL
49075128011NULL
490752185121945
49076233311NULL
49077233311NULL
490781145121875

To get to this ->

cr_urn proc_urn crs_seq crp_seq crp_site

49073233311NULL
49076233311NULL
49077233311NULL
490781145121875

View 3 Replies View Related

SQL Select - How To Make This One Work?

Aug 15, 2006

Select *From HSRSeasonWHERESeasonID='1'HSRID=(Select HSRID FROM HSR WHERE HotelID='1' AND ServiceID='1' AND RoomID='1')

View 1 Replies View Related







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