Tuesday, March 14, 2017

Restrict user by ip address in sybase

SQL
Maybe usefull to use to restrict users by ip address
create group restrictedusergroup
go
create proc restrictuser as
declare @ip char(15)
select @ip = ipaddr from master..sysprocesses where spid = @@spid
if @ip in ('10.160.43.46','10.160.43.45', and so on)
begin
select syb_quit()
end
go
sp_modifylogin dbo_db,'dbo_db',restrictuser
go
grant execute on restrictuser to restrictedusergroup
go
I guess this would have to be set for all the logins that we want to restrict the
ipaddress too.
Execute sp_modifylogin

Cross Platform dump in sybase

Cross platform dump
http://www.sybase.com/content/1033627/18XPDL_1253_WP.pdf
after you run the code dump the database and copy to the location once you have done
this you can then load the database.
Sample of code to run
USE master
go
EXEC sp_dboption 'db','single user',true
go
USE master
go
EXEC sp_dboption  'db','dbo use only',true
go
USE cats_tky_dev1
go
CHECKPOINT
go
sp_flushstats
go
sp_flushstats
go
USE master
go
EXEC sp_dboption 'db','single user',false
go
USE master
go
EXEC sp_dboption'db','dbo use only',false
go
USE db
go
CHECKPOINT
go
sp_flushstats
go
sp_flushstats
go
USE master
go
USE master
go
EXEC sp_dboption 'db2','single user',true
go
USE master
go
EXEC sp_dboption 'db2','dbo use only',true
go
USE db2
go
CHECKPOINT
go
sp_flushstats
go
sp_flushstats
go
USE master
go
EXEC sp_dboption 'db2','single user',false
go
USE master
go
EXEC sp_dboption 'db2','dbo use only',false
go
USE db2
go
CHECKPOINT
go
sp_flushstats
go
sp_flushstats
go
USE master
go

Performance and Tuning


MEMUSAGE:
This is useful for validation your SQLserver memory configuration, dbcc
memusage reports three pieces of information.
The current allocation of memory within SQL server
Up to the 20 largest tables and or index currently in datacache.
Up to the 20 largest sored procs currently in procedure cache.
Examble for the code.
dbcc traceon (3604)
go
dbcc memusage
go
SP_SYSMON:
Sp_symon is a specialized system proc used to produce a statically report on the
sql server it will provide an overall performance picture for the adaptive
server(ASE) it is run on it will only work on system 11 and above.
The sytax for it is as followed

Sp_sysmon interval , section , applmon
The interval should be entered in “hh:mm:ss” format
It is not wise to run this on a daily basis as the system over head is to great this is
used for spot checks to see how the system is running. And example is to run
Sp_sysmon “00:15:00”