Update Query Using Uppercase
Dec 30, 2004
Hi,
I have a table where the values in the Description field are all upper case. I found a script that will change all the words to UPPERCASE in the first character then LOWERCASE for the remaining until the next space is found. It will also repeat this for all words in the field.
The part I need help with is having this repeat through the entire table. Heres the code and thanks - troy
declare @input varchar(20)
declare @position int
set @input = (SELECT Description FROM tbl_ItemMast where wallysku ='10071')
set @position = 1
SET @input = Upper(substring(@input,1,1))+ LOWER(substring(@input,2,len(@input)-1))
WHILE @position < DATALENGTH(@input)
Begin
set @position = charindex(' ',@input,@position+1)
if @position = 0
goto done
SET @input = REPLACE(@input,substring(@input,@position,2),Upper(substring(@input,@position,2)))
End
DONE:
PRINT @input
View 2 Replies
ADVERTISEMENT
Oct 16, 2006
In Query Editor I type statements like this:
"select * from ...."
Does Query Editor support a "macro" facility where I could, via keystorke, uppercase all t-sql keywords? (so it would look like SELECT * FROM...)
TIA,
barkingdog
P.S. You think I'm lazy? I knew a programmer who was so lazy that his password was one character long!
View 7 Replies
View Related
Dec 11, 2007
In sql2005 how can I update a table in my db to give me all uppercase. I have never created a sp but would like to try to do this so can someone point me in the right direction. If a select/update statement is better then please give me suggestion that way also. Thanks in advance
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1445009
MELVIN
CALVIN
A
000142718
12/11/2007 6:44:00 AM
40
503
5831
mark
lama
A
000005831
12/11/2007 7:51:00 AM
41
503
01
8300
tito
fernandez
A
000008300
12/11/6:58:00 AM
41
503
01
2380
ANNABEL
MEZA
A
00000380
12/11/2007 8:06:00 AM
41
503
01
3697
armando
hernandez
A
000003697
12/11/2007 7:24:00 AM
41
503
01
5208
juan
guardiola
A
000005208
12/11/2007 7:29:00 AM
41
503
01
523614
JOHNNY
KELLEY
A
000143625
12/11/2007 8:00:00 AM
41
503
04
View 5 Replies
View Related
Jul 23, 2005
How can I create a trigger that obliges UPPERCASE of a field in thedatabase?thanks
View 3 Replies
View Related
Apr 27, 2006
I have been tinkering with triggers and have tried to build one that will format the names in two columns to UPPERCASE.
Trouble is it won't run and I don't know why, how can I accomplish this uppercase task with a trigger?
View 2 Replies
View Related
Jul 23, 2005
I have a table where inactive names are lower case and active names areuppercase. Note: Not my design.Anyways I want to select all names form this table where the name isuppercase. I see collate and ASCII pop up in searches but the examplesdon't seem usable in queries as much as they were for creating tablesand such.Thanks,Phil
View 5 Replies
View Related
Jul 12, 2006
Hi,
What is the dowside of not using all uppercase for predicates and key words?
I cannot find to see a problem beside adhering to a clean coding convention. After all I already have color coding so what would be the uppercase for?
Same question for the semicolon ; at the end of a sql block. Is that real necessary not to get in trouble sometime down the road or is it a non-issue. I find like I am now a C# guys if I use these ;
Just curious, I find tedious to switch from all upper case to normal case all the time. And not forget to type the ;
Thanks,
Philippe
View 7 Replies
View Related
Aug 15, 2005
Hi all!This is the problem:User enters student name, in the database, only the 1st letter is uppercase and the rest is in Lower case.So, I want to fix this so as it is not case sensitive, i.e. the user can enter a name and it will return the recordwhether they enter it in upper or lower case.My Code:CvtUpperCase.Text = UCase(Content.Text) //stores user's input
Select Case OptionChoice
Case "Student_FirstName" MyCommand = New SqlDataAdapter("select * from [qryStudentDetails] where [qryStudentDetails].[Student_FirstName] like '" & CvtUpperCase.Text & "'" , myConnection)
....Any ideas??
View 2 Replies
View Related
Apr 9, 2008
Hi
I am trying to output the data in the table to uppercase. I am using bcp to output as text file.Any possible solution to convert the data to uppercase from the table.Any tsql code for this
Thanks in advance
View 4 Replies
View Related
Dec 10, 2007
I am always changing the Sql Query Keywords to UpperCase and formatting the T-sql.
Is there a option so that i can change the keywords to uppercase automatically in the sql 2005 management studio ?
How do most of you format the sql statements?
Please let me know it will save me and most of us like me alot of time.
Your help will be most appreciated.
Thanks in Advance
Savvy
View 6 Replies
View Related
Jan 28, 2004
I am trying to convert all my client first and last names in my table to uppercase. They are currently listed as mixed case. Also I wanted to know what is the best way to force the data to UPPERCASE hwen a end user tries to insert or update the clients name. I am thinking about trying a trigger, but I am unsure how to set it up. Thanks for all the help.
View 4 Replies
View Related
Sep 19, 2006
I know you are able to display data all uppercase or all lowercase, but how do you display it First letter capital rest lower. Like a First or Last name?
View 3 Replies
View Related
May 10, 2007
I would like SQL Server 2000 to distinguish between uppercase and lowercase letters, but only within a single stored procedure. Also, at the end of the sp, I want the original collation to be restored. How will I implement this in my sp?
View 3 Replies
View Related
Aug 1, 2015
The states in this report are all in caps TEXAS, CALIFORNIA, etc.. Is there a way to use expressions to only have the first letter in uppercase and rest in lowercase?
View 3 Replies
View Related
Mar 26, 2007
Hi! Select gets all records that contains illegal chars... Ok, to replace '[' { and some other chars I will make AND '% .. %' and place other intervals, that is not the problem.The problem is: How to replace not allowed chars ( ! @ # $ % ^ & * ( ) etc. ) with '_' ?I have seen that there is a function REPLACE, but can't figure out how to use it. 1 SELECT user_username
2 FROM users
3 WHERE user_username LIKE '%[!-)]%';
View 2 Replies
View Related
Sep 15, 2001
I'm looking for a query that can "batch" update one table from another. For example, say there are fields on both tables like this:
KeyField
Value1
Value2
Value3
The two tables will match on "KeyField". I would like to write one SQL query that will update the "Value" fields in Table1 with the data from Table2 when there is a match.
View 1 Replies
View Related
Jul 20, 2005
Hi there,I'm a little stuck and would like some helpI need to create an update trigger which will run an update query onanother table.However, What I need to do is update the other table with the changedrecord value from the table which has the trigger.Can someone please show me how this is done please??I can write both queries, but am unsure as to how to get the value ofthe changed record for use in my trigger???Please helpM3ckon*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 1 Replies
View Related
Mar 1, 2007
Can I roll back certain query(insert/update) execution in one page if query (insert/update) in other page execution fails in asp.net.( I am using sqlserver 2000 as back end)
scenario
In a webpage1, I have insert query into master table and Page2 I have insert query to store data in sub table.
I need to rollback the insert command execution for sub table ,if insert command to master table in web page1 is failed. (Query in webpage2 executes first, then only the query in webpage1) Can I use System. Transaction to solve this? Thanks in advance
View 2 Replies
View Related
Mar 30, 2006
Hello, I have the following query in Access 2000 that I need to convertto SQL 2000:UPDATE tblShoes, tblBoxesSET tblShoes.Laces1 = NullWHERE (((tblShoes.ShoesID)=Int([tblBoxes].[ShoesID])) AND((tblBoxes.Code8)="A" Or (tblBoxes.Code8)="B"))WITH OWNERACCESS OPTION;The ShoesID in the tblShoes table is an autonumber, however the recordsin the tblBoxes have the ShoesID converted to text.This query runs ok in Access, but when I try to run it in the SQLServer 2000 Query Analizer I get errors because of the comma in the"UPDATE tblShoes, tblBoxes" part. I only need to update the tblShoesfield named Laces1 to NULL for every record matching the ones in thetblBoxes that are marked with an "A" or an "B" in the tblBoxes.Code8field.Any help would be greatly appreciated.JR
View 2 Replies
View Related
Mar 5, 2008
Hi everybody,
I would like to know if there is any property in sql2000 database to separate lowercase characters from uppercase characters. I mean not to take the values €˜child€™ and €˜Child€™ as to be the same. We are transferring our ingres database into sqlserver. In ingres we have these values but we consider them as different values. Can we have it in sqlserver too?
Hellen
View 1 Replies
View Related
Nov 19, 2004
I have an update query running which to just now has been running for 22 hours running on two tables 1 a lookuptable that has just been created within the batch the other a denormalised table for doing data analysis on
the query thats causing teh problem is
--//////////////////////////////////// this is the one thats running
Print 'Update Provider 04-05 EmAdmsCount12mths : ' + CAST(GETDATE() AS varchar)
GO
Update Provider_APC_2004_05
set EmAdmsCount12mths =
(Select COUNT(*)-1
from Combined_Admissions
where ((Combined_Admissions.NHSNumber = Provider_APC_2004_05.NHSNumber) or
(Combined_Admissions.PASNUMBER = Provider_APC_2004_05.PDDISTNO)) and
(Combined_Admissions.AdmDate BETWEEN DateAdd(yyyy,-1,Provider_APC_2004_05.AdmDate) AND Provider_APC_2004_05.AdmDate) AND
Combined_Admissions.AdmMethod like 'Emergency%')-- and
-- CA.NHSorPrivate = 'NHS'))
FROM Provider_APC_2004_05, Combined_Admissions
any help in improving speed would be most welcome as there are 3 more of these updates to run right after this one and the analysis tables are almost double the size of this one
Dave
View 6 Replies
View Related
Jul 10, 2006
This is my first website done in ASP.NET and SQL Server 2005. I haven't ran into any major problems, until I tried to run an update on some rows. I've searched everywhere online, only to be stuck at the end of the day. I will post the code I have for the button that triggers it. I'll be crossing my fingers! int eid = Int32.Parse(Request.QueryString["id"]);
string updateSQL = "UPDATE Events SET event_title = @event_title, event_date = @event_date, ";
updateSQL += "event_time = @event_time, event_location = @event_location, event_description = @event_description WHERE (eid = @eid)";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(updateSQL, con);
cmd.CommandType = CommandType.Text;
// Add the parameters.
cmd.Parameters.AddWithValue("@event_title", txtEditTitle.Text);
cmd.Parameters.AddWithValue("@event_date", txtEditDate.Text);
cmd.Parameters.AddWithValue("@event_time", txtEditTime.Text);
cmd.Parameters.AddWithValue("@event_location", txtEditLocation.Text);
cmd.Parameters.AddWithValue("@event_description", txtEditDescription.Text);
cmd.Parameters.AddWithValue("@eid", eid);
// Try to open database and execute the update.
try
{
con.Open();
int updated = cmd.ExecuteNonQuery();
}
catch (Exception err)
{
Response.Write(err.Message);
}
finally
{
con.Close();
Response.Redirect("./?msg=eus");
}
View 11 Replies
View Related
Feb 19, 2007
Hi everyone!I have a update query which all looks good and it looks like it executes, though it does not effect the database for some unknown reason. (No error messages).protected void Button1_Click(object sender, EventArgs e)
{
int areaId = 0;
if (Request.QueryString["doc_area_id"] != null)
{
areaId = Convert.ToInt32(Request.QueryString["doc_area_id"]);
}
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["CPS_docshareConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand("UPDATE document_area SET doc_area_name = '" + AreaText.Text + "' WHERE doc_area_id = @areaId", myConnection);
command.Parameters.Add(new SqlParameter("@areaId", areaId));
myConnection.Open();
command.ExecuteNonQuery();
myConnection.Close();
} Thanks for any help you can give, cheers, Mark.
View 8 Replies
View Related
Jul 19, 2007
I am using the update query listed below in my DetailsView. The issue i am having is the ManagerDecision value which gets populated in a DropDownList in EditTemplate, doesnt seem to update correctly. If I choose 'Approved' from the DropDownList, the result for Status_Type ends up being 'Closed' and not 'Open'. Could someone please Help.
Thanks!!
UPDATE ServiceRequest_Table SET ManagerDecision = @ManagerDecision, Comments = @Comments, Priority_Name = @Priority_Name, Status_Type = CASE WHEN (ManagerDecision = 'Approved') THEN 'Open' ELSE 'Closed' END, ManagerDateTime = CASE WHEN (Status_Type = 'Closed') THEN '' END, Closed_Date = CASE WHEN (Status_Type = 'Open') THEN '' END WHERE (ServiceRequest_ID = @ServiceRequest_ID)
View 33 Replies
View Related
Jul 23, 2007
OK, so I have this page where a user can edit multiple fields in a database record. My problem is, that once changes have been made and the user hits the "save" button, everything SEEMS to run just fine (no errors, other things that should happen when the button is clicked happen normally), but nothing is changed. It's almost like the update function (which was created with Microsoft ASP.NET Web Matrix) is working, but it's being fed the old values for the page, rather than the updated ones.
Any ideas on what might be causing this? It's not like anything I've seen before.
Thanks
Kaiti
View 13 Replies
View Related
Feb 16, 2008
I gave a storedprocedure for gatting data into gridview,just go through that.
Select Ind.Industry_Name,Com.Company_Address from Pcra_Industry Ind join Pcra_Company Com on Ind.Ind_ID_PK=Com.Ind_ID_FK Here iam getting two fields from two different table depending on the Id.
So how to write a Query to change the fields in the different tables.
please Help me...
View 1 Replies
View Related
Feb 19, 2008
Im having a problem when using my update statement on button click. I want the field to be updated to be true whenever the button was clicked but it doesn't seem to like my current syntax. Can someone point me in the right direction please? I know its really simple but when you have just been looking at something for so long you can never see it!!! Thanks
SqlCommand myCommand = new SqlCommand("Update Notice SET Resolute = '" + Resolute + "', DateClosed= '" + DateClosed + "', Resolved = 'True' WHERE NoticeID = " + NoticeID + "", myConnection);
View 3 Replies
View Related
Apr 22, 2008
Hi Guys
I have a problem with UPDATE query. Here is my Select query.
SELECT d.EID as EID,d.EName as EName,d.EDOB as EDOB,d.EDesignation as EDesignation,d.ESal as ESal,EI .EPhone as EPhone,EI .EEnddate as EndDate FROM Data_EMP d Join Emp_Info EI on d.EID=EI.EIDWhere d.EID ='1001'
According to this query I have to update another query.This is my original Update Query.
"Update Data_EMP set EStatus=0 where EID='" & TempEID & "'"
Now i wrote update query like this
UPDATE d.EID as EID,d.EName as EName,d.EDOB as EDOB,d.EDesignation as EDesignation,d.ESal as ESal,EI .EPhone as EPhone,EI .EEnddate as EndDate FROM Data_EMP d Join Emp_Info EI on d.EID=EI.EIDSet set EStatus=0 where EID='" & TempEID & "'"
Shall i write Update query like this and Is there any issues in this update query can any one let me know?
Thanks
View 2 Replies
View Related
Mar 7, 2006
Once a month I will have to run a query to update 2 fields
in one table, from another table.
Say Table1 is my main table to update and Table2 is the
table that it will update from.
Table2 is just a temporary table I will import monthly just
to update Table1.
Both tables have 2 pk/fk (userID and leaveDate).
Table1 has many of the same userID, but all different dates.
Table2 has only one instance of each userID
Example:
Table1
userID leaveDate other1 other2
1 1/1/06 6 14
1 2/1/06 2 12
1 3/1/06 <NULL> <NULL>
2 1/1/06 43 21
2 2/1/06 15 34
2 3/1/06 <NULL> <NULL>
Table2
userID leaveDate other1 other2
1 3/1/06 35 18
2 3/1/06 12 19
So Table 2 should update Table1.other1 AND Table1.other2
where userID AND leaveDate are equal
View 2 Replies
View Related
Jul 10, 2001
customerid lastname firstname emailaddress
14556928 tyler NANCY abc@hotmail.com
14556927 tyler NANCY abc@hotmail.com
I am going to create a mastercustomerid column whose value will be the min(customerid) in the above scenario.
I need a query where I can achieve this
I used the query below to achieve the above results
SELECT a.customerid, lastname, firstname, emailaddress
FROM account.Customer a Join account.Email b
ON a.customerid = b.customerid
WHERE lastname in
(
SELECT lastname
FROM account.Customer c Join account.Email d
ON c.customerid = d.customerid
GROUP BY lastname, firstname, emailaddress
HAVING count(*) >1
AND firstname = a.firstname
AND emailaddress = b.emailaddress
)
ORDER BY lastname, firstname, emailaddress
I need to update 349862 rows with a mastercustomerid . Please help me.
View 4 Replies
View Related
May 25, 2000
I have an update query which updates a field if the contents of 3 other fields in the table matches the result of a Where clause. Is it possible to only update the first matched row in the table rather than all rows that match the Where clause. Forgive if this is simple but I am a newbie to SQL 7.
Regards
Andrew Wall
View 1 Replies
View Related
Oct 26, 1999
I have the following table:
AreaName Population RankNumber
======== ========== ==========
Annerley 200 NULL
Balmoral 50 NULL
Chermside 350 NULL
Is it possible the write an update query that, after ordering the table by Population, it sets RankNumber to 1 for the first row, sets RankNumber to 2 for the second row, and so on??
The resultant table would look like:
AreaName Population RankNumber
======== ========== ==========
Balmoral 50 1
Annerley 200 2
Chermside 350 3
View 3 Replies
View Related
Oct 13, 1999
like so many i am upsizing some databases from access to sql server. how can i get the following access query to work in sql server 7.0
UPDATE dbo_t_Assignments INNER JOIN t_Assignments ON dbo_t_Assignments.AssignID = t_Assignments.AssignID SET dbo_t_Assignments.EmployeeID = [T_ASSIGNMENTS]![EMPLOYEEID], dbo_t_Assignments.DeptID = [T_ASSIGNMENTS]![DEPTID], dbo_t_Assignments.ShiftID = [T_ASSIGNMENTS]![SHIFTID], dbo_t_Assignments.JobClassID = [T_ASSIGNMENTS]![JOBCLASSID], dbo_t_Assignments.Regular = [T_ASSIGNMENTS]![REGULAR], dbo_t_Assignments.CreatedBy = [T_ASSIGNMENTS]![CREATEDBY], dbo_t_Assignments.TimeStampCreate = [T_ASSIGNMENTS]![TIMESTAMPCREATE], dbo_t_Assignments.UpdatedBy = [T_ASSIGNMENTS]![UPDATEDBY], dbo_t_Assignments.TimeStampUpdate = [T_ASSIGNMENTS]![TIMESTAMPUPDATE], dbo_t_Assignments.DateStart = [T_ASSIGNMENTS]![DATESTART], dbo_t_Assignments.DateEnd = [T_ASSIGNMENTS]![DATEEND], dbo_t_Assignments.rEmployeeID = [T_ASSIGNMENTS]![REMPLOYEEID];
thanks
Tony
View 1 Replies
View Related