Click here to Skip to main content
14,360,125 members
Rate this:
Please Sign up or sign in to vote.
Requirements - Schedule task in SQL Express Edition.

But SQL server Agent functionality is not available in express edition.

Possible Solution- Schedule batch file execution to execute sql script. Tried

Batch File-
cmd /k sqlcmd -i backup.sql


Sql Script-
backup database DB_user1212 to disk = 'E:\backups\MyBackup.bak'
. But error occurred while executing sql script
A network related or instance specific error occurred while establishing a connection to SQL Server


Possible Reason- Something like connection string missing. Help me how to solve this, i am using windows authentication for connection.
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Chetan Saini wrote:
A network related or instance specific error occurred while establishing a connection to SQL Server

Basically, when you failed to connect to your SQL Server, the issue could be:
1) Network issue,
2) SQL Server configuration issue.
3) Firewall issue,
4) Client driver issue,
5) Application configuration issue.
6) Authentication and logon issue.
Check these
Steps to troubleshoot SQL connectivity issues[^]
SQL Server 2005 Connectivity Issue Troubleshoot - Part I[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part II[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part III[^]
   
Comments
Chetan Saini 7-Feb-14 8:04am
   
But i think i had not specified connection which is the reason behind the error. I tried :Connect localhost[\SQLEXPRESS] [-l timeout]
backup database DB_user1212 to disk = 'E:\backups\MyBackup.bak'

but problem continued. Please suggest me how to do connection then only i should think of firewall, driver etc.
thatraja 7-Feb-14 8:08am
   
Are you able to connect sql server(leave the backup process)? Try SQL management studio & login, verify
Chetan Saini 7-Feb-14 8:35am
   
hello thatraja problem was with connection i tried cmd /k sqlcmd -S localhost\SQLEXPRESS -E -i E:\Work\Test Schedule task in sql express\backup.sql in batch file and it worked.
thatraja 7-Feb-14 8:49am
   
Fine Hereafter do the same. Check the connection & go ahead with other things after that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100