Stored Procedure `sp_rename` missing in my edition of SQL Server. How can I get it? - sql-server-express

I am using the Visual Studio C# Express edition and it comes with SQL Server for Database. I need the stored procedure sp_rename so that I can call it in my software to change specified table names.
Is there any way that I can import it from somewhere or get it by chance, because I notice that SQL Server in Visual Studio is limited and does not have the predefined stored procedure like the full version of SQL Server.
Is there any way to import certain stored procedures into my SQL Server for Visual Studio C# Express Edition?
I can run stored procedures, I just do not have the ones you usually get when you buy the complete SQL Server.
The following is my code. It will change the name of the database.
SqlConnection sqlConnectionCmdString = new SqlConnection(#"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Rick\Documents\Visual Studio 2010\Projects\Server\database\ClientRegit.mdf;Integrated Security=True;User Instance=True");
string renameCommand = "EXEC sp_rename 'NetworkAccount' , 'oldhires'";
SqlCommand sqlRenameCommand = new SqlCommand(renameCommand, sqlConnectionCmdString);
sqlConnectionCmdString.Open();
sqlRenameCommand.ExecuteNonQuery();
sqlConnectionCmdString.Close();

sql server express contains full set of standard/basic stored procedures, including sp_rename
most likely you mistyped procedure name or have problems with permissions

Related

How can I make an SQL Server 2008 procedure get data from SQL Server Compact?

How can I transfer a SQL Server Compact database to SQL Server 2008 by using
a SQL Server 2008 procedure?
Yes, you can create a SQLCLR procedure using the SQL Server Compact OLEDB provider. I have some sample code here: http://erikej.blogspot.dk/2008/10/accessing-sql-compact-from-sql-server.html
If you want to do a one off transfer from SQL Server Compact to SQL Server 2008, you can use my ExportSqlCe command line to in combination with sqlcmd to transfer the entire database

Moving data from SQL Server 2008 to remote SQL Server 2000, using sqlcmd

The setup:
I have two different machines, one with MS SQL Server 2008 which is my main machine and a secondary with MS SQL Server 2000. Newly generated data are stored in a specific table on the main server(2008).
The problem:
My main machine has limited storage, whereas my secondary one with the older SQL version(2000), doesn't have such kind of limitations.
A possible solution:
At least as a temporary solution, i could try to move some data, on a daily schedule, from the main machine to the secondary, using sqlcmd, run by a Windows Task Scheduler.
The largest portion of my data are stored on a single table so the idea is to "cut" them from the table on the main server and append them on a "backup/depot/storage" table on my secondary server.
What i have tried so far:
So far, i haven't been able to simultaneously connect to both servers from the main one, at least using sqlcmd. Is there a limitation for the sqlcmd to the connections it can create simultaneously?
Other possible ways:
Is there a suggested practice for that case? Would it be a good idea to write a vbs script to export from the main server and import to the secondary?
All corrections and suggestions are welcome. And thanks for your time.
First, link the servers. From the server you want to INSERT into, run this SQL (using any tool you want to run SQL with... SQL Server Management Studio or SQLCMD or OSQL or whatever):
EXEC sp_addlinkedServer N'remoteSqlServer\Instance', N'SQL Server'
EXEC sp_addlinkedsrvlogin #rmtsrvname = N'remoteSqlServer\Instance', #useself = 'FALSE', #rmtuser = N'user', #rmtpassword = N'password'
Replace "remoteSqlServer\Instance" with the actual host-name\instance of the SQL Server you want to copy data FROM. Also replace the "user" and "password" with appropriate login credentials to that server.
After that is done, you can execute SQL like the following against this server (from anywhere, including SQLCMD):
INSERT INTO [LocalTable]
SELECT * FROM [remoteSqlServer\Instance].[DatabaseName].[schema].[TableName]
Again, this is just an example... you'd replace all those values with values appropriate to your source and destination databases (everything in the square brackets). For instance, it might look something like this:
INSERT INTO [HistoricalData]
SELECT * FROM [DBServer\SQL2008].[ProductionDatabase].[dbo].[CurrentData]
I hope this helps.

How to export SQL Server 2005 tables to SQL Server Compact database

I don't know if this is a newbie question or not, I want to export some tables from "full" SQL Server 2005 database to a SQL Server Compact Edition database through a CLR stored procedure.
I know it is possible through SSIS.
This article shows how to migrate between sql server and sql server compact using SQL Server Compact Toolbox. so you can use the sql server compact script generated from your database to create CLR stored procdure

SQL Server 2005 install stored procedure

I'm trying to install the stored procedure WhoIsActive, but have no clue where to put it.
I thought it was supposed to go in the Bin folder but I believe it's only for DLLs. How do you install a stored procedure in SQL Server 2005?
I would like to call it using
Exec dbo.sp_WhoIsActive
since it has some parameters that I can use with it
How do you install a SP in SQL 2005?
You usually execute it within the query window.
That would invovle opening the stored procedure file (.sql) or copy / pasting it in, then pressing execute (or F5).
You might want to take a look at this article, and scripting stored procedures.

Where does SQL Server store the DTS packages?

I have created a few DTS packages and saved them on the server. where I can edit these DTS packages on the server?
you should connect to integration services...
and then in the MSDB folder or in the FileSystem folder, it depends how did you save them
As you probably know, DTS was deprecated and was replaced by SSIS in SQL Server 2005. It IS possible to edit and run DTS packages in SQL Server 2005 however, by installing the “Feature Pack for Microsoft SQL Server 2005”. Particular components that you should look at are “Microsoft SQL Server 2000 DTS Designer Components” for editing and “Microsoft SQL Server 2005 Backward Compatibility Components” for the runtime.
This allows you to upgrade from SQL Server 2000 to SQL Server 2005 and your old DTS packages will still run. This leaves you time to upgrade them to SSIS.
When you use the Import/Export wizard you are given an option, at the end of the wizard, to save the SSIS package into the database.
The wizard saves the package in the msdb database in the
sysssispackages table. This option does not save the package to the
SSIS Catalog database (SSISDB).
The raw payload of a DTS package should give results from this:
SELECT * FROM msdb.dbo.sysdtspackages WHERE name = 'MyPackageName'
Or this:
exec msdb..sp_get_dtspackage #name = N'PackageName', #id = 'PACKAGE_GUID', #versionid = 'VERSION_GUID'
--you can get PACKAGE_GUID from going to Package/Properties from DTS Designer
--you can get VERSION_GUID from Package/Properties from DTS Designer
The payload is in the packagedata field. However it is in binary format so there is not much manipulation that can be done with the field.
This technically answers the question from the perspective of the physical location.