English 中文(简体)
一栏中包含数的自动栏目数据?
原标题:Switch column data where a column contains a number?
  • 时间:2010-08-19 08:39:12
  •  标签:
  • tsql

我的表格有3列。

id, Company and adress

i 如今发现一只灯泡,挽救了公司-公司和公司在压力充气的SOMETPASS中的堡垒,即纠正了ug,现在试图将数据放在合适的地方。

每一名受胁迫者都有一些,因此,我的猜测是,如果公司栏中有一些的话,最容易的办法是调换压力和公司栏目(如果公司名称中应当有几处,这赢得了很多事情:p)。

如何在TSQL中写这句话?

最佳回答

我不敢肯定,这是在这里做的正确事情,但因为我可以想到应该做的任何其他选择。

Update dbo.MyTable
Set Company = Address,
    Address = Company
Where Company like  %[0-9]% 
问题回答

你们可以尝试:如果公司压力已经包含一些内容的话,就提供简单保护,避免掉头。

insert into COMPANY (NAME, ADDRESS) 
VALUES ( 2 bld d  Italie  ,  CA ) , 
( Take 2  ,  anselmo street 234 ) , 
( Microsoft  ,  1 Microsoft Way Redmond ), 
( lake street 14  ,  Norton ), 
( lake street 17  ,  trendMicro );

SELECT * FROM COMPANY

UPDATE COMPANY set NAME = ADDRESS, ADDRESS = NAME
WHERE NAME like  %[0-9]%  and (ADDRESS not like  %[0-9]% )

SELECT * FROM COMPANY

你们可以注意到,2行得起的电离灯被蒸发。





相关问题
How to write this T-SQL WHERE condition?

I ve got two tables: TableA Col1 Col2 TableB Col3 Col4 I want to join them together: SELECT * from TableA join TableB ON (...) Now, in place of ... I need to write an expression ...

Customer and Order Sql Statement

TSQL query to select all records from Customer that has an Order and also select all records from customer that does not have an Order. The table Customer contains a primary key of CustomerID. The ...

Recommended way of querying multiple Versioned tables

Have a win 2003 box with MSSQL 2005 running on it. There is a database which is populated every morning with new/modified SalesOrder made the previous day. The database has several tables: SalesOrder, ...

update duplicate record

I have a table with the following fields Id Name IsPublic i need to write a sql query that updates IsPublic to false where name has a duplicate. Only one of the duplicates should have IsPublic = ...

Define variable to use with IN operator (T-SQL)

I have a Transact-SQL query that uses the IN operator. Something like this: select * from myTable where myColumn in (1,2,3,4) Is there a way to define a variable to hold the entire list "(1,2,3,4)"? ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...

热门标签