26.02.2015 Views

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

DOT NET Interview Questions - DotNetSpider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

UNION SQL syntax is used to select information from two tables.But it selects only<br />

distinct records from both the table. , while UNION ALL selects all records from both<br />

the tables.<br />

Note :- Selected records should have same datatype or else the syntax will not work.<br />

(I)How can you raise custom errors from stored<br />

procedure ?<br />

The RAISERROR statement is used to produce an ad hoc error message or to retrieve a<br />

custom message that is stored in the sysmessages table. You can use this statement with<br />

the error handling code presented in the previous section to implement custom error<br />

messages in your applications. The syntax of the statement is shown here.<br />

RAISERROR ({msg_id |msg_str }{,severity ,state }<br />

[ ,argument [ ,,...n ] ] ))<br />

[ WITH option [ ,,...n ] ]<br />

A description of the components of the statement follows.<br />

msg_id :-The ID for an error message, which is stored in the error column in sysmessages.<br />

msg_str :-A custom message that is not contained in sysmessages.<br />

severity :- The severity level associated with the error. The valid values are 0–25. Severity<br />

levels 0–18 can be used by any user, but 19–25 are only available to members of the<br />

fixed-server role sysadmin. When levels 19–25 are used, the WITH LOG option is required.<br />

state A value that indicates the invocation state of the error. The valid values are 0–127.<br />

This value is not used by SQL Server.<br />

Argument, . . .<br />

One or more variables that are used to customize the message. For example, you could<br />

pass the current process ID (@@SPID) so it could be displayed in the message.<br />

WITH option, . . .<br />

The three values that can be used with this optional argument are described here.<br />

LOG - Forces the error to logged in the SQL Server error log and the NT application log.<br />

NOWAIT - Sends the message immediately to the client.<br />

207

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!