Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update query

Author  Topic 

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-08-27 : 09:45:23
I have a update query i'm working on how do i get - and commas in the query. For example I want my data to be displayed like such:
blue-Redford, MI to red-Garden City, MI

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-27 : 09:53:02
UPDATE Table1
SET Col1 = 'blue-Redford, MI to red-Garden City, MI'


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-08-27 : 10:01:58
here's the code i have

UPDATE [address]
SET [address].[Pair] = RTrim([Name]+[City Name]+[State]) + ' to ' + RTrim([Name]+[City Name],[State])
FROM [address]
WHERE ((([address].[Pair]) IS NULL
OR ([address].[Pair]) LIKE ''));

I'm trying to get it to update the column pair with Name-City Name, State to Name-City Name, State
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-08-27 : 10:09:59
Why would you like to have "A B C to A B C"?
Are you sure want to travel from one place to same place?
UPDATE	[Address]
SET Pair = RTRIM(LTRIM(Name)) + '-' + RTRIM(LTRIM([City Name])) + ', ' + RTRIM(LTRIM([State]))
+ ' to '
+ RTRIM(LTRIM(Name)) + '-' + RTRIM(LTRIM([City Name])) + ', ' + RTRIM(LTRIM([State]))
WHERE Pair IS NULL
OR Pair = ''



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-08-27 : 11:11:46
Thanks it worked
Go to Top of Page
   

- Advertisement -