I have written a stored procedure which uses bulk insert to load data from a *.csv file.
It works fine when I mention the physical path.Now I want to use the same stored procedure in a SQL server project.Hence I have to mention the relative path.Is there anyway I can do this?
Thanks in advance.
Your best bet would be to either pass the root in as a parameter to the SP, or have a config table in your DB and set the root path there. Heck, you might as well just pass in the entire fully qualified name of the file if you can.
Related
On one server I have xp_copy_file and the other I don't. I have found that this resides in the XPStar.dll and have found the location of the file.
I use xp_copy_file in a procedure which I have moved to the server which does not have the xp_copy_file extended stored procedure and it of course errors from that part of the script...
Can I copy XPStar.dll from one machine and replace on another to use for Extended Stored Procedures?
Is there an alternative way to do this?
Thanks
Will
Why script generated by SSMS shown in red is different from script stored in system tables. Please notice stored procedure names in query, query result and Object explorer.
i.e.
All these methods are giving me same script
sql_module
object_definition
sp_helptext
However when generated from SSMS, right click -> script as Create or Modify is giving a different script.
How is it possible and generating different scripts.
The answer can be confusing.
The Stored procedure getBudgets4programManager2 was renamed (very likely using sp_rename https://msdn.microsoft.com/en-us/library/ms188351.aspx), so the original definition does not match the new name. BTW. Notice that the definition stored in metadata will always change the DDL command to CREATE in case of issuing an ALTER PROCEDURE statement.
At the same time, SSMS scripting features will not simply get the definition from metadata as it has an object representation of the stored procedure, it will normalize the schema name & object name, and it may also normalize the DDL command accordingly (CREATE/ALTER). Notice that the schema is showing it is normalized (i.e. [dbo]), and that the current name is also normalized.
As for why the metadata definition is not renamed at the same time you rename the object. The answer is not 100% clear, but such change would affect any features in the SQL Server engine that relies on the definition, including using the WITH ENCRYPTION option on ALTER/CREATE PROCEDURE as well as the verification of digital signatures.
As far as I know, other elements in both versions of the scripts should remain intact (comments, blank spaces, etc.).
I hope this information helps.
Is it even possible? I tried to update model from DB where I have my stored procedure, but it still does not help in what I want to get,i.e. call to create procedure in the output sql script.
It appears that it is pretty much easy as one can add code that creates stored procedure in the 'tt' file as it is said here: http://msdn.microsoft.com/en-us/data/gg558520.aspx
I am loading 30 files at a time using a MULTIFLATFILE connection from SSIS into a raw table. These files are constantly coming in and a job loops through to exec the package and pick these up. Some of the files can have bad data every once in a while. I am having trouble when one of the 30 files is bad. I have no way to know which of the files actually failed so I can move it into a Suspect folder, roll the other 29 files back into my Input folder and try again. Can't find any info on the net on this, or in Microsoft's documentation. Any help appreciated. Thanks.
I would rebuild your Connection using the FLATFILE type, then use it within a Foreach Loop Container that sets a Variable to the file name. In the Connection definition, you can use an Expression to set the ConnectionString property to your Variable value.
Then you can use that Variable value to take whatever action you need when your "bad" condition occurs.
Configure the FileNameColumnName property of the Flat File Source component. That will add a column containing the file name.
I want to copy and rename a table in SQL EXPRESS in an mdf database. Which is the best way to do this?
Try a
select * into [newtablename] from [oldtablename]
which will make a copy of your old table with a new name.
You can rename a table using sp_rename. Note the warning (which will also appear when you run the stored proc):
Changing any part of an object name can break scripts and stored procedures.