Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
steelkilt
Constraint Violating Yak Guru
255 Posts |
Posted - 2004-09-03 : 15:25:18
|
| Hi, I'm trying to pass a file name (chosen from and ASP page, listbox) to a dynamic sql SPROC. Most of the path is hard coded except for the filename value. I'm having syntax problems. anyone know proper syntax in this case? thxSELECT @SQL = @SQL +' \\servername\sharename\' + '''' + @FileChoice + '''' FROM 'etc... |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-09-03 : 15:30:23
|
| How is @SQL is going to look? Do you want single quotes around the path?SELECT @SQL = @SQL + '''\\servername\sharename\''' + ...Tara |
 |
|
|
steelkilt
Constraint Violating Yak Guru
255 Posts |
Posted - 2004-09-03 : 16:07:48
|
| ok, here's more. the filename is being passed, but the system says it cannot find the file, so my syntax must still be wrong. The error is:Could not bulk insert. File '\\servername\sharename\'filename.txt' does not exist.My code:SELECT @SQL = 'BULK INSERT new_table'SELECT @SQL = @SQL + ' FROM ' SELECT @SQL = @SQL + '''\\servername\sharename\''' + '''' + @FileChoice + '''' + ' WITH (FIRSTROW=2, LASTROW=385, KEEPNULLS) ' |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-09-03 : 16:12:50
|
| Instead of executing the string, PRINT it out to see if the string was built correctly. So instead of EXEC (@SQL), run PRINT @SQL. Then copy that command (the output of the PRINT statement) into a new window and run it.Tara |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-03 : 16:14:22
|
| you don't need single quotes around filename.SELECT @SQL = 'BULK INSERT new_table'SELECT @SQL = @SQL + ' FROM ' SELECT @SQL = @SQL + '''\\servername\sharename\' + @FileChoice + ''' WITH (FIRSTROW=2, LASTROW=385, KEEPNULLS) 'Go with the flow & have fun! Else fight the flow :) |
 |
|
|
|
|
|