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.
| Author |
Topic |
|
eem_2055
Yak Posting Veteran
69 Posts |
Posted - 2008-05-19 : 06:06:46
|
Hi guys,please help.I use to copy one column from one database to another database. What query should I use?moreover,How can I convert thiscode000001the result would be code1thanks!  |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2008-05-19 : 06:20:59
|
| 1: INSERT INTO db1.dbo.tablename (Column1) SELECT Column1 FROM db2.dbo.tablename2: SELECT CAST(code AS int)--Lumbago |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-19 : 06:22:54
|
[code]DECLARE @Sample TABLE (Info VARCHAR(20))INSERT @SampleSELECT '000001' UNION ALLSELECT '000020'SELECT Info, REPLACE(LTRIM(REPLACE(Info, '0', ' ')), ' ', '0') AS Peso1, SUBSTRING(Info, PATINDEX('%[^0]%', Info), 8000) AS Peso2FROM @Sample[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-19 : 07:03:45
|
| SELECT Info,info*1FROM @SampleMadhivananFailing to plan is Planning to fail |
 |
|
|
eem_2055
Yak Posting Veteran
69 Posts |
Posted - 2008-05-19 : 07:11:41
|
| how about?code000001the result would be code01 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-19 : 07:18:52
|
[code]DECLARE @Sample TABLE (Info VARCHAR(20))INSERT @SampleSELECT '000001' UNION ALLSELECT '000020'SELECT Info, REPLACE(LTRIM(REPLACE(Info, '0', ' ')), ' ', '0') AS Peso1, SUBSTRING(Info, PATINDEX('%[^0]%', Info) - 1, 8000) AS Peso2FROM @Sample[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|