SQL Server 2008 :: Automatically Execute Script Once Database Has Been Attached
Jul 29, 2015
our clients have the flexibility to detach and attach databases (I know there are a lot of considerations around this but there is now way of changing it), once they attach a database we need to run some code to update a bunch of values in the database.
Other than creating a SQL Agent job are there any other options available to automatically execute a script once the database has been attached?
View 1 Replies
ADVERTISEMENT
Feb 19, 2015
I have a database which contains a stored procedure. The stored procedure contains an update script to a different database. The user group have access to the database that stores the stored procedure but do not have update rights to the database that contains the data that is being updated.
Therefore, every time the user group executes the stored procedure it fails because the security permissions do not propagate to the next database.
Is there anything I can do to get around this without grant dbo permissions to the whole user group.
View 2 Replies
View Related
Jul 17, 2015
I've been struggling with this issue,
1) Test--FolderName (This Test folder name should use as a database name for below sub folders)
a)Create--Sub Foldername
i)create.sql
b)Alter---Sub FolderName
i)Alter.sql
c)Insert---Sub FolderName
i)Insert.sql
[Code] .....
The scripts need to be run in order. So script one needs to run first folder in that sub folders after that next second folders etc..
Is there a way to create a bat file that automatically runs all these scripts, in order against, the databases they need to?
The databases that they need to run against have the name of the database at the beginning of the name of the folder.
View 0 Replies
View Related
Apr 8, 2007
Hi all (newbie @ asp.net)(oldie @ ASP 3)What is the purpose of using an attached MDF database files in the App_Data folder on a web site as to importing it into the SQL server directly or creating it on the SQL server. Does a mdf database attached file purely use the SQL server as a connection interface.Is it something similiar to DSN(ODBC) Connections for ms access databases.
View 2 Replies
View Related
Feb 4, 2015
I need to load the latest csv files from file server , The files are placed in a folder called -
Posted 02022015- --> csv files .
I am able to copy the csv files from filserver using bulk insert (manually) , giving the file location
I am having difficulty picking up the latest folder which is posted on the server and import it into database using a stored proc .
View 2 Replies
View Related
May 27, 2007
Hi allI have a question concerning sql database mdf files. In the old days I would user a ms access database. This file would be stored with the actual web files and would utilise a dsn connection. I have noted when designing with vwd 2005 express it allows you to use 2 methods of creating a mdf database. You can either create it as an attachment mdf or you can create it directly using sql manager. My question is, if you create the mdf database as an attachement file can you store it in the same manner as if you where using a ms access database, meaning can you store it with the web site's files so it uses the file storage allocated size and then create a connection similar to a dsn (but for sql) to the isp's sql engine or does it have to be uploaded to the isp' s sql server.The reason for this question is some of my customers do not want to pay the extra cost to have an sql allocation, however I do not want to go back to using old asp methods to create advanced sites as I prefer using stored procedures. Any help will be appreciated
View 4 Replies
View Related
Feb 13, 2015
I have a report that is scheduled to run a once a week. This works fine. But now I would like this report to be saved as an Excel file automatically when it runs. how / where do I do this?
View 0 Replies
View Related
Dec 25, 2007
Hi every body.
As you can see in the title I would like to import my tables from the data base which is in the SQL Server, to an mdf file which can be attached to the project.Can some one give an indice please?
View 3 Replies
View Related
Apr 4, 2015
I am working towards automating the process of testing our backups. For the meantime, I do it all manually - I copy the backup files (full + transaction logs) to our test server and then run the restore script. Once database restored I run the DBCC CheckDB. The results of checkdb I manually upload to our Sharepoint portal as proof that the backup file is intact with no errors.
here are some ideas I have but have not yet tested:
Create a maintenance plan with each 3 jobs:
--> Powershell script to copy the files from Prod server to Test server - add this scrip to Job1
--> Powershell script to restore databases files - add this script to Job2
--> Run the DBCC in powershell (yet to find if possible in PS) - add this script to Job3
I would like to use seperate jobs as to get a report on the duration and status of each job
Would also like to get the results of the DBCC Checkdb as proof that no errors were found for upload to our Sharepoint portal. Dont know if possible via the job.
View 8 Replies
View Related
Jun 17, 2015
A common partitioning scenario is when the partition column has the same value for every record in the partition, as opposed to a range of values. Am I the only person who wonders why there isn't an option to automatically partition a table based on the unique values of the partition column? Instead of defining a partition function with constants, you ought to be able to just give it the column and be done. This would be particularly valuable for tables partitioned on a weekly or monthly date; when new data is added it could simply create a new partition if one doesn't already exist.
View 4 Replies
View Related
Apr 8, 2015
I have separate scripts for Creation of Tables, Stored Procedures, Views, Triggers in different .sql files.
I have to execute thses scripts in batch in different servers and different databases without opening SSMS.
All .sql files to be executed in single command.
View 3 Replies
View Related
Dec 13, 2006
I don't know if this is a newbie question or not, I want SQL Server to automatically execute a stored procedure at the first of each month, how can I do this ?
Regards,
AJ
Be nice to nerds. Chances are you'll end up working for one. (Bill Gates)
View 1 Replies
View Related
Oct 7, 2013
I am search for coding criteria I need create a stored procedure with execute as and along with encryption. How can I use the same ? My main motive is to create proc with execute as a user also at the same time I need to encrypt the same from other users seeing the code.
The below query is getting errors:
Create procedure testproc
with execute as 'user' and with encryption
as truncate table some table
View 3 Replies
View Related
Mar 3, 2015
I have built the following query in SSMS, when I add it to an Execute SQL Task in SSIS. I get this error -
"[Execute SQL Task] Error: Executing the query "SELECT @columnz = COALESCE(@columnz + ',[' + times..." failed with the following error:
"Must declare the scalar variable "@columnz".". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly."
Query:
use design
drop table tmpNCPCNCDownstreamMaxUtilization3wks
select node, max(utilization) as max_Utilization, DATE
into tmpNCPCNCDownstreamMaxUtilization3wks
from stage_ncpcncdownstream_temporal
WHERE Date BETWEEN DATEADD(day, -20, GETDATE()) AND GETDATE()
[code]....
View 1 Replies
View Related
Mar 5, 2015
I have a column in a table, which have the stored procedure name stored in each row. Now, I need to execute each SP in the table dynamically. I'm trying to construct a SQL but not able to fire them!!
DECLARE @sql VARCHAR(MAX)
SELECT @sql = STUFF((SELECT '; GO EXEC ' + StoredProcedureName + '' FROM MyTable FOR XML PATH ('')),1,5,'')
print @sql
EXEC sp_executesql @sql
View 2 Replies
View Related
Jun 19, 2015
I have a periodic backup task, and when I need a development copy on which to test code, I restore my most recent backup to a different name, switch the ODBC link to that name on my development machine and have a current copy of the database to play with.
I've been doing this for years, and it works great. Just now I did it, and suddenly my development machine is unable to run any stored procedures that have the 'Execute as owner' clause in their definition. I'm using domain accounts, my personal account is the owner of the database, and everything works on the production copy, which is in the same instance on the same machine.
The test copy is identical to the production copy, which continues to work fine - it was just created using by restoring the backup of the production copy, but I can't run anything with this clause. As soon as I delete the 'Execute as owner' line, the procedure is suddenly available. If I put it back, I'm locked out again.
The error message is: The server principal “sa” is not able to access the database “WhateverDB” under the current security context
View 5 Replies
View Related
May 11, 2015
I have create a batch file to execute a stored proc to import data.
When I run it from the server (Remote Desktop) it works fine, but if I share the folder and try to run it from my pc, it doesn't do anything. I don't get an error, it just doesn't do anything. My windows user has admin rights in SQL. Why is it not executing from my PC?
View 9 Replies
View Related
Mar 1, 2006
how can i attached MDF file only without .log and data only
View 6 Replies
View Related
Jan 10, 2006
Hi,
I was trying to figure out how to back up a database that has been attached to the SQL Express instance. I found on the web this tutorial and tried to use it, however it seems like it cannot find the database. The DB is attached by the web application using AttachDbFilename in the connectionstring.
http://www.sqldbatips.com/showarticle.asp?ID=27
Any ideas?
thanks
View 5 Replies
View Related
Nov 11, 2007
Hello all,
I'm using SQL 2005 Express edition. I'm currently connecting to the database file directrly (from ASP.NET) and that db file is not attached to the server.
My question is this:
What is the difference ? Will the performance improve if the db is attached and I connect to it throught the server ? I'm really not sure what the difference is.
Thanks
View 5 Replies
View Related
May 25, 2008
Hey!
I need help getting all the users that are "attached" or "allowed" to access a given database and their login information. I do not know if this is even possible but I had tried to do my own research and cant figure it out/find any info on it. Any help is greatly appreciated!
Thank you!
-Teenprogrammer
View 4 Replies
View Related
Mar 13, 2007
I been asked recently in the interview thatHow can I detect changes automatically in the SQL Server Database when anything is updated, deleted or inserted?if anyone can help me in this that will be really great.
I dont actually know whether I can ask this here but I wanted to know the answer for this and thought this might be right place to ask?
sorry if I am wrong?
Thanks in Advance
View 2 Replies
View Related
Jul 25, 2014
We have two SQL 2012 servers, sever A and B.
We need to sync a database on A so that there is a copy of it on B.
We need to be able to query both databases so mirroring isn't an option.
View 7 Replies
View Related
Jun 20, 2013
Problem Summary: Merge Statement takes several times longer to execute than equivalent Update, Insert and Delete as separate statements. Why?
I have a relatively large table (about 35,000,000 records, approximately 13 GB uncompressed and 4 GB with page compression - including indexes). A MERGE statement pretty consistently takes two or three minutes to perform an update, insert and delete. At one extreme, updating 82 (yes 82) records took 1 minute, 45 seconds. At the other extreme, updating 100,000 records took about five minutes.When I changed the MERGE to the equivalent separate UPDATE, INSERT & DELETE statements (embedded in an explicit transaction) the entire update took only 17 seconds. The query plans for the separate UPDATE, INSERT & DELETE statements look very similar to the query plan for the combined MERGE. However, all the row count estimates for the MERGE statement are way off.
Obviously, I am going to use the separate UPDATE, INSERT & DELETE statements. The actual query plans for the four statements ( combined MERGE and the separate UPDATE, INSERT & DELETE ) are attached. SQL Code to create the source and target tables and the actual queries themselves are below. I've also included the statistics created by my test run. Nothing else was running on the server when I ran the test.
Server Configuration:
SQL Server 2008 R2 SP1, Enterprise Edition
3 x Quad-Core Xeon Processor
Max Degree of Parallelism = 8
148 GB RAM
SQL Code:
Target Table:
USE TPS;
IF OBJECT_ID('dbo.ParticipantResponse') IS NOT NULL
DROP TABLE dbo.ParticipantResponse;
[code]....
View 9 Replies
View Related
Jun 17, 2015
Exec Prcoess task with source : ftp
destination :ftpunzip
work directory ftpunzip
executable : c:Program FilesWinZip
i am using expressing.
It is doing the unzip but getting this error
package process on server server1 has failed within the Task 'Unzip Files' with the following errors:
>
> File/Process "WZUNZIP.EXE" does not exist in directory "c:Program FilesWinZip".
This is the error message i am getting it
View 6 Replies
View Related
Feb 27, 2008
I attached my database to SQL 2005 but it's showing up as read-only for some reason. I've attached this before just fine in another instance of the Vista OS. Why would it attach differently this time compared to all other times and show read only?
The .mdb and .ldf files are not read only if you right-click and check out their properties.
View 12 Replies
View Related
Nov 11, 2007
Hello all,
I'm using SQL 2005 Express edition. I'm currently connecting to the database file directrly (from ASP.NET) and that db file is not attached to the server.
My question is this:
What is the difference ? Will the performance improve if the db is attached and I connect to it throught the server ? I'm really not sure what the difference is.
Thanks
View 3 Replies
View Related
Sep 27, 2007
Hi All
I am in process of moving a SQL 2005 solution from a development box that used local storage to UAT environment with SAN attached storage. The solution uses database snapshots
The database files are on the SAN storage but during testing I was unable to create a Database snapshot on the SAN disk. Creating snapshots on the local disk worked fine.
Is their some restriction/problem in using the database snapshot technology with SAN storage?
View 19 Replies
View Related
Mar 23, 2007
Hello,
I was using a SQL Express database for some time now with no problems for a NUnit Test project. No, all of a sudden, I'm getting these problems:
DatabaseProviderTest.TestContainsUser : System.Data.SqlClient.SqlException : Cannot open user default database. Login failed.Login failed for user 'XXXXXX'.
For the SQLEXPRESS database, I checked and I am a user, and I gave myself every permission imaginable. The default database is master, so I don't know why I am getting this problem?
Any ideas? Thanks.
View 3 Replies
View Related
Jan 9, 2008
Why in the hell doesn't SQL Server provide a facility for dropping anactive connection on an attached database in SQL Server Managementconsole? I can't detach an attached database because apparently thereis an active connection.I know you can use SSEUTIL but it seems like kluge for a poorlythought out function.Crazy
View 2 Replies
View Related
Mar 8, 2007
I am supposed to be documenting the SQL Express 2005 SP2 installation and connection to our application on Vista. I have installed and uninstalled the application several times in trying to create the connection and document the process. I thought I was done but now the database will not attach because it thinks the databasse is already attached. The database is not attached. I even uninstalled it again thinking something was left over.
Among the possibilities are that the database we are trying to attach is from SQL Server 2003 on a Server 2003. I tend not to think it is a server issue but have no reason to make that statement.
I tend to think it is a Vista issue because I have encountered and circumvented several. Our applications work fine on the full version of SQL. I can connect my Vista computer to the servers without issue. We have no Vista Servers other than the workstation I am trying to get SQL Express running on.
I am about out of ideas. Any suggestion will be tried at this point. Brian
View 1 Replies
View Related
Oct 24, 2006
Hello,
In my vb.net application, I have an attached database called dbMaster with the following tables:
tblCustomer, tblProducts, tblUsers
In visual studio 2005, is it possible to publish only one table? My problem is, is that I want to send my end users updated data from my tblCustomer, and am finding that on my test laptop, if I publish dbMaster, it sends all tables when I just want one to be sent.
Thanks in advance.
View 5 Replies
View Related
May 17, 2015
Is it possible to try repair a database without being attached, giving the path to the files?
I'm trying to attach a database that i recover from a disk, and i'm not able to attach, gives me an error, saying i should do a db check.
View 3 Replies
View Related