Click here to Skip to main content
11,790,613 members (61,030 online)
Rate this: bad
Please Sign up or sign in to vote.
Dear Team,
i have file .sql and they content upto 150 mb file size when i execute in SQL Server then get file size heavy and execute error.

Have any other way restore .sql file in database like .bak file .

Rohit Kumar Singh
Posted 18-Feb-13 18:53pm
ssd_coolguy at 19-Feb-13 4:44am
can you tell us.. what exactly that sql file contain..?
is there any query?
rohit_singhk at 19-Feb-13 5:31am
DataBase Script with Data Contain
rohit_singhk at 19-Feb-13 5:47am
Dear File extension is .sql not .bak file got it?
File Path like :
E:\New folder\DCE_Script_With_Data.sql

Again i told not like .bak if it is .bak file i easily restore?

And .SQL extension direct open in new query window if file size not more than 150 MB.

rohit_singhk at 19-Feb-13 6:38am
CALL sqlcmd -w 125 -S %ROHIT-PC% -d %DCORE_19022013% -U%sa% -P%boss% -l30 -b -I -i "E:\Dcore_GGN_Even_20April2012_1013hrs.sql"

Like that
rohit_singhk at 19-Feb-13 6:40am
Server Name : ROHIT-PC
DataBase : DCORE_19022013
User ID : Sa
Password : boss
File Sources Path : E:\Dcore_GGN_Even_20April2012_1013hrs.sql

Now what is query direct exceutable
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Try this code....
DECLARE @SqlString VARCHAR(1000)
SELECT @SqlString = 'BACKUP DATABASE eUnderwrite TO DISK = ''path'+ REPLACE(CONVERT(VARCHAR(15),GETDATE(),106),' ','_')++'_'+REPLACE(CONVERT(VARCHAR(25),GETDATE(),108),':','_')+'.bak'' WITH INIT'
PRINT @SqlString
EXEC (@SqlString)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can try SqlCmd utility. Code like
CALL sqlcmd -w 125 -S %Server% -d %Database% -U%uid% -P%pwd% -l30 -b -I -i  "dbscript.sql"

In details you can check SqlCmd Utility

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 1,154
1 Maciej Los 825
2 KrunalRohit 686
3 ppolymorphe 660
4 CPallini 621

Advertise | Privacy | Mobile
Web02 | 2.8.1509028.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100