Start New Discussion within our Software Development Community

Please any one help me...
I want to insert data automatically to the table while installing an application. how can i do this? Can I generate sql script for this???


Regards
Jineesh

Please any one help me...
I want to insert data automatically to the table while installing an application. how can i do this? Can I generate sql script for this???


Regards
Jineesh

It depends on how big is the data you are dealing with. For example few lines can be inserted handy written script.

Few hundred lines can be inserted from script-generated sql script like:

declare @crlf varchar(2)
set @crlf = char(13)+char(10)
select 'insert into tab1 (a,b,c) values (''' +a+''','''+b+''','''+c''');'+crlf;
from tab1
where /* add filter here*/

for 1000+ you can store data into Excel table and import it very simple way (see http://horizon.leadhoster.com/?content=tipstricks topic Fast and simple import data from Excel table into SQL server ) or XML and process data on the server within stored procedure or with XQuery http://blogs.msdn.com/mrorke/ see Dynamic XQuery Expressions.

Finally for 100000+ I would reccommend you distribute whole database file (mdf+ldf) and during installation just unpack it and attach (works perfectly!).

This question has already been answered. Start a new discussion instead.