mssql Interview Questions and Answers


 

Interview Question in mssql

How to create database application in visual studio 2005

what language? the basic steps are

1. create a user interface
2. create a database (not in visual studio but mssql)
3. create a data adaptor to hook into the database
4. create sqlconnections to your database controls

dougc

PHP and MS-SQL: How to prevent SQL injection

I use PHP and Microsoft SQL Server 2000 to build dymanic pages. Assume I have code like this:

$id = $_POST['id'];
$query = "select * from employees where id = '$id'";
$result = mssql_query($query);

Is this safe from SQL injection?
If not, how to prevent it?

How to migrate to sql server 2000 from access and which area involve changes? front end is visual basic 6

Migration involves lots of complexities, depending upon the data. There are lots of third party tools available to migrate. From a programming point of view there are not mcuh difference. But from database point of view, there are lots of difference. Check this link. You can find some information regarding that.
http://www.mssqlcity.com/Articles/Compar...

How to connect PHP with Sql Server 2000

Thats pretty straighforward..
Connect to the server using mssql_connect ( servername, username, password)
However, read this note from php manual:
______________________________________...
If you use PHP on Windows with Apache as a web server, you may get problems with authentication to MS SQL Server even when you supply all valid credentials.
Check your php.ini file:
; Use NT authentication when connecting to the server
mssql.secure_connection = On
If you have secure_connection = On, make sure that you provide valid credentials in the properties for Apache service in the System Services box. Then you should not send DB username and password from your script to MSSQL Server.
If you want to use specific credentials from a PHP script, then set mssql.secure_connection = Off in your php.ini
____________________________________

If you explicitly state the problem you are facing (error messages), people can help you better.

How to connect to MS SQL server 2000 from php

I copied ntwdblib.dll 2000.80.194.0 from MS Sql and pasted in php.
Added the following to php.ini file
sql.safe_mode = On
mssql.allow_persistent=1
mssql.max_persistent=-1
mssql.max_links=-1
mssql.min_error_severity=10
mssql.min_message_severity=10
mssql.compatability_mode=0
mssql.connect_timeout=5
mssql.timeout=60
mssql.textsize=-1
mssql.textlimit=-1
mssql.batchsize=0
mssql.datetimeconvert=1
mssql.max_procs=-1
msssql.secure_connection = On
and uncommented
extension=php_mbstring.dll


Then I wrote the following code

$myServer = "ITDEPTCOMP2";
$myUser = "sa";
$myPass = "password";
$myDB = "Northwind";
while(!$connection){
@$connection = mssql_connect('ITDEPTCOMP2','sa','passwo...
}
echo "connect";
$db = mssql_select_db('Northwind',$connection) or die("Error selecting the database");

But it is not working.

Can you use Php with SQL server 2005? If so, can some one explain it or give links to tuts on how to do it

Yes; you work with it virtually the same way you work with MySQL server and the like. PHP has built-in MSSQL functions, just like it has built-in MySQL functions.

$link = mssql_pconnect( 'host', 'user', 'pass' ) or die( 'Cannot connect') ;
mssql_select_db( 'dbname' ) or die( 'Cannot select db' );

$query = "SELECT * FROM table";

$rs = mssql_query( $query ) or die( 'Cannot run query' );

while( $row = mssql_fetch_array( $rs ) ) {
echo $row['column']."
";
}

When would you use Database snapshot, database mirroring, log shipping and replication in Sql Server 2005

Database Snapshots : create a read-only copy of your database that can be used for reporting, auditing or recovering data.

The primary goal of database mirroring is to increase data availability and allow failover in case a server hosting the database becomes unavailable (e.g as the result of hardware or network failure).
http://www.databasejournal.com/features/...

Log shipping is one of the failover solutions offered by SQL Server 2000. In this context, failover means substituting primary server with a backup (sometimes also referred to as standby) server if the primary hardware becomes unusable. Failover solutions can also be used to provide close to 100% uptime—during primary database or server maintenance and during software upgrades you could use the standby server to continue serving your customers.
http://www.informit.com/articles/article...

Database replication is the creation and maintenance of multiple copies of the same database.
In most implementations of database replication, one database server maintains the master copy of the database and additional database servers maintain slave copies of the database.

I use :
Database snapshot : to make rollback point if some series of query fails.

Database mirroring : I use backup harddisk to make 'life' backup of my database just in case one harddisk is damage.

Log shipping : it's too expensive for my clients, i've never use it.

Database Replication : to move my database to a higher version of database server or to change my database server to another database server eg. from SQL server to MySQL

How do you restore or locate the shortcut for mssql server 2005 beta2 in the start menu

i've uninstalled sql server 2005 beta2 then deleted the shortcut in start menu then after i've reinstalled it, i can't locate it's folder in the start->programs menu but the installation is fine.

How can i select a specific attribute from a view in mssql.if i write select ... than its ok

i have created a view in mssql. i want to select specific attributes from that view. when i write (select *.. where...) then i get all the attributes. but when i write (select [specific attribute]..) then i got an error message.i am using ASP.NET 2.0 with C#. please somebody help me. thanks.....Robin