I have to create a procedure to fetch few values from database but I don't have access to write procedure on that server. So, I wanted to create that procedure on another server and fetch the values. I wanted to know if is it possible to create procedure to fetch values from any other server?.
Assume that in the target database you have read only access to fetch data. In that case you could
Create a database link from the database where you would be creating
stored procedure.
Read the data from target database using the database link (db link).
Once you are able to get the data from target database you could do any manipulation you would want to. For creating database link in sql server you could check this
Related
Greetings for the day!!
My requirement is we have Stored procedures created with one ID in database now i need to copy the script of Stored procedure created with existing ID and rename it with New ID.
Is there any SQL server Query to do above process.
PS:i am aware about sp_helptext. looking for SQL script.
Thank you.
I'm currently using SQL Server 2014. In a stored procedure, I'm inserting data into a local temporary table (#TestTemporaryTable). I want to see the logs of data insertion into temp table, how can I fetch it from tempdb? And also, I want to know for how long these logs will exist?
You can examine the log records with the undocumented fn_dblog
eg
SELECT * FROM tempdb.sys.fn_dblog(NULL, NULL)
I have a stored procedure that updates a table taking the data from a source and I want to modify the stored procedure so that it takes data from a table in an external database and updates a table in the original server. Can this be achieved and how ?
See linked servers, it's treated just a synonym: http://msdn.microsoft.com/en-us/library/ff772782.aspx
Actually synonyms are treated like linked servers..
I need the "create table... " statement for a particular table and stored procedure to recreate them in another database. Forget the backup and restore. I have to do it in vb6. Its the same thing you get when you copy the Table And paste it in query analyzer. Its sql server 2000
Edit: Now I Know it can be asked as 'How To Script Entire Database Through VB6'.
Take a look at this StackOverlow post which talks about the same. Although it is not VB6-specific, you should be able to apply this solution without a problem.
Essentially you create a stored procedure that will generate the CREATE TABLE statement for the given table. The stored procedure will examine the sysobjects table to build the SQL.
Your VB6 application can run the stored procedure on server 'A' fetching the CREATE TABLE SQL. Then connect to server 'B' and run that SQL to create the table on the other server.
Can I get the whole query which I used for creating a table, like we have sp_helptext to get the query of a stored procedure.
sp_helptext 'procedure_name'
Is there anything like this available for create table also in SQL server express?
I want to view the whole query which I wrote for creating a particular table and not the table structure.
Like if a deleted a table, and again want to create it, then I would have to type the whole query again, so I want a way through which I don't have to write the whole query again, like in mysql there is an option such as SHOW, which shows the table query?
In SQL Server Management Studio you can right-click on a table in the Object Explorer window and choose to generate the CREATE script into a new query window or put it in the clipboard or save it in a file.
Try sp_columns or sp_help. But this will not give you the CREATE TABLE text, you have to create this text for yourself.
You can also have a look at Catalog Stored Procedures