Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

BIT Barbarian

After working in the mortgage industry for 7 years, I transitioned into Business Intelligence and began learning SQL and .NET. My goal is to integrate my business knowledge into my development to intelligently analyze and find solutions to problems. Blogging offers me an option to share what I've learned as well as receive feedback on better practices and solutions.

Archives: May 2013

TSQL Snippet for viewing basic info on database principals and their permissions

Quick snippet I put together for reviewing basic info on database users/principals, permissions, and members if the principal is a role.

/*******************************************************
Some Basic Info on Database principals, permissions, 
explicit permissions, and if role, who is in this role currently
*******************************************************/
;
with
	roleMembers
	as (
			select
				drm.role_principal_id
				,dp.principal_id
				,dp.name…

Read more

0 comments, 448 reads

Posted in BIT Barbarian on 31 May 2013

A moment of void in the cranium reveals a recursive computed column with an esoteric message

Msg 402, Level 16, State 1, Line 67
The data types varchar and void type are incompatible in the add operator.
I came across this error today when I accidentally used a computed column in a temp table, that referenced itself. This very unhelpful message was caused by referring to… Read more

0 comments, 374 reads

Posted in BIT Barbarian on 30 May 2013

View computed columns in database

Snippet to quickly view computed column information. You can also view this by doing a “create table” script. This however, was a little cleaner to read and view for me.

select
	database_name = db_name()
	,object_schema_name = object_schema_name( object_id )
	,object_name = object_name( object_id )
	,full_object_name = object_schema_name( object_id ) +…

Read more

0 comments, 219 reads

Posted in BIT Barbarian on 22 May 2013

On how to Googlify your SQL statements for future searching

For sake of future generations, let’s begin to reduce typing and reuse code we’ve built. I think we can all agree that TSQL statements are often repeated. Ideally, snippets should be created to reduce repeated typing and let us focus on logic and content. However, some statements may not really… Read more

0 comments, 519 reads

Posted in BIT Barbarian on 22 May 2013

Get synonym definitions for all databases in server

If you want to audit your enviroment to look at all your synonyms and see where they are pointing, you can use exec sys.sp_MSforeachdb to loop through databases, and even filter. It will save some coding. However, my research indicates it is probably a bad practice to rely on this… Read more

0 comments, 337 reads

Posted in BIT Barbarian on 21 May 2013

Calculating the next beginning of month and the current end of month

Handling dates is always a fun challenge in T-SQL! Finding the current end of month and next months beginning of month is straight forward, but I like to find new ways to do things that take less coding, and hate date conversions that require a lot of manipulation of characters… Read more

0 comments, 717 reads

Posted in BIT Barbarian on 1 May 2013