开发者

sqlcmd script with spaces in filename

开发者 https://www.devze.com 2023-02-05 03:00 出处:网络
I have a simple SQLCMD script that includes some lines like this: /* Load data into Exampletable */ BULK INSERT dbo.Example

I have a simple SQLCMD script that includes some lines like this:

/* Load data into Exampletable */
BULK INSERT dbo.Example
    /* NOTE: I've tried single AND double quotes here. */
    FROM "C:\Example Filepath\test.csv"
    WITH 
    (
            /* skip the first row containing column names */
            FIRSTROW = 2,
            /* specify how fields are separated */
            FIELDTERMINATOR = '|',
            /* specify how lines end */
            ROWTERMINATOR = '\n' 
    )

When I run it on the command line, I get an error like this:

Sqlcmd: 'C:\Example': Invalid filename.

I think that having a space in the path is causing the path to be cut off, but I开发者_如何学C can't figure out a syntax that works. Does anybody have any experience with this?


The error message sounds like sqlcmd cannot find the .sql file.

Try sqlcmd "c:\example filepath\test.sql" from the command prompt.

Strings are quoted with single quotes in TSQL, with double quotes in cmd.


Surround the path with single quotes like:

'C:\Example Filepath\test.csv'
0

精彩评论

暂无评论...
验证码 换一张
取 消