Blog Posts on tsql




Percent:
 
Distinct:
 


The Easy way of changing Collation of all Database objects in SQL Server by Raymund Macaalay's Dev Blog on Dec 19, 2011Did you encountered a problem where you wanted to change your database collation to default or even just changing it to a different type? I guess what you had initially done (like me) was to change the collation of the Database well that does not qui...



Simple TSQL and C# Entity Generator for S#arp Architecture by Raymund Macaalay's Dev Blog on Sep 16, 2011Recently we started a big project which uses S#arp Architecture and for those who does not know what it is you can go to the site (http://www.sharparchitecture.net/) and have a read, but in a gist it is an open source architectural foundation that us...



Singularize Function in TSQL by Raymund Macaalay's Dev Blog on Sep 13, 2011Today I was trying to make a code generator for one of our projects to make our lives easier, basically I was trying to list all objects on our SQL Server database and Print a C# code output which I can then save as a .cs file, all went fine until I...



How to: assign IDs/SortVal values using ROW_NUMBER() by Being (me) on Mar 29, 2010I have a lookup table L_MyLookup with columns ID and NAME.Later, my client wanted a SORTVAL column because they want to define the order of the values through that column instead of ID.So add the SORTVAL columnupdate the valuesalter SORTVAL to become...



TSQL Latin Collation Error by Being (me) on Oct 1, 2009Error encountered:Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.I'm not sure if it's as convenient with the earlier versions but SQL Server 2008 allows you to easily...



Enabling Database Mail via TSQL by on Sep 28, 2009-- allow advanced optionssp_configure 'show advanced options', 1; GO RECONFIGURE; GO-- enable database mail (0 disables , 1 enables) sp_configure 'Database Mail XPs', 1; GO RECONFIGURE GO-- hide advanced options againsp_configure 'show advanced optio...



TSQL Latin Collation Error by Email Forward on Aug 17, 2009Error encountered:Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.I'm not sure if it's as convenient with the earlier versions but SQL Server 2008 allows you to easily...



TSQL: Rename Tables or Columns by Being (me) on Jul 21, 2009To rename a table:EXEC sp_rename @objname='{TableName}', @newname='{NewTableName}', @objtype='TABLE'To rename a column:EXEC sp_rename @objname='{TableName}.{ColumnName}', @newname='{NewColumnName}', @objtype='COLUMN'Note: you may refrain from specify...



TSQL Error: EXECUTE permission denied on XML Column by Being (me) on Jun 24, 2009I got this error when I created a restricted login for a user. We've only recently been optimizing the use of XML data types in SQL Server so it took me an hour to find the solution -- not on MSDN but on some other programmer's blog (gave my thanks o...



TSQL Add/Delete User, Login, Role (Code sample) by Being (me) on Jun 24, 2009The first group of code uses the system stored procedures that are still currently supported but will soon be deprecated in future updates. The structure of the following codes (1) try to drop the existing login/role/user; (2) create a new login/role...