开发者

Building a cache table, database helpers

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 pl开发者_运维百科an 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.


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:

INSERT INTO Table1 (Col1, Col2, Col3)
    SELECT Col1, Col2, Col3
    FROM Tabl2

The second is a SELECT INTO:

SELECT Col1, Col2, Col3
INTO Table2
FROM Table1

I don't know if that helps to answer your question, but hopefully it will put you on the right path.


You can use my SqlCeBulkCopy library, takes DataReader, DataTable or any List object as parameter... http://sqlcebulkcopy.codeplex.com

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜