Click here to Skip to main content
15,901,035 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Server 2005 query execution time Pin
Wendelius13-Jan-09 21:05
mentorWendelius13-Jan-09 21:05 
Questionsql group by and minimum Pin
swjam13-Jan-09 15:41
swjam13-Jan-09 15:41 
AnswerRe: sql group by and minimum Pin
Reza Raad13-Jan-09 17:26
Reza Raad13-Jan-09 17:26 
AnswerRe: sql group by and minimum Pin
RyanEK13-Jan-09 17:29
RyanEK13-Jan-09 17:29 
QuestionStored Procedure for Dynamic Table Creation Pin
Sunset Towers13-Jan-09 10:49
Sunset Towers13-Jan-09 10:49 
AnswerRe: Stored Procedure for Dynamic Table Creation Pin
Wendelius13-Jan-09 11:06
mentorWendelius13-Jan-09 11:06 
GeneralRe: Stored Procedure for Dynamic Table Creation Pin
Sunset Towers13-Jan-09 11:55
Sunset Towers13-Jan-09 11:55 
GeneralRe: Stored Procedure for Dynamic Table Creation Pin
Wendelius13-Jan-09 21:50
mentorWendelius13-Jan-09 21:50 
I think your solution works fine even if you do the table first and then insert the rows. But to answer your questions:

Sunset Towers wrote:
the information that is being inserted is being retrieved from a CSV file


If the CSV file can be opened by SQL Server (it resides on a disk that SQL Server can see), you could use SELECT INTO ... OPENROWSET combination. In that case you would give reasonable names to the selected columns in the select statement and the table will be created at the same time as it's populated. For more info, see: OPENROWSET[^].

Sunset Towers wrote:
I'm not sure how I could pass that table directly into the SQL Server to do the SELECT INTO


If you mean the table where the data goes, you don't have to, since it's created on-the-fly. If you mean the datatable, there's an article I wrote about this: How to pass multiple records to a Stored Procedure[^].

Sunset Towers wrote:
Also there is a need to do some pre-processing on each record before it's inserted


Perhaps another option could be that you first insert the data to the table and instead of pre-processing, you load the data 'as-is' and modify it in the table after it's populated (especially if the table you create is used just for loading). Don't know if this is possible or reasonable in your case.


Anyhow, you can create the table using stored procedure and then fill it from client side and use procedure to reduce the number of roundtrips if you want.

By the way, did the first reply resolve your table creation problem?

The need to optimize rises from a bad design.My articles[^]

GeneralRe: Stored Procedure for Dynamic Table Creation Pin
Mycroft Holmes14-Jan-09 0:08
professionalMycroft Holmes14-Jan-09 0:08 
QuestionSQL Server 2008 Management Studio Installation Pin
Grapes-R-Fun13-Jan-09 5:57
Grapes-R-Fun13-Jan-09 5:57 
AnswerRe: SQL Server 2008 Management Studio Installation Pin
Wendelius13-Jan-09 6:22
mentorWendelius13-Jan-09 6:22 
GeneralRe: SQL Server 2008 Management Studio Installation Pin
Grapes-R-Fun13-Jan-09 6:41
Grapes-R-Fun13-Jan-09 6:41 
GeneralRe: SQL Server 2008 Management Studio Installation Pin
Wendelius13-Jan-09 7:26
mentorWendelius13-Jan-09 7:26 
AnswerRe: SQL Server 2008 Management Studio Installation Pin
Reza Raad13-Jan-09 17:40
Reza Raad13-Jan-09 17:40 
Questiontry catch in T-SQL Pin
George_George12-Jan-09 21:59
George_George12-Jan-09 21:59 
AnswerRe: try catch in T-SQL Pin
Wendelius12-Jan-09 22:16
mentorWendelius12-Jan-09 22:16 
GeneralRe: try catch in T-SQL Pin
George_George13-Jan-09 0:58
George_George13-Jan-09 0:58 
AnswerRe: try catch in T-SQL Pin
Hamid_RT15-Jan-09 2:28
Hamid_RT15-Jan-09 2:28 
GeneralRe: try catch in T-SQL Pin
George_George15-Jan-09 18:29
George_George15-Jan-09 18:29 
QuestionGETUTCDATE and GETDATE Pin
George_George12-Jan-09 21:14
George_George12-Jan-09 21:14 
AnswerRe: GETUTCDATE and GETDATE Pin
Reza Raad12-Jan-09 21:44
Reza Raad12-Jan-09 21:44 
GeneralRe: GETUTCDATE and GETDATE Pin
George_George13-Jan-09 0:31
George_George13-Jan-09 0:31 
GeneralRe: GETUTCDATE and GETDATE Pin
Reza Raad13-Jan-09 2:53
Reza Raad13-Jan-09 2:53 
GeneralRe: GETUTCDATE and GETDATE Pin
George_George14-Jan-09 2:10
George_George14-Jan-09 2:10 
AnswerRe: GETUTCDATE and GETDATE Pin
Wendelius12-Jan-09 21:45
mentorWendelius12-Jan-09 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.