17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Chapter 12: Stored Procedures<br />

392<br />

not from the C world, these may seem a little odd to you. All the placeholders start with the % sign and<br />

are then coded for the kind of information you’ll be passing to them, as shown in the following table.<br />

Placeholder Type Indicator Type of Value<br />

D Signed integer; Books Online indicates that it is an acceptable<br />

choice, but I’ve had problems getting it to work as expected<br />

O Unsigned octal<br />

P Pointer<br />

S String<br />

U Unsigned integer<br />

X or x Unsigned hexadecimal<br />

In addition, there is the option to prefix any of these placeholder indicators with some additional flag<br />

and width information:<br />

Flag What It Does<br />

- (dash or<br />

minus sign)<br />

Left-justify; only makes a difference when you supply a fixed width<br />

+ (plus sign) Indicates the positive or negative nature if the parameter is a signed<br />

numeric type<br />

0 Tells <strong>SQL</strong> <strong>Server</strong> to pad the left side of a numeric value with zeros until it<br />

reaches the width specified in the width option<br />

# (pound sign) Applies only to octal and hex values; tells <strong>SQL</strong> <strong>Server</strong> to use the appropriate<br />

prefix (0 or 0x) depending on whether it is octal or hex<br />

‘ ‘ Pads the left of a numeric value with spaces if positive<br />

Last, but not least, you can also set the width, precision, and long/short status of a parameter:<br />

❑ Width — Set by simply supplying an integer value for the amount of space you want to hold for<br />

the parameterized value. You can also specify a *, in which case <strong>SQL</strong> <strong>Server</strong> will automatically<br />

determine the width according to the value you’ve set for precision.<br />

❑ Precision — Determines the maximum number of digits output for numeric data.<br />

❑ Long/Short — Set by using an h (short) or I (long) when the type of the parameter is an integer,<br />

octal, or hex value.

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

Saved successfully!

Ooh no, something went wrong!