SQL script and complex passwords

Got a problem you cannot solve? Try here.
steveosmith
Posts: 14
Joined: Thu Mar 09, 2006 4:14 pm

SQL script and complex passwords

Postby steveosmith » Thu Apr 27, 2006 10:48 am

I'm having a problem running a sql script when my SQL Express 2005 database has a complex password. I'm trying to run a stored procedure that exists in the database. Here's the SQL script I'm runniing:

EXEC dbo.spInsertNewDatabaseInitialValues

I return the result to a variable. If the database has the sa password set to pass, the variable shows SUCCESS. But if I change the sa password to @qmispass1 (and change the password in the IA script), the variable shows ERROR.

Any thoughts ?

TIA,
Steve.

Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Postby Gizm0 » Thu Apr 27, 2006 1:00 pm

The @ mark is used for variables.. you have to put the password between quotes ( ' ) so sql will treat them as a string and not as variable..
eg '@mypass' and not @mypass..
Panagiotis Kefalidis
Software Design Team Lead
\"In order to succeed, your desire for success should be greater than your fear of failure\"
InstallAware Software Corporation

steveosmith
Posts: 14
Joined: Thu Mar 09, 2006 4:14 pm

Postby steveosmith » Thu Apr 27, 2006 1:08 pm

Yes! That did it. Thanks for the help!

steveosmith
Posts: 14
Joined: Thu Mar 09, 2006 4:14 pm

Postby steveosmith » Thu Apr 27, 2006 5:54 pm

A related issue. I need to change the existing SQL Server Express sa password from 'pass'. I've tried calling the stored procedure sp_password from my SQL script with the proper parameters, but even though it returns SUCCESS, the password doesn't change. Here's the SQL script to change the password:

EXEC master.dbo.sp_password @old = 'pass', @new = 'foo', @loginame ='sa'
Go

When I run it from within an OSQL prompt it runs fine. I thought perhaps the @ was causing a problem in the SQL script, so I even tried assigning that line to a variable and referencing my variable in the SQL script. Same thing - it returns SUCCESS but doesn't actually change the password.

Any thoughts as to what I'm doing wrong?

Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Postby Gizm0 » Thu Apr 27, 2006 7:44 pm

You propably don't have permissions to do it when you connect to it through your script..
Check the roles of the user you are connecting to the database..
If it runs from the osql tool, it should run from anywhere..
Panagiotis Kefalidis

Software Design Team Lead

\"In order to succeed, your desire for success should be greater than your fear of failure\"

InstallAware Software Corporation

steveosmith
Posts: 14
Joined: Thu Mar 09, 2006 4:14 pm

Postby steveosmith » Fri Apr 28, 2006 10:04 am

I'm not too sure it's a permissions issue. In the script I set the user to sa - same as I do in OSQL. However, I'm going to consider the issue moot. Fortunately, there's always more than one way to accomplish a given task. I created a small executable that changes the password, and I call that from within my script.

Thanks for the help!

Steve.

MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Postby MichaelNesmith » Sat Apr 29, 2006 2:23 pm

Would taking EXEC out of the first line help - could you try that real quick?
Michael Nesmith
InstallAware
Home of The Next Generation MSI Installer
Get your free copy today - http://www.installaware.com/

Gizm0
Posts: 339
Joined: Wed Nov 09, 2005 8:47 pm

Postby Gizm0 » Sun Apr 30, 2006 6:41 am

It's the same Michael.. Either putting EXEC in front or not, it's absolutely the same..SQL Server executes the sp no matter what! :)
Panagiotis Kefalidis

Software Design Team Lead

\"In order to succeed, your desire for success should be greater than your fear of failure\"

InstallAware Software Corporation


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 179 guests