Showing posts with label login. Show all posts
Showing posts with label login. Show all posts

Tuesday, March 20, 2012

compare two string in SQL Server

Hi,
I am writing a Store Procedure for Login, as following:
@.p_sUsername, @.p_sPassword are parameters
...
SELECT @.BName = B.username, @.BPW = Password FROM BENUTZER as B WHERE
username = @.p_sUsername AND Passwort = @.p_sPassword
...
but the SELECT Statement can not differ Uppercase and Lowercase, that means,
"Martin" = "martin"
Then I check explicitly:
if @.BName != @.p_sUsername
Login = 0
but this comparing works the same.
What can I do?
Thanks
Martinif you SQL Server database is not case sensitive you have to convert to to a
comparable format ,e.g. varbinary or specifiy a CASE Sensitive (CS) Collatio
n
for it:
Select 1 where 'test' = 'TEST'
GO
Select 1 where 'Test' COLLATE SQL_Latin1_General_CP1_CS_AS = 'TEST' COLLATE
SQL_Latin1_General_CP1_CS_AS
GO
Select 1 Where CAST('Test' as varbinary) = CAST('TEST' as varbinary)
Select 1 where 'test' = 'TEST'
GO
Select 1 where 'Test' COLLATE SQL_Latin1_General_CP1_CS_AS = 'TEST' COLLATE
SQL_Latin1_General_CP1_CS_AS
GO
Select 1 Where CAST('Test' as varbinary) = CAST('TEST' as varbinary)
--
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Martin" wrote:

> Hi,
> I am writing a Store Procedure for Login, as following:
> @.p_sUsername, @.p_sPassword are parameters
> ...
> SELECT @.BName = B.username, @.BPW = Password FROM BENUTZER as B WHERE
> username = @.p_sUsername AND Passwort = @.p_sPassword
> ...
> but the SELECT Statement can not differ Uppercase and Lowercase, that mean
s,
> "Martin" = "martin"
> Then I check explicitly:
> if @.BName != @.p_sUsername
> Login = 0
> but this comparing works the same.
> What can I do?
> Thanks
> Martin
>
>|||Case-sensitivity is determined by the column collation. So choose a
case-sensitive collation. For example:
ALTER TABLE benutzer
ALTER COLUMN username VARCHAR(128) COLLATE Latin1_General_CS_AS ;
David Portas
SQL Server MVP
--|||Thanks
Martin
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> schrieb im
Newsbeitrag news:1125571037.540712.199690@.g43g2000cwa.googlegroups.com...
> Case-sensitivity is determined by the column collation. So choose a
> case-sensitive collation. For example:
> ALTER TABLE benutzer
> ALTER COLUMN username VARCHAR(128) COLLATE Latin1_General_CS_AS ;
> --
> David Portas
> SQL Server MVP
> --
>|||thanks
Martin
"Jens Smeyer" <Jens@.[Remove_that][for contacting me]sqlserver2005.de>
schrieb im Newsbeitrag
news:877CE479-F0DF-4CDA-8720-A14908BFB207@.microsoft.com...
> if you SQL Server database is not case sensitive you have to convert to to
a
> comparable format ,e.g. varbinary or specifiy a CASE Sensitive (CS)
Collation
> for it:
> Select 1 where 'test' = 'TEST'
> GO
>
> Select 1 where 'Test' COLLATE SQL_Latin1_General_CP1_CS_AS = 'TEST'
COLLATE
> SQL_Latin1_General_CP1_CS_AS
> GO
> Select 1 Where CAST('Test' as varbinary) = CAST('TEST' as varbinary)
> Select 1 where 'test' = 'TEST'
> GO
>
> Select 1 where 'Test' COLLATE SQL_Latin1_General_CP1_CS_AS = 'TEST'
COLLATE
> SQL_Latin1_General_CP1_CS_AS
> GO
> Select 1 Where CAST('Test' as varbinary) = CAST('TEST' as varbinary)
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>
> "Martin" wrote:
>
means,|||To add to the other responses, if you force a case-sensitive compare in your
SQL statement, consider also including the normal compare in your WHERE
clause. This will allow SQL Server to efficiently use indexes on those
columns and thereby improve performance.
SELECT
@.BName = B.username,
@.BPW = Password
FROM BENUTZER as B
WHERE
username COLLATE SQL_Latin1_General_CP1_CS_AS = @.p_sUsername AND
username = @.p_sUsername AND
password COLLATE SQL_Latin1_General_CP1_CS_AS = @.p_sPassword AND
Password = @.p_sPassword
Hope this helps.
Dan Guzman
SQL Server MVP
"Martin" <martinsm@.freenet.de> wrote in message
news:Okeml6trFHA.304@.TK2MSFTNGP11.phx.gbl...
> Hi,
> I am writing a Store Procedure for Login, as following:
> @.p_sUsername, @.p_sPassword are parameters
> ...
> SELECT @.BName = B.username, @.BPW = Password FROM BENUTZER as B WHERE
> username = @.p_sUsername AND Passwort = @.p_sPassword
> ...
> but the SELECT Statement can not differ Uppercase and Lowercase, that
> means,
> "Martin" = "martin"
> Then I check explicitly:
> if @.BName != @.p_sUsername
> Login = 0
> but this comparing works the same.
> What can I do?
> Thanks
> Martin
>

Friday, February 24, 2012

Common error codes for ADO & DMO

hi,
The error codes I am getting for errors like SQL server not available,
invalid sql credentials, login not a database user etc. are not same for ADO
& DMO. Is there a way to get common error codes for ADO & DMO?
Thanks.
- AjeyFor DMO I am using the IDispatch pointer and converting the EXCEPINFO->wCode
to HRESULT.
"Ajey" <ajey5@.hotmail.com> wrote in message
news:eLRrRVOCFHA.3820@.TK2MSFTNGP11.phx.gbl...
> hi,
> The error codes I am getting for errors like SQL server not available,
> invalid sql credentials, login not a database user etc. are not same for
ADO
> & DMO. Is there a way to get common error codes for ADO & DMO?
> Thanks.
> - Ajey
>

Sunday, February 12, 2012

command line local login to SQL failed

Pardon if this has been asked before. If so, please post the URL.
Could someone please tell me how to fix this login/pipe? Notice the 3rd
login is fine with "/E". It is a SQL2005 Enterprise on Win2003 Server Ent.
C:\Program Files\Microsoft SQL
Server\90\NotificationServices\9.0.242\Bin>osql /
SMIAMI /U junk
Password:
Login failed for user 'junk'. The user is not associated with a trusted SQL
Server connection.
C:\Program Files\Microsoft SQL Server\90\Tools\Binn> osql /SMIAMI /U junk
Password:
[SQL Native Client]Shared Memory Provider: No process is on the other en
d of
the pipe.
[SQL Native Client]Communication link failure
C:\Program Files\Microsoft SQL Server\90\Tools\Binn>osql /SMIAMI /E
1> use adventureworks
2> go
1> select count (*) from person.address
2> go
19614
(1 row affected)It appears that SQL Server is set for Windows Authentication and that you
are attempting to login using SQL Authentication (Username/Password).
If you must use SQL Authentication, you need to change the authentication
mode of the server.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"light_wt" <lightwt@.discussions.microsoft.com> wrote in message
news:2A01AFB3-3447-46CA-B69B-BA527E620F3D@.microsoft.com...
> Pardon if this has been asked before. If so, please post the URL.
> Could someone please tell me how to fix this login/pipe? Notice the 3rd
> login is fine with "/E". It is a SQL2005 Enterprise on Win2003 Server
> Ent.
> C:\Program Files\Microsoft SQL
> Server\90\NotificationServices\9.0.242\Bin>osql /
> SMIAMI /U junk
> Password:
> Login failed for user 'junk'. The user is not associated with a trusted
> SQL
> Server connection.
> C:\Program Files\Microsoft SQL Server\90\Tools\Binn> osql /SMIAMI /U junk
> Password:
> [SQL Native Client]Shared Memory Provider: No process is on the other
end
> of
> the pipe.
> [SQL Native Client]Communication link failure
> C:\Program Files\Microsoft SQL Server\90\Tools\Binn>osql /SMIAMI /E
> 1> use adventureworks
> 2> go
> 1> select count (*) from person.address
> 2> go
> --
> 19614
> (1 row affected)|||Hi,
Go to SQL Server program groups, select SQL Server management studio.After
connecting to SQL Server instance do;
1. Right click above server
2. Select properties
3. Select Security option and click the option button, SQL Server and
Windows authentication
4.click ok and restart SQL Server
After this you wil be able to connect using SQL Authentication.
Thanks
Hari
SQL Server MVP
"light_wt" <lightwt@.discussions.microsoft.com> wrote in message
news:2A01AFB3-3447-46CA-B69B-BA527E620F3D@.microsoft.com...
> Pardon if this has been asked before. If so, please post the URL.
> Could someone please tell me how to fix this login/pipe? Notice the 3rd
> login is fine with "/E". It is a SQL2005 Enterprise on Win2003 Server
> Ent.
> C:\Program Files\Microsoft SQL
> Server\90\NotificationServices\9.0.242\Bin>osql /
> SMIAMI /U junk
> Password:
> Login failed for user 'junk'. The user is not associated with a trusted
> SQL
> Server connection.
> C:\Program Files\Microsoft SQL Server\90\Tools\Binn> osql /SMIAMI /U junk
> Password:
> [SQL Native Client]Shared Memory Provider: No process is on the other
end
> of
> the pipe.
> [SQL Native Client]Communication link failure
> C:\Program Files\Microsoft SQL Server\90\Tools\Binn>osql /SMIAMI /E
> 1> use adventureworks
> 2> go
> 1> select count (*) from person.address
> 2> go
> --
> 19614
> (1 row affected)