Я делаю это все время в режиме SQLCMD. Вот пример:
-----------------------------
--Generate State seeds
-----------------------------
-- This is the path and file where you want the scripts to land.
:setvar OutDir "C:\Dev\Sandbox\GenTest\Scripts\"
:setvar OutFile "dbo.State.seed.sql"
SET NOCOUNT ON;
GO
:out $(OutDir)$(OutFile)
SELECT
'INSERT [State] ([StateId], [StateCd], [Description]) VALUES ('
+ CAST( [StateId] AS VARCHAR(2))
+ ', ''' + [StateCd] + ''''
+ ', ''' + [Description] + ''''
+ ');'
FROM [State];
GO --this 'GO' is vital for this to work correctly.
:out stdout
- Graeme