dcsimg
Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
SQL Scripts & Samples
Tips
» Database Forum
» Slideshows
» Sitemap
Free Newsletters:
DatabaseDaily  

By submitting your information, you agree that databasejournal.com may send you databasejournal offers via email, phone and text message, as well as email offers about other products and services that databasejournal believes may be of interest to you. databasejournal will process your information in accordance with the Quinstreet Privacy Policy.

News Via RSS Feed


Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Oct 6, 2000

Standardize Titles and Headings

By Alan Enderby

Here's a script that will help you standardize those titles & headings.

Drop proc rp_title
go
create proc rp_title
@t varchar(255) , /* Title to box & display */
@s char(1)='*' , /* Box character */
@center bit=0 , /* Center text in box */
@lpad int=0 , /* Shift box to right */
@timestamp bit=0 , /* display date/time */
@date_format int=0 /* format for date/time */
as

DECLARE @pad varchar(80) SELECT @pad=''
IF @lpad>0 SELECT @pad=replicate(' ',@lpad)

IF @timestamp=1 SELECT @t=@t + ' (' +
convert(varchar(25),getdate(),@date_format) + ')'

DECLARE @c varchar(255)
SELECT @c=@pad+replicate(@s,82) ,
@t=@pad+@s +
convert(char(80),replicate(' ',case when @center=1 then
40-(datalength(@t)/2)else 1 end) + @t) + @s
PRINT ' '
PRINT @c
PRINT @t
PRINT @c
PRINT ' '

RETURN 0


go
exec rp_title 'Hello there',@lpad=0,@center=0,@s='#'
exec rp_title 'Hello
there',@lpad=20,@center=0,@timestamp=1,@date_format=3
exec rp_title 'Hello there',@lpad=0,@center=1
exec rp_title 'Hello there',@lpad=20,@center=1





MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM