Executing a sql script via sqlcmd

Hello all

I have a generated script of a database which is 477 mb. When I try to run it on SSMS I have an "insufficient memory to continue the execution of the program" error. After searching around the web I found that I can use sqlcmd to run the script.

When I type
1>SQLCMD -S "FHMDEV1 -d UndNetTest - E -i D:\Script.sql
2>GO

I get a Incorrect Syntax near 'S' error. I can't understand what I'm doing wrong. Can anyone help me?

If you pasted this right, you don't have closing quotes for the server name.

I tried this but still get the same error

1> sqlcmd -S FHMDEV1 -d UndNetTest -E -i D:\Script.sql
2> go
Msg 102, Level 15, State 1, Server FHMDEV1, Line 1
Incorrect syntax near 'S'.

Is the database 477MB or the script?

Oh sorry, it is rather vague there :slight_smile: Script is 477 mb. has schemas and data inside.

Well, my best guess is there's a syntax error in there.

The problem is that for every GO statement in the script it resets the line count. You may have to put PRINT statements in there to isolate it.

Can you post the first 10-20 lines of the script?

Well, this is a generating script of a whole database at the total of 914308 lines

First 20 lines are;

USE [master]
GO
/****** Object: Database [UndnetTest] Script Date: 05/28/2015 10:09:31 ******/
CREATE DATABASE [UndnetTest] ON PRIMARY
( NAME = N'eBelge', FILENAME = N'C:\SQLDATA\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\UndnetTest.mdf' , SIZE = 101056KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ),
FILEGROUP [TRANSACTIONS]
( NAME = N'eBelgeTransactions', FILENAME = N'C:\SQLDATA\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\UndnetTest_1.ndf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'eBelge_log', FILENAME = N'C:\SQLDATA\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\UndnetTest_2.ldf' , SIZE = 1536KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [UndnetTest] SET COMPATIBILITY_LEVEL = 90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [UndnetTest].[dbo].[sp_fulltext_database] @action = 'disable'
end
GO
ALTER DATABASE [UndnetTest] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [UndnetTest] SET ANSI_NULLS OFF

I'm not sure what to tell you. My only suggestion is PRINT statements to isolate the error. Or maybe you can break it into pieces.

It may be you'll find some odd quoting in some string data.

Your SqlCmd is trying to connect to the database UndnetTest, yet you are creating the database in the script. The error message does not appear to be related to that, even if you fix the current error, you will get another error message. If the UndnetTest database already exists, connection will succeed, but then it will fail on your create statement. If that database does not exist, your connection attempt would fail.