views:

232

answers:

2

I need: Plain SQL that I can run without modification with sqlcmd.exe to insert testdata into testdatabase.

I have: Service calls and entities to generate the insert operations with NHibernate.

Not working solution: Log output to text-file. NHibernate generates parameterized sql but logs them in a format not runnable by sqlcmd.exe.

Is there any way to force NHibernate to generate sql without parameters?

Or is there any better solutions to the problem?

A: 

You could record a transaction log, the SQL Server Profiler is providing something like this.


In our application, we wrote factories in C# which generate the entities. We don't have SQL scripts to create testdata. An executer (.exe) picks up assemblies, creates the entities and stores them to the db. This way we don't have to maintain scripts. The factories are compile-time-safe.

Stefan Steinegger
A: 

depending on your schema, it may be easier to just generate INSERTs from the actual database, try using a utility like:

Procedure to script your data (to generate INSERT statements from the existing data)

KM