Question: I want to save a video file in C:\ by incrementing the file name e.g. video001.avi video002.avi video003.avi etc. i want to do this in java. The program is on 

[Problem in java programming on windows7 (working well in windows xp)](https://stackoverflow.com/questions/2298101/problem-in-java-programing-on-windows7working-well-in-windows-xp)

How do i increment the file name so that it saves without replacing the older file.

Answer: 
The "nice" format you mention is simply a 4 part object reference.

```
select * from [server\instance].database.owner.tablename

```

3 part

```
select * from database.owner.tablename

```

2 part

```
select * from owner.tablename

```

If you want to dynamically change any of the server, db or schema values then you have one option:

```
EXEC (@sqlstring)

```

However, if you only access stored procs remotely...

```
DECLARE @RemoteSP varchar(500)

SET @RemoteSP = '[server\instance].database2.schema.proc2'
EXEC @RemoteSP @p1, @p2, @p3 OUTPUT

SET @RemoteSP = '[server\instance].database1.schema.proc1'
EXEC @RemoteSP @p4, @p5, @p6 OUTPUT

```

However, changing the components of the object reference makes no sense arguably: if you know you're going to query a table then just call that table in that database...
You do not have to use `EXEC` you could use something like `select * from openquery(MyLinkedServer,@sql)` THough i prefer `EXEC(@sql) AT MyLinkedServer`

But all work