Tag SQL Server instance as DEV, TEST, STAGING, PRODUCTION etc -


we have few sql server boxes , instances running, wish our code identify if running on development, test or production server instance of sql server. based on code take path.

we have few choices of hard coding sql server name , instance

  1. case when @@servername= abc/xyz dev , on.

  2. check specific letters in name or instance when (charindex('dev', @@servername, 1) > 0 ) dev , on.

  3. select type table:

    select @vcservertype = vcservertype  master.dbo.tbl_serverdetails when @vcservertype = 'dev' , on. 

but rely on assumption dev found or server name contains letters, creating table in database exist in instances..

should have been easier if there exists property set/identify @ instance level.. suggestions (apart above)

is there way in sql server, can set property or tag them dev, test or production?

there tab named "extended properties" on database level in it's properties.

you can set them sys.sp_addextendedproperty

and read them instance in ado.net answer question shows.

edit: didn't see asked tag on instance-level or maybe on server level. sorry not directly addressing that. should able achieve wish through properties on db-level, shouldn't you?


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -