Jobs blocked by sleeping sessions in sql server

After a disaster recovery and a recreation of transaction log, my requests made through the virtual machine manager console are blocked by sessions with sleeping status,
The next requests are waiting for this session, anyone have any suggestions?
Thank U
Att

If it takes long time then what can i do , Because users are complaining about DB is slow  ?
bhagee
you can see blocked process info using sp_who2
to get an idea of locks acquired see sp_lock
http://msdn.microsoft.com/en-us/library/ms187749.aspx
The process to remove the blocking is to wait for one session to finish what its doing or kill it if you suspect its running longer than usual
To check if the process is actually waiting for something, have a look at wait stats
http://www.sqlskills.com/blogs/paul/wait-statistics-or-please-tell-me-where-it-hurts/
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • Urgent: Finding sessions in SQL server 2000

    Hi,
    Can you help me how to find out sessions in SQL Server 2000.
    Also is there any way to see the outstanding sessions for a database?
    Thanks in advance,
    Vasu.

    You can do this graphically in Enterprise Manager, or you can use this script:
    SET NOCOUNT ON
    create table #ProcCheck(
     Status varchar(50) ,
     SPID int ,
     CPU int ,
     Pys_IO int ,
     WaitTime int ,
     BlockSPID int ,
     HostName varchar(36) ,
     ProgName varchar(100) ,
     NTUser varchar(50) ,
     LoginTime datetime ,
     LastBatch datetime ,
     OpenTrans int ,
     LastCmd varchar(4000))
    create table #ProcInfo(
     EventType varchar(100) ,
     Parameters int ,
     EventInfo varchar(7000)
    INSERT INTO #ProcCheck(Status, SPID, CPU, Pys_IO, WaitTime, BlockSPID, HostName, ProgName, NTUSer, LoginTime, LastBatch, OpenTrans)
    SELECT status, SPID, CPU, Physical_IO, WaitTime, Blocked, SUBSTRING(HostName, 1, 36), SUBSTRING(Program_Name, 1, 100), SUBSTRING(nt_username, 1, 50), Login_Time, Last_Batch, Open_Tran
    FROM master..sysprocesses
    where (blocked > 0
    or spid in (select blocked from master..sysprocesses (NOLOCK) where blocked > 0)
    or open_tran > 0)
    and SPID <> @@SPID
    declare @spid int ,
     @cmd varchar(7000)
    declare Procs cursor fast_forward for
    SELECT SPID FROM #ProcCheck
    OPEN Procs
    FETCH NEXT FROM Procs INTO @SPID
    WHILE @@FETCH_STATUS = 0
     BEGIN
     SET @cmd = 'DBCC INPUTBUFFER(' + CONVERT(varchar, @SPID) + ')'
     INSERT INTO #ProcInfo
     EXEC(@cmd)
     SELECT @cmd = EventInfo
     FROM #ProcInfo
     DELETE FROM #ProcInfo
     UPDATE #ProcCheck
     SET LastCmd = SUBSTRING(@cmd, 1, 500)
     WHERE SPID = @SPID
     FETCH NEXT FROM Procs INTO @SPID
     END
    CLOSE Procs
    DEALLOCATE Procs
    SELECT * FROM #ProcCheck 
    DROP TABLE #ProcCheck
    DROP TABLE #ProcInfo

  • Scheduler jobs to refresh table data from SQL server

    Hi !
    I am planning to have a scheudler job to refresh data from a SQL server database into Oracle. All I do is run several of the below statements. Each of these tables have less than 100 rows. So, it completes in under 20 seconds.
    I am wondering if it is a good idea to run it as PL/SQL block as below. Please can someone comment ?
    delete from B;                                                 
    insert into A select * from AA@choumsq020;                                     
    commit;
    delete from B;                                            
    insert into B select * from BB@choumsq020;                           
    commit;
    I am planning to run it as below
    BEGIN
      DBMS_SCHEDULER.create_schedule (
        job_name        => 'TEST'
        job_type          => 'PLSQL_BLOCK'
        job_action      => 'begin 
                   delete from B;                                                 
                   insert into A select * from AA@choumsq020;                                     
                   commit;
                   delete from B;                                            
                   insert into B select * from BB@choumsq020;                           
                   commit;
                   end; '   
        start_date      => SYSTIMESTAMP,
        repeat_interval => 'FREQ=MINUTELY, byminute=15',
        end_date        =>  NULL,
        comments        => 'Repeats every 15 mins, for ever.');
    END;
    /Am I doing anything wrong here ? I am yet to run it on the database
    Thanks.

    And use dbms_scheduler.create_job not dbms_scheduler.create_schedule.
    Also leave start_date empty (that gets you systimestamp but at the timezone that
    usually has a region instead of an absolute offset, like select dbms_scheduler.stime from dual
    would report.
    -Eric

  • "block change tracking" equivalent in sql server

    Hi All,
    If someone has expertise in both oracle and sql server, pls let me know if there is " block change tracking" equivalent in sql server. I know sql server has incremental/differential backup, curious to know whether it got this equivalent feature.
    Regards,
    Satheesh Shanmugam
    http://borndba.com

    May be the below link will help you:
    http://www.databasejournal.com/features/mssql/article.php/3824196/Introducing-Change-Tracking-in-SQL-Server-2008.htm

  • Effective GUI for monitoring blocks, memory, cpu,io in SQL server

    Hi,
    Is there any GUI/ tool to monitor SQL server 2008 R2 memory, CPU, IO, blocks?

    Hi,
    Is there any GUI/ tool to monitor SQL server 2008 R2 memory, CPU, IO, blocks?
    Simply run below query to see SQL Server memory utilization.
    select
    (physical_memory_in_use_kb/1024)Memory_usedby_Sqlserver_MB,
    (locked_page_allocations_kb/1024 )Locked_pages_used_Sqlserver_MB,
    (total_virtual_address_space_kb/1024 )Total_VAS_in_MB,
    process_physical_memory_low,
    process_virtual_memory_low
    from sys. dm_os_process_memory
    Schedule it through agent job and add database mail to send mail to you.
    I use Quest spotlight it does no gives memory utilization but shows Buffer cache hit ratio.Which is important parameter to mark.SQL utilizes memory heavily so any tool can flash message like memory utilization high which actually is not correct.I have seen
    it with many tools.
    For others you can go for Quest tool.
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • How to Create a SQL Agent Job For A SSIS Package with Sql Server Authentication

    Hi ALl,
    I have a SSIS package which basically has a data flow task in which i pull the data from one server and copy it into another server and my source server is the one where i dont have windows authentication and i have to only use a sql server authentication
    . This package runs fine if i click the server connection properties type the password and save it.
    Now, my task is to set up a sql agent job which basically uses a proxy account and takes this package from the file system and runs it.But when i try to run this package, its failing with an error saying 
    "Login Failed For rpt5user" where rpt5user is the username for my sql server authentication of the source connection.
    Can someone please help me with any suggestions on how to do this?
    I have heard that we can achieve it by using xml config file which i have never used and i am trying to google around but for no luck.
    So, If someone can please throw any suggestions or ideas on this it would be great.
    Thanks

    You need to add password as a config item and set it from the file source or sql table
    see this as an example
    http://blogs.msdn.com/b/runeetv/archive/2009/12/22/ssis-package-using-sql-authentication-and-dontsavesensitive-as-protectionlevel.aspx
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Data services job failes while insert data into SQL server from Linux

    SAP data services (data quality) server is running on LInux server and Windows. Data services jobs which uses the ODBC driver to connect to SQL server is failing after selecting few thousand records with following reason as per data services log on Linux server. We can run the same data services job from Windows server, the only difference here is it is using SQL server drivers provided by microsoft. So the possible errors provided below, out of which #1 and #4 may not be the reason of job failure. DBA checked on other errors and confirmed that transaction log size is unlimited and system has space.
    Why the same job runs from Windows server and fails from Linux ? It is because the ODBC drivers from windows and Linux works in different way? OR there is conflict in the data services job with ODBC driver.
    ===== Error Log ===================
    8/25/2009 11:51:51 AM Execution of <Regular Load Operations> for target <DQ_PARSE_INFO> failed. Possible causes: (1) Error in the SQL syntax;
    (2)6902 3954215840 RUN-051005 8/25/2009 11:51:51 AM Database connection is broken; (3) Database related errors such as transaction log is full, etc.; (4) The user defined in the
    6902 3954215840 RUN-051005 8/25/2009 11:51:51 AM datastore has insufficient privileges to execute the SQL. If the error is for preload or postload operation, or if it is for
    ===== Error Log ===================

    this is another method
    http://www.mssqltips.com/sqlservertip/2484/import-data-from-microsoft-access-to-sql-server/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Access to view blocking sessions in sql server 2008

    Hi,
    One of my client wrote a stored procedure. we scheduled this SP in a job. while job is running, it is blocking other sessions. It is happening frequently. So, client is asking me to grant permission to view blocking session( want to execute sp_who2). Could
    you please advise me, which permission I need to give. I don't like to give access other than sp_who2. Please advise.
    Thanks.
    Raja.
    Thanks, Raja

    You need VIEW SERVER STATE permissions for sp_who or sp_who2 to work. You can also use sys.dm_exec_requests which will also give blocking information and requires the same permissions.
    Else you can take a look at the other alternative which is sp_whoisactive - check this link -
    http://sqlblog.com/blogs/adam_machanic/archive/2012/03/22/released-who-is-active-v11-11.aspx
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • SQL Server Agent - Job History not being recorded (SQL Server 2005)

    I have been trying to get to the bottom of an issue with SQL Server Agent not recording any job history. I am using SQL Server 2005 on a single Windows Server 2008 machine (i.e. no other domain controllers/active directory servers).
    The SQL Server Agent service is configured to 'Log On As' NT user account 'sqlagent'. The jobs themselves are executed successfully (all 'Transact-SQL' type steps actually use the 'sa' account) however the there is no actual job history to be found for any
    of the jobs -- in the SQL Activity monitor, the 'Last Run Outcome' is always 'Unknown' and the 'Last Run' date is always 'Never' for all jobs; in the SQL Job History Viewer there are no entries for any instances of a job being executed.
    The 'sqlagent' NT user account ia a member of the 'Administrators' NT group; the 'Administrators' group appears under Security > Logins on the database server. I have another server that also uses the same setup with a 'sqlagent' NT user account, on that
    database server the 'sqlagent' user account appears under Security > Logins and the SQL job history works correctly. I have attempted to add the 'sqlagent' to the Logins on the affected server using the SQL Server Surface Area configuration but this operation
    returns an error, detailed below.
    Additionally, I have attempted to use the built-in NT system account 'NETWORKSEVICES' to run the SQL Agent Service but this also results in exceptions in the error log and no job history being recorded. The entries in the error logs are very similar to those
    from the 'sqlagent' NT user account but instead the user is referred to as 'NT AUTHORITY\ANONYMOUS LOGON' in the error logs, again these are detailed below.
    Many thanks in advance for anyone's time and help with this issue!
    Arthur
    The following errors are raised in SQL Server Agent > Error Logs each time a job is executed:
    Date 11/11/2012 18:30:01
    Log SQL Agent (Current - 11/11/2012 18:30:00)
    Message
    [298] SQLServer Error: 18452, Login failed for user ''. The user is not associated with a trusted SQL Server connection. [SQLSTATE 28000]
    Date 11/11/2012 18:30:01
    Log SQL Agent (Current - 11/11/2012 18:30:00)
    Message
    [382] Logon to server 'XXXXXXXX' failed (ConnAttemptCachableOp)
    If the SQLAgent service is configured to use the NT system account 'NETWORKSERVICE' then the following errors are returned instead:
    Date 29/10/2012 18:30:15
    Log SQL Agent (Archive #1 - 29/10/2012 18:38:00)
    Message
    [298] SQLServer Error: 18456, Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. [SQLSTATE 28000]
    Date 29/10/2012 18:30:15
    Log SQL Agent (Archive #1 - 29/10/2012 18:38:00)
    Message
    [382] Logon to server 'XXXXXXXX' failed (ConnAttemptCachableOp)
    I have tried granting the 'sqlagent' NT user account with SysAdmin Server Role privaledges using the SQL Server User Provisioning tool in SQL Server Surface Area Configuration, but this always throws the following, similar error:
    Login failed for user ''. The user is not associated with a trusted SQL Server connection. (Error: 18452)
    ===================================
    Login failed for user ''. The user is not associated with a trusted SQL Server connection. (.Net SqlClient Data Provider)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18452&LinkId=20476
    Server Name: 127.0.0.1,1344
    Error Number: 18452
    Severity: 14
    State: 1
    Line Number: 65536
    Program Location:
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
       at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at sqlprov.SysAdminServerRole.ProvisionInstance(Instance instance, String userName)
       at sqlprov.ProvisionTask.Provision(Instance instance, String userName)
       at sqlprov.MainForm.ProvisionTasks()

    Hi Rama,
    Thanks for your reply. I have run the query you specified and can see only one entry with "NTLM" in the auth_scheme column, all of the rest have "SQL". It figures that the entry with "NTLM" is relating to the one NT user account that can successfully log
    in to the service (as mentioned in my reply to Nag above, this is the NT user account that installed the service on the machine). I have also executed the same query on the other machine that I mentioned in my original post and this contains two "NTLM" entries,
    I'd assume that these relate to the NT user that installed the software and the correctly working "sqlagent" NT user account that is correctly logging the job history on that machine.
    I think the problem is very much to do with granting access to new NT user accounts, as per the KB article that you have quoted above. In this case, it is not relating to scenarios 1 or 2 as these relate to SQL Server logins and this issue is about a Windows
    Authentication login. As I mentioned to Nag above, I am unable to grant any NT user accounts with access to the service however the NT accounts are all defined locally on the same machine as the SQL server is installed (i.e. there is no domain controller,
    active directory controller, etc) so I don't understand how the Windows login cannot be verified.
    Any further advice on the issue would be greatly appreciated, please let me know if there is any more information I can provide to help diagnose the problem.
    Many thanks!
    Arthur

  • SQL Server Agent Jobs- Not running

    Team,
    We have a production database hosted on SQL Server 2008R2 SP2(10.50.4000). We have application jobs which are scheduled and basically have packages called from this job. These jobs were running all good till yesterday and it has stopped working since yesterday
    even though its enabled. Manual runs are successful. Other jobs are running fine. 
    Checked the Owner of these jobs and the account is SQL Server account which is a proxy account. It had enforce password policy. I have removed that and reset the password to original. However it didnt work.
    The last change on this server was windows patching which was performed last week. Apart from that the SQL Server agent service was changed. This is a clustered environment.
    The last resort is restart the agent, however would like to get some inputs before I perform this action. 
    Please let me know your valuable inputs.
    Regards,
    Sharath

    If job is not executed at all, that is, there are no entries in the job history, check:
    1) The job is enabled.
    2) The schedule(s) is enabled.
    3) The scdedule does not have an end date has has passed.
    4) And that all other conditions on the schedule says that the job should run.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • SQL Server Agent Job

    I want to learn how to create a SQL Server Agent Job. After I googled it, I see that it can be found under Databases under Object Explorer, But I don't see that option. Can someone tell me where is it or how can i create one? I also need to
    understand the steps to create one. (I just have basic knowledge of SQL Server of using small queries like Update, Delete, Select statements, etc). A plain english explanation would be very helpful.

    BOL: "Create a Job
    This topic describes how to create a SQL Server Agent job in SQL Server 2014 by using SQL Server Management Studio, Transact-SQL, or SQL Server Management Objects (SMO)."
    https://msdn.microsoft.com/en-us/library/ms190268.aspx
    See SSMS image for new job:
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Does SQL Server 2008 R2 recognize only system-generated session identifiers,

    As part of the locking down of our system we are doing the Security Technical Implementation Guide (STIG) and one of the questions it asks is "The DBMS must recognize only system-generated session identifiers."
    I have looked at the STIG version for SQL Server 2012 and this is not a finding on it, since it supports the requirement and cannot be configured out of compliance.
    If anyone can help confirm that this is also the case with SQL Server 2008 R2 that would be very helpful.
    Thank you, Darren
    The discussion of it is:
    This requirement focuses on communications protection at the application session, versus network packet level. The intent of this control is to establish grounds for confidence at each end of a communications session in the ongoing identity of the other
    party and in the validity of the information being transmitted.
    Unique session IDs are the opposite of sequentially generated session IDs which can be easily guessed by an attacker. Unique session identifiers help to reduce predictability of said identifiers. 
    Unique session IDs address man-in-the-middle attacks including session hijacking or insertion of false information into a session. If the attacker is unable to identify or guess the session information related to pending application traffic, they will have
    more difficulty in hijacking the session or otherwise manipulating valid sessions.
    The DBMS must only recognize only system generated session identifiers. If an attacker was able to generate a session with a non-system generated session identifier and have it be recognized by the system, the attacker could potentially gain access to the
    system without passing through access controls designed to limit database sessions to authorized users.

    Hi Darren,
    From your description, do you mean the session_id from DMV sys.dm_exec_sessions? If so, the session_id(s) are all created and handled by SQL Server. When session_id <= 50 , it belongs to a system session, and when session_id > 50, it belongs to a user
    session.
    Below query could help you generate system sessions in SQL Server 2008 R2. Refer to :
    Explore the secrets of session- sys.dm_exec_sessions.
    SELECT
    S.SESSION_ID,
    S.STATUS,
    S.HOST_NAME,
    C.CLIENT_NET_ADDRESS,
    CASE WHEN S.LOGIN_NAME = S.ORIGINAL_LOGIN_NAME THEN S.LOGIN_NAME ELSE S.LOGIN_NAME + ' (' +S.ORIGINAL_LOGIN_NAME + ')' END AS LOGIN_NAME,
    S.PROGRAM_NAME,
    C.CONNECT_TIME, -- DIFFRENT BETWEEN CONNECT & LOGIN TIME IS TIME TAKEN BY PRELOGON ACTIVITIES
    S.LOGIN_TIME,
    CASE S.TRANSACTION_ISOLATION_LEVEL
    WHEN 0 THEN 'UNSPECIFIED'
    WHEN 1 THEN 'READUNCOMITTED'
    WHEN 2 THEN 'READCOMMITTED'
    WHEN 3 THEN 'REPEATABLE'
    WHEN 4 THEN 'SERIALIZABLE'
    WHEN 5 THEN 'SNAPSHOT'
    ELSE CAST(S.TRANSACTION_ISOLATION_LEVEL AS VARCHAR(32))
    END AS TRANSACTION_ISOLATION_LEVEL_NAME,S.LAST_SUCCESSFUL_LOGON, -- REQUIRES 'COMMON CRITERIA COMPLIANCE ENABLED' OPTION VIA SP_CONFIGURE.
    S.LAST_UNSUCCESSFUL_LOGON, -- REQUIRES 'COMMON CRITERIA COMPLIANCE ENABLED' OPTION VIA SP_CONFIGURE.
    S.UNSUCCESSFUL_LOGONS, --REQUIRES 'COMMON CRITERIA COMPLIANCE ENABLED' OPTION VIA SP_CONFIGURE.
    S.CPU_TIME AS CPU_TIME_MS,
    S.MEMORY_USAGE AS MEMORY_USAGE_PAGES,
    S.ROW_COUNT,
    S.PREV_ERROR,
    S.LAST_REQUEST_START_TIME,
    S.LAST_REQUEST_END_TIME,
    C.NET_TRANSPORT,
    C.PROTOCOL_TYPE,
    S.LANGUAGE,
    S.DATE_FORMAT,
    ST.TEXT AS QUERY_TEXT
    FROM
    SYS.DM_EXEC_SESSIONS S
    FULL OUTER JOIN SYS.DM_EXEC_CONNECTIONS C ON C.SESSION_ID = S.SESSION_ID
    CROSS APPLY SYS.DM_EXEC_SQL_TEXT(C.MOST_RECENT_SQL_HANDLE) ST
    WHERE
    S.SESSION_ID IS NULL
    OR S.SESSION_ID < = 50
    ORDER BY
    S.SESSION_ID
    Thanks,
    Lydia Zhang

  • SQL server can't access network share

    Hello,
    I am facing an issue where the SQL server can't access the network share. The network share is mounted by  a domain user who is also configured as Administrator on the server.
    Through SQL Server management studio as well as PoweShell script when i try to access the share in order to attach the database contained within the share, i get the error "Unable to find the file specified". I can't mention the network drive to
    the SQL management GUI file browser too if i try to attach the database through GUI.
    For all SQL services, I changed the service log on account to be the same account which mounts the network share.
    As work around - 
    I launched a command prompt under NT Authority \ SYSTEM (LocalSystem) account and mounted the drive to the same location which lead to adding one more connection but under local system account. With this change, the SQL server was able to access the network
    share!
    I couldn't understand whey SQL expects the network share to be mounted under local system account even if all the SQL services are running under domain account ? I want SQL to be able to access the network share without opting for above work around.

    Hello,
    I couldn't understand whey SQL expects the network share to be mounted under local system account even if all the SQL services are running under domain account ? I want SQL to be able to access the network share without opting for above work around.
    It doesn't have to be. The workaround is only a temporary fix and is certainly not a good idea. I would not use mounted folders with SQL Server, at all, period.
    The reason you're having difficulty is that when the folder is mounted, it's mounted for YOUR session not ALL sessions. SQL Server has already started its services and is running under its' own session and is not privy to the things you do to change the
    environment. For example, if you changed a system or user variable (for example, a SET variable) SQL Server would have no idea about this because when it started, that variable either didn't exist or was something else. This is not SQL Server's fault but how
    Windows works (this information is stored in the Process Environment Block [PEB]) for any windows process.
    As other's have said, don't use mounted drives - use a UNC path. UNC paths are 100% supported on 2012+ as well as running databases on a SMB 3.x share (UNC pathed of course).
    If you absolutely must use a mounted drive, enabled xp_cmdshell access (through sp_configure) and run the net use command through xp_cmdshell. I, once again, would highly advise not doing this and using an UNC path.
    -Sean
    The views, opinions, and posts do not reflect those of my company and are solely my own. No warranty, service, or results are expressed or implied.

  • Is there any simple way to run same sql script on multiple remote sql server databases at once?

    i am using sql server 2005. our company has many branches. each branch is located in different country. so when i update database in any country over the VPN connection then i need to update db in another country one by one over the vpn connection. it
    is very tire some job....so i was think that there could be any easy trick to update multiple db in different country easily. so am developing a store procedure which will connect each DB in different database one after one over the vpn and read script from
    sql file and execute the script in remote db over vpn. so please have look at my script and tell me how to do it. please do not advise me to use any 3rd party.
    here is a table structure where i will put all my remote db details.
    CREATE TABLE [dbo].[DBDetails]
    [ServerName] [varchar](max)     NULL,
    [DBName] [varchar](max)         NULL,
    [UserID] [varchar](max)         NULL,
    [Password] [varchar](max)       NULL,
    [CountryCode] [varchar](2)      NULL
    SET NOCOUNT ON
    DECLARE DB CURSOR FOR SELECT ServerName,DBName,UserID,Password,CountryCode FROM    DBDetails
    OPEN DB
    DECLARE @ServerName     varchar(MAX)
    DECLARE @DBName         varchar(MAX)
    DECLARE @UserID         varchar(MAX)
    DECLARE @Password       varchar(MAX)
    DECLARE @CountryCode    varchar(2)
    FETCH NEXT FROM DB INTO @ServerName,@DBName,@UserID,@Password,@CountryCode
    WHILE @@FETCH_STATUS = 0
    BEGIN
    -- here i need some help for opening db connection and read sql file and execute  the statement
    -- Please help here
    FETCH NEXT FROM DB INTO @ServerName,@DBName,@UserID,@Password,@CountryCode
     END
     CLOSE DB
     DEALLOCATE DB
    thanks

    One way: set them as jobs and assign the same schedule or start them from a stored procedure:
    http://www.sqlusa.com/bestpractices2005/startjobfromstoredproc/
    Note: when you start a job from a stored procedure, control proceeds to the next statement, there is no wait for the job to finish.
    Kalman Toth SQL SERVER 2012 & BI TRAINING
    New Book: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2012

  • SQL Server Agent fails to connect to DB after enabling mirror on failover cluster

    Hello:
    We have multiple databases running in a Failover Cluster instance: SQL 2012SP1 on Server 2008 R2 failover cluster (NOT AlwaysOn). We are trying to add a high-performance mirror in a standalone instance for DR. My understanding is that should be a perfectly
    normal, supported configuration.
    The mirroring is working properly; however, the clustered SQL Server agent is unable to run jobs that run in the mirrored databases.
    We get the following in the job log: Unable to connect to SQL Server 'VIRTUALSERVERNAME\INSTANCE'.  The step failed.
    There is a partner message in the agent log: [165] ODBC Error: 0, Connecting to a mirrored SQL Server instance using the MultiSubnetFailover connection option is not supported. [SQLSTATE IMH01]
    The cluster is not a mulitsubnet cluster. All hosts are connected to the same subnets and there is no storage replication. I can not find any place where I can adjust the connect string options for SQL Agent.
    Any guidance or suggestions on how to resolve this would be appreciated.
    ~joe

    SQL Team - MSFT:
    Thank you for taking the time to research and provide a clear answer.
    This seems very much a workaround and very unsatisfactory.
    You are correct, there is an IP dependency with OR condition. Moving to an AND condition is not viable for us. The whole point is to provide network redundancy. With an AND condition, if EITHER network interface fails, the service will go offline or fail
    to come online without manual intervention. This is arguably worse for uptime than having a single interface available.
    We are in process of rewriting all our SQL jobs to start in tempdb before transitioning to the appropriate target database. If this works for all of our jobs, I will mark the above response as answer.
    Again, thank you for the answer.
    Regards,
    Joe M.

Maybe you are looking for

  • JavaScript error on Interactive Report

    When clicking on the Magnifying glass of my interactive report search bar, I receive a JavaScript error. Line: 2 Char: 15193 Error: Syntax Error The page that I am navigating to has 2 regions. The first is an interactive report and the second is an h

  • Social media integration (fb,twitter...)

    Hi All, How do we integrate the social media sites into e-commerce application ,I want share or like  a Product in to social media,Could you please guide me how to do or any examples. Thanking you..! Regards, Jyothi.M

  • Possible Bug on Analytic Workspace Manager 11.1.0.7B

    Gentlemen, Perhaps I am doing something wrong, but for some reason when I enable the Materialized View option for an Average Cube, the Query on the MV gets set to SUM instead of AVG. I have disabled and re-enabled the materialized view on the cube se

  • Using MactheRipper...help!

    I have used mactheripper to extract a dvd and now the folder is in my movies...Now, how do burn that folder into a blank DVD?

  • BO Explorer add excel source

    Hello everybody, I allready install BO Enterprise XI 3.1, and have access to polestar via the port 8080, and that all is good, but i have a requirement to add into the Source box in the Manage Spaces the excel spreadsheet source, because we only find