Blog Posts on database mysql mssql postgresql oracle sql
Percent:
How to select all the triggers in an mssql table by czetsuya's tech on May 20, 2012I've found this script somewhere on the internet, just for reference: SELECT [Table] = OBJECT_NAME(o.parent_obj), [Trigger] = o.[name], [Type] = CASE WHEN ( SELECT cmptlevel FROM master.dbo.sysdatabases WHERE [name] = DB_NAME() ) = 80 T...
How to enable slf4j logging in glassfish 3.1.1 by czetsuya's tech on May 3, 2012This blog entry will try to setup slf4j as the main logger for glassfish 3.1.1What you need:1.) Glassfish 3.1.1 (zipped)2.) Download the ff jars: a.) slf4j-api.jar b.) jul-to-slf4j.jar c.) logback-classic.jar&nbs...
How to create a Connection Pool for PostgreSql on Glassfish 3.1.1 by czetsuya's tech on May 1, 2012This tutorial assumes that 1.) You already have Glassfish 3.1.1 installed. https://blogs.oracle.com/java/entry/glassfish_3_1_1 2.) Create and start a Glassfish domain a.) asadmin create-domain czetsuya b.) asadmin start-domain czetsuya...
How to execute a group by and sum query in entity framework by czetsuya's tech on Mar 3, 2012The following code is the native sql with the converted code in entity framework. It queries the sum of quantity group by branch, model, year and week no.//native sqlselect weekyear, weekno, branchid, modelid, sum(quantity) from selloutmobileswhere w...
How to alter bit and date column's default value in MSSQL by czetsuya's tech on Jan 24, 2012Aside from using the SQL Designer, you can alter a bit and date column's default value.ALTER TABLE TableName ADD CONSTRAINT TableName_Disabled DEFAULT 0 FOR DisabledALTER TABLE TableName ADD CONSTRAINT TableName_DateCreated DEFAULT getdate() FOR Date...
Executing a linq query with a bridge table like aspnet_Users and aspnet_Roles by czetsuya's tech on Dec 20, 2011Using model first approach, we add aspnet_Users, aspnet_Roles and aspnet_UsersInRoles in the edmx file. But why is aspnet_UsersInRoles missing? It's because aspnet_Users has one-to-many relationship to aspnet_Roles. To get the role of the user, we ne...
Calling MSSQL's aspnet_Membership_CreateUser stored procedure by czetsuya's tech on Dec 17, 2011Here's how you would want to call mssql's aspnet_Membership_CreateUser method:DECLARE @return_value int, @UserId uniqueidentifier, @nowUtc datetime, @now datetime set @nowUtc = getutcdate() set @now = getdate()EXEC @return_value = [dbo].[aspnet_M...
The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. by czetsuya's tech on Dec 6, 2011Normally you will encounter this issue if you generate an sql script of an aspnet_database without including the data. To resolve this you have 2 options:1.) Execute c:\windows\microsoft.net\framework\v4.xxx\aspnet_regsql.exe, and just follow through...
Passing an array of objects to mssql stored procedure by czetsuya's tech on Nov 12, 2011Oftentimes you need to pass an array of objects (could be ids, types, etc) in an mssql stored procedure that you either need to insert into a table or use as filter. The following codes will explain the latter:Pass an array of integers:ALTER PROCEDUR...
Insert an md5 password in mssql by czetsuya's tech on Nov 7, 2011To md5 a string in mssql we execute this query:select HASHBYTES('MD5', 'password')//But this has a problem because it returns a VarBinary data type which is a garbled text. So it should be converted first to NVarchar:SELECT CONVERT(NVARCHAR(32),HashB...


