Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Determine filepath from open SQL script Expand / Collapse
Author
Message
Posted Monday, October 01, 2012 3:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, January 29, 2013 5:26 AM
Points: 8, Visits: 138
Hi everyone,

Can any one tell me how to determine the file path of an open SQL file in the management studio?

I am trying to run an update script which open other SQL files. These update files (and folders) will always be relative to the update script which could be installed to different locations; so what I want is to be able to determine the path of the update file being opened, so that variables do not need to be manually set.

Many thanks for everyone's help.

Laurence.
Post #1366405
Posted Monday, October 01, 2012 3:08 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Tuesday, May 14, 2013 3:36 AM
Points: 721, Visits: 1,330
Place the mouse pointer of the the file's tab.



Ole Kristian Velstadbråten Bangås - Virinco - Facebook - Twitter

Concatenating Row Values in Transact-SQL
Post #1366407
Posted Monday, October 01, 2012 3:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, January 29, 2013 5:26 AM
Points: 8, Visits: 138
Thanks for the reply.

I know you can obtain the file path from looking at the tab. I want to be able to obtain the file path using TSQL within the script. It needs to be automatic.

Many thanks,

Laurence
Post #1366418
Posted Monday, October 01, 2012 3:58 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 4:46 PM
Points: 1,287, Visits: 3,850
<disclaimer> I don't even want to think about the security implications of what you are doing, so I will leave that to you</disclaimer>

Have you thought about using sqlcmd instead of ssms?

It can read files into the query stack using the ":r" command - and it uses relative paths ...



MM




Post #1366453
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse