Showing posts with label mssql. Show all posts
Showing posts with label mssql. Show all posts

Wednesday, March 28, 2012

How can I read an Image which is in the MSSQL Server database?

How can I read an Image which is in the MSSQL Server database?Come on, Ashok, stop using the forums to research your interview questions.
You are not likely to succeed in an interview if you take this approach. Even if you did succeed in fluffing an interview and landing a programming job, what would you then do when you were given a task to complete? Jump on the forums and ask how to do it? What would you say when your boss asks why it is taking so long for you to do anything? "Sorry, boss, but I'm waiting for others to tell me how to do it."
If you want to be a programmer, you must learn how to be a programmer. The operative phrase there is that "you must learn." Open a book, or hit Google, or read the documentation--but do it yourself.
Then, if you truly get stuck and cannot find an answer, *that* is the time to ask on the forums.
|||Well said, I don't mind helping people that are stuck and want to learn, but please no short-cutters.
sql

Friday, March 23, 2012

how can I open a .mdf aspnetDB DataBase ?

Hello everybody,

I am working with SqlExpress and MSSQL Server Management Studio Express and do not manage to open the aspnetDB .mdf database in which I am storing all data about my users.

I woulds like to open it and to be able to request it in order to check some strange things.

Actually, I'm experiencing an isssue with that database since the request just below gives me two results for only one user:

SELECT Member.Password, Member.PasswordAnswerFROM aspnet_MemberShip Member, aspnet_Users UsersWHERE Member.UserId=Users.UserIdAND Users.UserName='Admin'

Using this request returns me a user whom password is clear and an identical user whom password is hashed whereas I set PasswordFormat="Clear" in my Web.Config

Could you explain me how I may proceed please?

Thanx for your help

If you still have your project open, it could be that the project has a lock on the database file. Close your project in order to use MS SSMS express.

Otherwise, you can right-click the ASPNET.MDF database file and choose 'Open'. This will allow you to navigate the database using the Server Explorer tab, much like you would with SSMS.

Your problem lies in your SQL, however. UserId is the only Unique column in the default Users table because it is the primary key. This means that the UserName is NOT unique, and could be duplicated.

Use System.Web.Security.Membership.Provider to get a reference to the app's default membership provider, and use that to do what you need. (See the System.Web.Security.MembershipProvider class for available functions.)

|||

Thanx for your answer ps2goat,

I finally used VisualStudio Servers's Explorer to do so and was able to see all the information stored in the .mdf file.

This raises some questions about the issue I was dealing about above, but at the time, it is a solution for that precise problem ;)

In fact, I had two identical usernames in the database, one with a password saved in clear and the other hashed and, as you tell it, with a different unique ID.

I believe this comes from the fact that I used this .mdf file in more than 3 versions of the current prooject, making of it some kind of mess where it becomes to difficult to find what you're looking for.

Thanks for your help.

|||

You can just use visual studio directly to navigate through it. Also you can get that into sql express or any other db and reconstruct all the db.

Friday, March 9, 2012

How can I import table indices for all the tables transferred from one db to Sql Server?

Hello,
I was successfully able to import all the tables from a SQLBase db to MSSQL.
Now i would also like to import all the indexes for the tables.
How can I do that?
Regards,
Sami
[Remove Numbers from e-mail address to use it]
The only way I can think of would be if SQLBase has metadata tables from
which you can query for the indexes. You could query them and create
the CREATE INDEX statements required on SQL Server and then run them.
There is no part of Native DTS that will do this for you though.
Allan
"Sami" <s8a2m9i1_i5s1l9a6m@.hotmail.com> wrote in message
news:s8a2m9i1_i5s1l9a6m@.hotmail.com:

> Hello,
> I was successfully able to import all the tables from a SQLBase db to MSSQL.
> Now i would also like to import all the indexes for the tables.
> How can I do that?
> --
> Regards,
> Sami
> [Remove Numbers from e-mail address to use it]

Wednesday, March 7, 2012

How can I hide mssql server system database?

Dear All,

I m using mssql server 2005, when i create a user account for mssql and then use this account to login via management studio. It will show all the system databases and other client databases. How can i hide those databases and allow the client to see their own databases.

Regards,

Ricky

You can hide all databases (other than system databases) by revoking VIEW ANY DATABASE permission from public server role. But you cannot tweak Management Studio to only show certain databases.

Thanks
Laurentiu

|||

Hi Laurentiu

Could you tell me the basic steps (sql statements ) that can allow the clients only its related databases. Because i use a sa account to run "DENY VIEW ANY DEFINITION TO public", the result is incorrect.

Regards,

Ricky

|||

Hello,

In order to see who all have access to 'View Any Database' Permission, you can use the following query

SELECT l.name as grantee_name, p.state_desc, p.permission_name
FROM sys.server_permissions AS p JOIN sys.server_principals AS l
ON p.grantee_principal_id = l.principal_id
WHERE permission_name = 'VIEW ANY DATABASE' ;

and to DENY access to public you can use the following syntax

DENY VIEW ANY DATABASE TO PUBLIC

|||

The problem is that what are the related databases for a client is not an easy to answer question: whether a user can or cannot access the database cannot be determined without accessing the database. Testing the user access for all databases will not be efficient if you have hundreds of databases.

If you want to filter databases within SSMS, I don't think there is a way to do that, but the Tools forum is a more appropriate place to get guidance on this issue.

If you want to create your own view that the client can query to see the databases that he has access, you can filter sys.databases using has_dbaccess:

select name from sys.databases where has_dbaccess(name) = 1

Thanks
Laurentiu

|||

I have the opposite problem. When using SSMS on the server itself, I cannot see the system databases tree at all. I tet only "Database Snapshots" and my own database.

However, when accessing this server over a VPN connection, I can see and access the system databases.

I am a Sysadmin and would expect to be able to see everything.

And since the server is running Windows Authentication only, I would expect that my credential are the same, no matter where I login from.

My first guess is that I inadvertantly hid the System Database tree in SSMS, but I see no way to do/undo anything remotely like that.

Per your comment, I remain confused as to how to make them visible. Note that the databases are listed in various dialogs where one would normally select a database (Maint Wizard, for example).

"You can hide all databases (other than system databases) by revoking VIEW ANY DATABASE permission from public server role. But you cannot tweak Management Studio to only show certain databases.

Thanks
Laurentiu"

|||

Can you see the database entries when you query sys.databases? If the catalogs show you the correct information, but SSMS does not, then the issue should be pursued on the Tools forum.

Thanks

Laurentiu

|||

Yes, I can see master, tempdb, model and msdb via "select * from sys.databases".

Will re-post in the Tools forum, thanks.

How can I hide mssql server system database?

Dear All,

I m using mssql server 2005, when i create a user account for mssql and then use this account to login via management studio. It will show all the system databases and other client databases. How can i hide those databases and allow the client to see their own databases.

Regards,

Ricky

You can hide all databases (other than system databases) by revoking VIEW ANY DATABASE permission from public server role. But you cannot tweak Management Studio to only show certain databases.

Thanks
Laurentiu

|||

Hi Laurentiu

Could you tell me the basic steps (sql statements ) that can allow the clients only its related databases. Because i use a sa account to run "DENY VIEW ANY DEFINITION TO public", the result is incorrect.

Regards,

Ricky

|||

Hello,

In order to see who all have access to 'View Any Database' Permission, you can use the following query

SELECT l.name as grantee_name, p.state_desc, p.permission_name
FROM sys.server_permissions AS p JOIN sys.server_principals AS l
ON p.grantee_principal_id = l.principal_id
WHERE permission_name = 'VIEW ANY DATABASE' ;

and to DENY access to public you can use the following syntax

DENY VIEW ANY DATABASE TO PUBLIC

|||

The problem is that what are the related databases for a client is not an easy to answer question: whether a user can or cannot access the database cannot be determined without accessing the database. Testing the user access for all databases will not be efficient if you have hundreds of databases.

If you want to filter databases within SSMS, I don't think there is a way to do that, but the Tools forum is a more appropriate place to get guidance on this issue.

If you want to create your own view that the client can query to see the databases that he has access, you can filter sys.databases using has_dbaccess:

select name from sys.databases where has_dbaccess(name) = 1

Thanks
Laurentiu

How can I hide mssql server system database?

Dear All,

I m using mssql server 2005, when i create a user account for mssql and then use this account to login via management studio. It will show all the system databases and other client databases. How can i hide those databases and allow the client to see their own databases.

Regards,

Ricky

You can hide all databases (other than system databases) by revoking VIEW ANY DATABASE permission from public server role. But you cannot tweak Management Studio to only show certain databases.

Thanks
Laurentiu

|||

Hi Laurentiu

Could you tell me the basic steps (sql statements ) that can allow the clients only its related databases. Because i use a sa account to run "DENY VIEW ANY DEFINITION TO public", the result is incorrect.

Regards,

Ricky

|||

Hello,

In order to see who all have access to 'View Any Database' Permission, you can use the following query

SELECT l.nameas grantee_name, p.state_desc, p.permission_name
FROMsys.server_permissionsAS p JOINsys.server_principalsAS l
ON p.grantee_principal_id = l.principal_id
WHERE permission_name ='VIEW ANY DATABASE';

and to DENY access to public you can use the following syntax

DENY VIEW ANY DATABASE TO PUBLIC

|||

The problem is that what are the related databases for a client is not an easy to answer question: whether a user can or cannot access the database cannot be determined without accessing the database. Testing the user access for all databases will not be efficient if you have hundreds of databases.

If you want to filter databases within SSMS, I don't think there is a way to do that, but the Tools forum is a more appropriate place to get guidance on this issue.

If you want to create your own view that the client can query to see the databases that he has access, you can filter sys.databases using has_dbaccess:

select name from sys.databases where has_dbaccess(name) = 1

Thanks
Laurentiu

|||

I have the opposite problem. When using SSMS on the server itself, I cannot see the system databases tree at all. I tet only "Database Snapshots" and my own database.

However, when accessing this server over a VPN connection, I can see and access the system databases.

I am a Sysadmin and would expect to be able to see everything.

And since the server is running Windows Authentication only, I would expect that my credential are the same, no matter where I login from.

My first guess is that I inadvertantly hid the System Database tree in SSMS, but I see no way to do/undo anything remotely like that.

Per your comment, I remain confused as to how to make them visible. Note that the databases are listed in various dialogs where one would normally select a database (Maint Wizard, for example).

"You can hide all databases (other than system databases) by revoking VIEW ANY DATABASE permission from public server role. But you cannot tweak Management Studio to only show certain databases.

Thanks
Laurentiu"

|||

Can you see the database entries when you query sys.databases? If the catalogs show you the correct information, but SSMS does not, then the issue should be pursued on the Tools forum.

Thanks

Laurentiu

|||

Yes, I can see master, tempdb, model and msdb via "select * from sys.databases".

Will re-post in the Tools forum, thanks.

How can I handle OnError event in my stored proc.

Dear All:
I want to ask how can I handle OnError events in stored procedure in MSSQL.
Actually I wanted to place some Rollback procedure on this.
Can you suggest some methods for me?
KEVINfrom BOL

C. Use @.@.ERROR to check the success of several statements
This example depends on the successful operation of the INSERT and DELETE statements. Local variables are set to the value of @.@.ERROR after both statements and are used in a shared error-handling routine for the operation.

USE pubs
GO
DECLARE @.del_error int, @.ins_error int
-- Start a transaction.
BEGIN TRAN

-- Execute the DELETE statement.
DELETE authors
WHERE au_id = '409-56-7088'

-- Set a variable to the error value for
-- the DELETE statement.
SELECT @.del_error = @.@.ERROR

-- Execute the INSERT statement.
INSERT authors
VALUES('409-56-7008', 'Bennet', 'Abraham', '415 658-9932',
'6223 Bateman St.', 'Berkeley', 'CA', '94705', 1)
-- Set a variable to the error value for
-- the INSERT statement.
SELECT @.ins_error = @.@.ERROR

-- Test the error values.
IF @.del_error = 0 AND @.ins_error = 0
BEGIN
-- Success. Commit the transaction.
PRINT "The author information has been replaced"
COMMIT TRAN
END
ELSE
BEGIN
-- An error occurred. Indicate which operation(s) failed
-- and roll back the transaction.
IF @.del_error <> 0
PRINT "An error occurred during execution of the DELETE
statement."

IF @.ins_error <> 0
PRINT "An error occurred during execution of the INSERT
statement."

ROLLBACK TRAN
END
GO

How can i go to my SQL Query Manager

anybody can help me how to get into the SQL Query Manager. I downloaded already the MSSQL Server 2000 and it's already running.

efrend/l mssql? from where?|||yes, MSSQL. I'm wondering on how can i go to my SQL Server Enterprise Manager (Console Root). I wnat to create a database for my application.|||where did you d/l ms sql from?|||from MSDE 2000 for Developers Using Visual Studio .NET. the fike name is sql2kdesksp3.exe.|||from MSDE 2000 for Developers Using Visual Studio .NET. the file name is sql2kdesksp3.exe. why? does it matter where i downloaded the exe file? Am confused.

Friday, February 24, 2012

How Can I Get Client User Ip Number

Hi,
Use Mssql,
How can I,
Get Client User Ip Number in Mssql
Thanks,I don't know of a direct way to do this is TSQL.
There is a workaround, in your ADO connection string set the workstation id
= 123.123.13.233
Then in TSQL you can retreive this with SELECT HOST_NAME()
HTH. Ryan
"kimsin_sen" <kimsinsen@.hotmail.com> wrote in message
news:%23UYiMISEGHA.1264@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Use Mssql,
> How can I,
> Get Client User Ip Number in Mssql
> Thanks,
>|||I Can Try This Code
In Sql Query Analyzer
SELECT HOST_NAME()
Return Machine Name
No Ip Number
"Ryan" <Ryan_Waight@.nospam.hotmail.com> wrote in message
news:e1oolNSEGHA.2728@.TK2MSFTNGP14.phx.gbl...
I don't know of a direct way to do this is TSQL.
There is a workaround, in your ADO connection string set the workstation id
= 123.123.13.233
Then in TSQL you can retreive this with SELECT HOST_NAME()
HTH. Ryan
"kimsin_sen" <kimsinsen@.hotmail.com> wrote in message
news:%23UYiMISEGHA.1264@.TK2MSFTNGP09.phx.gbl...
> Hi,
> Use Mssql,
> How can I,
> Get Client User Ip Number in Mssql
> Thanks,
>|||Did you try changing the ADO connection string on the client 1st or is this
not an option.?
HTH. Ryan
"kimsin_sen" <kimsinsen@.hotmail.com> wrote in message
news:uDEX5USEGHA.1508@.TK2MSFTNGP15.phx.gbl...
>I Can Try This Code
> In Sql Query Analyzer
> SELECT HOST_NAME()
> Return Machine Name
> No Ip Number
>
> "Ryan" <Ryan_Waight@.nospam.hotmail.com> wrote in message
> news:e1oolNSEGHA.2728@.TK2MSFTNGP14.phx.gbl...
> I don't know of a direct way to do this is TSQL.
> There is a workaround, in your ADO connection string set the workstation
> id
> = 123.123.13.233
> Then in TSQL you can retreive this with SELECT HOST_NAME()
> --
> HTH. Ryan
>
> "kimsin_sen" <kimsinsen@.hotmail.com> wrote in message
> news:%23UYiMISEGHA.1264@.TK2MSFTNGP09.phx.gbl...
>
>