updated code with sqlserver