Combine CTE “WITH” and a “WITH XMLNAMESPACES…” in SQL Server

Has anyone managed to create a CTE in SQL Server’s T-SQL that also includes a WITH XMLNAMESPACES declaration? It seems both WITH keywords insist on being the “first in the T-SQL batch”, and that doesn’t really work…. I tried: WITH XMLNAMESPACES(‘’ as ns) WITH CTEQuery AS ( SELECT (list of fields) FROM dbo.MyTable WHERE (conditions) […]

SQL Server, Using UNION ALL for multiple tables then paging implementation

I need help also about paging and using UNION ALL for multiple tables: How do i implement an optimized paging when joining multiple tables using UNION ALL and returning only specific number of rows… declare @startRow int declare @PageCount int set @startRow = 0 set @PageCount = 20 set rowcount @PageCount select Row_Number() OVER(Order by […]

Linq distinct record containing keywords

I need to return a distinct list of records based on a car keywords search like: “Alfa 147” The problem is that, as I have 3 “Alfa” cars, it returns 1 + 3 records (it seems 1 for the Alfa and 147 result, and 3 for the Alfa result) EDIT: The SQL-Server Query look something […]

Option Recompile makes query fast – good or bad?

I have two SQL queries with about 2-3 INNER JOINS each. I need to do an INTERSECT between them. Problem is that indiividually the queryes work fast, but after intersecting take about 4 seconds in total. Now, if I put an OPTION (RECOMPILE) at the end of this whole query, the query works great again […]

MS SQL server – convert HEX string to integer

This answer to what looks like the same question: Convert integer to hex and hex to integer ..does not work for me. I am not able to go to a HEX string to an integer using MS SQL server 2005 CAST or CONVERT. Am I missing something trivial? I have searched extensively, and the best […]

SQL – improve NOT EXISTS query performance

Is there a way I can improve this kind of SQL query performance: INSERT INTO … WHERE NOT EXISTS(Validation…) The problem is when I have many data in my table (like million of rows), the execution of the WHERE NOT EXISTS clause if very slow. I have to do this verification because I can’t insert […]

Converting Access Database to MSSQL Database Using Microsoft SQL Server Migration Assistant for Access

I am trying to convent a Ms Access Database to MS SQL 2012, using Microsoft SQL Server Migration Assistant for Access version 6.0 but each time i try to convert it an error pops up. any ideas how i can solve the problem i reinstall the program Microsoft SQL Server Migration Assistant for Access , […]

Using Kerberos S4U extensions (introduced in Java 8) to connect to database using JDBC

It’s been a while since I coded in Java, so I may be missing something obvious. I want to connect to the database (I need to support many – SQL Server, MySQL, etc.) via JDBC. However, I want to use Microsoft S4U Java extension support that was added in Java 8 to achieve Kerberos delegation. […]

tsql script to add delete cascade to existing tables

is there a script that can be used to enable cascaded deletion for existing tables. Thanks.

Where to find a good reference when choosing a database?

I and two others are working on a project at the university. In the project we are making a prototype of a MMORPG. We have decided to use PostgreSQL as our database. The other databases we considered were MS SQL-server and MySQL. Does somebody have a good reference which will justify our choice? (preferably written […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.