PrestwoodBoards Knowledgebase:


These FAQs are contributed by you (our online community members). They are organized by our knowledge base topics. Specifically, by the DBA sub-topics.

Expand All

4 DBA, Databases, & Data FAQs

Group: DBA, Databases, & Data

Topic: ANSI SQL Scripting

-Collapse +Expand Q1. Is there a way to reverse order a select statement?

Yes. Use the DESC keyword in your order by clause on each column you want ordered descending. Use ASC for ascending.

select * from Customer 
Order by Age Desc, City Asc, State Asc

Topic: Microsoft SQL Server

-Collapse +Expand Q2. What is the differences between Char, NChar, VarChar, and NVarChar?

A Char field is a text field of a specific length. For example, a Char(50) field takes up 50 characters of storage in most databases even if you only store 1 character in it., or even none. 

A VarChar field is a text field of variable length. For example, a VarChar(50) field can be up to 50 characters but if less is stored, the length of the field is somewhat less than 50. If you only store 1 character in a VarChar, then generally only 1 character of space is taken up in storage.

The "N" in NChar and NVarChar stands for National character which means you can store unicode text. NChar and NVarChar take up twice as much storage space.

-Collapse +Expand Q3. Are views in Microsoft SQL Server editable?
Answer: Yes and no. Yes, there is nothing in MS SQL Server preventing a client from writing to the underlying tables involved in an view. Therefore, it is left up to the tool accessing the view. Many tools allow you to edit views in SQL Server including ASP Classic, ASP.Net, VB, Access, etc. Some tools, like SQL Server Management Studio allow you to edit tables, but not views.

Topic: MS SQL 2005

-Collapse +Expand Q4. How do you store BLOBs (Binary Large Objects) in Microsoft SQL Server?

BLOBs (Binary Large Objects) are collections of data that can be stored as a single entity in a database. In Microsoft SQL Server, BLOBs are stored using the text, ntext, and image data types.

  • The text data type stores a variable length of non-unicode data up to 231 - 1 characters.
  • The ntext data type stores a variable length of unicode data up to 230 - 1 characters. The storage size, in bytes, is twice the amount of characters.
  • The image data type is used to store image files smaller than 231 - 1 bytes.
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 11/19/2019