jdbc:sybase:Tds:host:5000

 

Add space to a database:

 

alter database master on default = “8M”

 

Dump a database:

 

dump database db to db_dump

 

Create group:

 

sp_addgroup

 

Create login:

 

exec sp_addlogin 'dte_au_pub', 'dte_au_pub01', @defdb = 'DTE_db', @deflanguage = 'us_english', @auth_mech = 'ANY'

go

USE DTE_db

go

exec sp_adduser 'dte_au_pub' , 'dte_au_pub' , 'operations'

go

 

 

Change user group

 

sp_changegroup TraceReadWrite, trace_proc

 

 

Sybase Date Formats for conversion

0 100 mon dd yyyy hh:miAM (or PM)

1 101 mm/dd/yy

2 102 yy.mm.dd

3 103 dd/mm/yy

4 104 yy.mm.dd

5 105 dd-mm-yy

6 106 dd mon yy

7 107 mon dd, yy

8 108 hh:mm:ss

9 109 mon dd yyyy hh:mi:ss:mmmAM (or PM)

10 110 dd-mm-yy

11 111 yy/mm/dd

12 112 yymmdd

 

 

Stripping date part from a timestamp

 

convert (DATETIME, convert (VARCHAR, datepart(hh, getdate())) + ':' + convert (VARCHAR, datepart(mi, getdate())) + ':' + convert (VARCHAR, datepart(ss, getdate())))

 

Use of cursor

 

declare c cursor for

select item, tran_num, control_num from items_s1

open c

fetch c into @item, @tran_num, @control_num

while (@@sqlstatus != 2)
begin

fetch c into @item, @tran_num, @control_num

end

 

Turn on identity insert:

 

set identity_insert tablename on

 

 

Alter table column:

 

alter table tab1 modify col1 varchar(40) not null

alter table tab1 replace col1 default 'N'

 

Find uptime

 

select @@boottime

 

Get object permissions.

 

sp_helprotect obj_name

 

Put delete in loop to avoid filling transaction log

 

 

SET rowcount 1000
GO
WHILE 1=1
BEGIN
delete.....

IF (@@rowcount < 1) BREAK
END