Jump to content

String Concatenation


Recommended Posts

Hi Guys,

I'm trying to perform an automated bulk insert of a file each day, which contains the date in the file name. If I enter the file name it runs fine so I think it is just the formatting of the code/string but I am struggling to find what it can be (if at all possible). The code extract is

BULK Insert HDD_Info_temp 
from 'c:\support\bulkimport\HDD-REPORT-SUCCESS_' + (select convert(varchar,(CAST(CONVERT(varchar, GetDate(), 105) AS DateTime)),105)) + '-09-17-00.csv'
with
(fieldterminator = ',',rowterminator ='\n')
go

the error I get is

Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '+'.
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '+'.

if I run the statement

select ('c:\support\bulkimport\HDD-REPORT-SUCCESS_' + (select convert(varchar,(CAST(CONVERT(varchar, GetDate(), 105) AS DateTime)),105)) + '-09-17-00.csv')

I get the required string

Any idea's or is it not possible via TSQL

Taggs

Link to comment
Share on other sites


Since I do not know this langauge so this is just a guess. I dont know if it matter but the working code

has a select ( at the beggining. The non working does not have select ( at the beggining.

Not working code

from 'c:\support\bulkimport\HDD-REPORT-SUCCESS_'

Working Code

select ('c:\support\bulkimport\HDD-REPORT-SUCCESS_'

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...