English 中文(简体)
使用MSQ 我需要选择一个桌子,同时把整批地铺上! 是否能够做到这一点?
原标题:using MS SQL I need to select into a table while casting a whole load of strings to ints! can it be done?

基本上,我是新信息技术的伪装,老的gu子给我留下了正确的东西! 我们有一个MS-Access银行,负责提供在线调查问卷的答案,该行有大约45 000份记录,每一份调查问卷有220个问题。 旧的伪称,他明智地决定将对调查表问题的回答作为案文,尽管答案是零到五。

无论如何,我们现在需要在调查表中增加新的问题,涉及240个问题。 255个现场访问限制和30个书目数据栏也储存在这个数据库中,这意味着需要分立行。

因此,我已设法将所有生物信息迅速输入新的表格,其中:

SELECT id,[all bio column names] INTO resultsBioData FROM results;

这确实造成了许多问题,因为问题并非产生任何结果,而对于问题数据来说,我想将其全部转换为愤怒,此时我已经:

SELECT id,CInt(q1) AS nq1.......CInt(q220) AS nq220 INTO resultsItemData FROM results;

这似乎对大约400份记录进行了罚款,但后来只是停止,我认为这可能是因为它打上了它不得不改换为愤怒的某种东西,以便开始,我写了一个小的 j方案,删除了220份复信中任何1,1,3,4或5份的任何记录,它仍然提供约400份(无论同一记录是什么)。

没有人会提出想法? 我现在在我的试验制度上这样做,真的要等一些强者,然后再把它交给我们的生活系统!

解决长期瘫痪的问题,但我是谁去做!

最佳回答

I m unsure whether you re talking about doing the data transformation in Access or SQL Server. Either way, since you re redesigning the schema, now is the time to consider whether you really want resultsItemData table to include 200+ fields, from nq1 through nq220 (or ultimately nq240). And any future question additions would require changing the table structure again.

umb的统治是“col花钱;row花是廉价的”。 无论表格是进入还是服务器,都适用。

考虑每id/quest合一行。

id q_number answer
 1      nq1      3
 1      nq2      1

我不理解,你目前的做法为什么会落到400头。 我甚至对此感到担忧,但直到你确定桌上的最佳设计。

Edit:由于你坚持你所描述的方针,我想知道,这是否可以用“申请”的质问,而不是“表格”处理。 创造成果 项目Data表的结构和附着一个将qx值改为数字的质子。

INSERT INTO resultsItemData (id, nq1, nq2, ... nq220)
SELECT id, CInt(q1), CInt(q2), ... CInt(q220) FROM results;
问题回答

寻找这一解决办法:

select * into #tmp from bad_table
truncate table bad_table
alter bad_table alter column silly_column int
insert bad_table
select cast(silly_column as int), other_columns
from #tmp
drop table #tmp

参考: 1. 从瓦尔查到t的分栏变更类型

仅仅写了一部小 j方案,最终创建了新桌子,逐个记录,将田地排入ger,需要大约一小时半的时间做整个事,尽管如此,在生活系统做这项工作时,仍会找到更好的解决办法。





相关问题
SQL SubQuery getting particular column

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 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

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

PHP array callback functions for cleaning output

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 ...

OracleParameter and DBNull.Value

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 ...

Running numbers in SQL

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 ...

How to get SQL queries for each user where env is production

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: ...

热门标签