我有一些项目名称可能组合的表,例如基本名称、前缀和后缀 - 但是直接在这些表中搜索并不是很好,因为我每次都必须生成组合,为了修复它,我创建了一个缓存表,其中我计划运行一些 cron 作业来填充它。我必须创建一个填充缓存的脚本,并且使用字符串连接按程序构建 SQL 似乎并不明智。
无论如何,我可以将 SQL 结果集插入到表中吗?无需手动创建实际的 INSERT 语句。
谢谢。
I have a few tables of possible combinations for item names, like base name, prefixes and suffixes - however it isnt very good to search directly in these tables as I have to generate the combinations every time, to fix it I created a Cache table where I plan to run some cron job to fill it up. I have to create a script that populates the cache and it just doesnt seem smart to build the SQL procedurally with string concatenations.
Is there anyway I can insert a SQL result set into a table? Without creating the actualy INSERT statement manually.
Thanks.
发布评论
评论(2)
我不知道是否有任何方法可以通过插入来插入记录,但是您可以通过几种不同的方式插入结果集:
第一种方法是 INSERT INTO SELECT:
第二种方法是 SELECT INTO:
我不不知道这是否有助于回答您的问题,但希望它能让您走上正确的道路。
I don't know if there's any way to insert records with doing an insert, but you can insert a result set in a couple of different ways:
The first method is an INSERT INTO SELECT:
The second is a SELECT INTO:
I don't know if that helps to answer your question, but hopefully it will put you on the right path.
您可以使用我的 SqlCeBulkCopy 库,将 DataReader、DataTable 或任何 List 对象作为参数... http://sqlcebulkcopy.codeplex.com
You can use my SqlCeBulkCopy library, takes DataReader, DataTable or any List object as parameter... http://sqlcebulkcopy.codeplex.com