Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Error Msg 102

Author  Topic 

ahson_u
Starting Member

12 Posts

Posted - 2010-10-13 : 13:10:29
Have changed the name of the computer and am running the following query to drop the old name of the machine on which the sql server is sitting.

OSQL -S.\STAX -E -icorrectservername.sql -oResult.txt

I get the following error message

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'S'.


Can someone kindly tell me how to correct this query

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-13 : 13:22:40
-S serverName\STAX (where serverName equals the name of the server)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-13 : 13:23:41
I moved your topic out of the Script Library forum, since that forum is for working scripts that people want to share with the community.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-13 : 13:23:58
What version of SQL Server are you using? If it's 2005 or 2008, then you should be using sqlcmd instead of osql.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ahson_u
Starting Member

12 Posts

Posted - 2010-10-13 : 13:42:26
Tara, thanks so much for your quick response. Still get an error message

Query
-S EPTAX01\SAGETAX

Message
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.

Ahson

quote:
Originally posted by tkizer

-S serverName\STAX (where serverName equals the name of the server)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-13 : 13:46:03
I think you've got a bad character in there, but perhaps it's hidden.

Let's try sqlcmd instead of osql.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-13 : 13:47:49
Where are you running this?
OSQL is a windows executable, it should be running from the command prompt. From the error is sounds like you're running it from management studio

Take a couple steps back, what are you trying to do?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-13 : 13:50:56
Ah, good catch! If it's from Management Studio, then just open your sql file and execute it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ahson_u
Starting Member

12 Posts

Posted - 2010-10-13 : 16:07:17
quote:
Originally posted by GilaMonster

Where are you running this?
OSQL is a windows executable, it should be running from the command prompt. From the error is sounds like you're running it from management studio

Take a couple steps back, what are you trying to do?

--
Gail Shaw
SQL Server MVP

Go to Top of Page

ahson_u
Starting Member

12 Posts

Posted - 2010-10-13 : 16:11:33
You have hit the nail on the head. I am using Management Studio indeed and it is SQP Server 2005. Basically changed the name of the computer and tried running the following query to drop the old name of the machine on which the sql server is sitting.

OSQL -S.\SAGETAX -E -icorrectservername.sql -oResult.txt

Thanks in advance for your help.

Kind regards

Ahson

quote:
Originally posted by GilaMonster

Where are you running this?
OSQL is a windows executable, it should be running from the command prompt. From the error is sounds like you're running it from management studio

Take a couple steps back, what are you trying to do?

--
Gail Shaw
SQL Server MVP

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-13 : 16:47:05
All you need to do is open that file from Management Studio and click F5 to execute it. osql/sqlcmd are not needed for this.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ahson_u
Starting Member

12 Posts

Posted - 2010-10-14 : 07:49:24
Tara/Gail:
Tried running from Management Studio the following

-S%computername%\SAGETAX -E -icorrectservername.sql -oResult.txt

still get the error message

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.

Basically Have changed the name of the computer and get an error message when I run an installation check. The error message is:

ERROR: Server has been renamed, (EPTAX01\SQLEXPRESS) was called (A-72E5634C45B34\SQLEXPRESS)

Can you kindly guide me on how to get rid of this error message. I was told the qeury would get rid of the message but the query does not tun.

Kind regards

Ahson
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-14 : 07:58:39
No, that's not what Tana meant. That command (with osql) something to be used at a dos command line, not in SQL.

Tana meant open the file correctservername.sql in management studio, connect to the appropriate server and then just run it.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

ahson_u
Starting Member

12 Posts

Posted - 2010-10-15 : 07:17:53
Gail/Tara, thanks for your help. I have been able to run the stored procedures from the Management Studio. However I still get an error when I run the installation as follows:

INFO: Established a SQL database session to MAIN01\SQLEXPRESS
ERROR: Server has been renamed, (MAIN01\SQLEXPRESS) was called (TRAIN01\SQLEXPRESS) Microsoft SQL Server 2005 - Express Edition RTM - 9.00.1399.06 (Intel X86)

This error, I suspect, results in a Windows Registry error as follows:

Ox0eedfade flags 0x00000001

Can you kindly me correct this error?
Thanks in advance for your kind help.


Ahson

quote:
Originally posted by GilaMonster

No, that's not what Tana meant. That command (with osql) something to be used at a dos command line, not in SQL.

Tana meant open the file correctservername.sql in management studio, connect to the appropriate server and then just run it.

--
Gail Shaw
SQL Server MVP

Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-15 : 08:03:58
What installation are you running? Doesn't look like a SQL error.

What was that stored proc that you were trying to run?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

ahson_u
Starting Member

12 Posts

Posted - 2010-10-15 : 09:58:57
It is Sage tax sofware which sits on top of SQL server. I don't know the name of the stored procedure but if you see it connects to SQL Server.

INFO: Established a SQL database session to MAIN01\SQLEXPRESS
ERROR: Server has been renamed, (MAIN01\SQLEXPRESS) was called (TRAIN01\SQLEXPRESS)

You don't think it is SQL Server Error?

Kind regards

Ahson


quote:
Originally posted by GilaMonster

What installation are you running? Doesn't look like a SQL error.

What was that stored proc that you were trying to run?

--
Gail Shaw
SQL Server MVP

Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-15 : 10:57:22
Um, I'm talking about the procedure that you ran (the one that's in that script file that you loaded in management studio and ran). What does that do?

That is not a SQL Server error. SQL doesn't care if you rename it and it doesn't have the right format for a SQL error.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

ahson_u
Starting Member

12 Posts

Posted - 2010-10-15 : 13:24:51
That stored procedure was sp_dropserver 'old machinename/sqlexpresss' and the second command was
sp_addserver 'new machinename/sqlexpresss'.
It seems this error arises when the application connects to the sql server it is expecting old machone name but encounters a new name. It seems I have to figure out when does the application store the old machine name and change it?
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-15 : 13:41:14
Was it exactly like that? To the letter?

If not, post the actual code.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

ahson_u
Starting Member

12 Posts

Posted - 2010-10-15 : 14:08:41
sp_dropserver 'TRAIN01\SQLEXPRESS'

and the second command was

sp_addserver 'MAIN01\SQLEXPRESS'.

There are error messages which arise from the application. The first one is

INFO: Established a SQL database session to MAIN01\SQLEXPRESS
ERROR: Server has been renamed, (MAIN01\SQLEXPRESS) was called (TRAIN01\SQLEXPRESS)

and the second error the application throws up is:

Checking master tables
OK: Master data path can be accessed from this machine.
OK: Location : C:\Personal_Tax\Master\Data
ERROR: Setting mismatch: SQL.MasterSettings (SQLServer=TRAIN01\SQLEXPRESS), expected (MAIN01\SQLEXPRESS)

This is the actual code and errors

Kind regards

Ahson


Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-10-15 : 15:57:12
The drop server is correct. The addserver should have been

EXEC sp_addserver 'MAIN01\SQLEXPRESS', 'local;

Before you run that, what do the following two statement return?

SELECT * from sys.servers
SELECT @@ServerName


--
Gail Shaw
SQL Server MVP
Go to Top of Page
    Next Page

- Advertisement -