我在加15,000条目表中有一个栏目——我想重复整个栏,同时保留其价值和名称不同。 I m 采用微软服务器管理演播室。
我怎么办?
感谢。
我在加15,000条目表中有一个栏目——我想重复整个栏,同时保留其价值和名称不同。 I m 采用微软服务器管理演播室。
我怎么办?
感谢。
根据你对原始问题的评论,我的理解是,你试图在哥伦保留25个不同的价值观。 在将新哥伦布改成10种不同价值的同时。 我认为,你可以做以下守则。 修改我的数据类型,以适应你的情况。
declare @ColumnAConverter table (
ColumnA nvarchar(max),
ColumnB nvarchar(max)
)
insert into @ColumnAConverter
(ColumnA, ColumnB)
select A , 1
union all
select B , 1
union all
select C , 2
/* ...continue for all 25 values in the original ColumnA */
update yt
set ColumnB = c.ColumnB
from YourTable yt
inner join @ColumnAConverter c
on yt.ColumnA = c.ColumnA
1. 设立一个新的栏目,然后设立新的栏目。
UPDATE YourTable
SET NewColumn = OldColumn
ALTER TABLE Boo
Add [NewColumnName] [datetype]
GO
Update Boo
Set NewColumnName = OldColumn
GO
为什么没有计算一栏?
ALTER TABLE Foo ADD NewColumnName AS OldColumnName
您希望将一些内容改成案文,例如:
ALTER TABLE Foo ADD NewColumnName AS RIGHT( ABC000000 + CAST(OldColumnName AS varchar(10)), 10)
1 ABC0000001
2 ABC0000002
3 ABC0000003
4 ABC0000004
5 ABC0000005
INSERT into tbl (colname,fld1,fld2,fld3,fld4)
SELECT NEWNAME as colname, fld1,fld2,fld3,fld4
FROM tbl where uniqid=[SOMEVAL]
BEGIN TRANSACTION
ALTER TABLE myTable
Add newcol NVARCHAR(8)
GO
UPDATE myTable
Set newcol = oldcol
GO
COMMIT TRANSACTION
将NVARCHAR(8)改为现列数据类型。
I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...
I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2
I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...
we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...
I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...
I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...