sql-server

Alternative approaches to a complicated-ish query in an badly-designed schema

I'm working on integrating some data from a 3rd-Party system into one of my applications (legacy ASP Classic-based web application/SQL 2000) - they have made some poor decisions (IMHO) when it comes to their approach and data structure, though perhaps we might get a chance to refactor at some point... but until then, I have to work with ...

How to connect to sql-server with windows authentication from windows-service?

I have programmed a Windows Service in C# which should connect to an SQL-Server 2005 Express Database with System.Data.SqlClient. As Microsoft prefers to use Windows Authentication over SQL Authentication I tried to connect to the DB with Trusted Conenction / Integrated Security. However that doesn't work as I get a System.Data.SqlClie...

Fluent NHibernate Many-to-One Join on a Substring

I'm trying to map 2 tables together in Fluent Nhibernate, but the only way to join them is based on using the LEFT function on one of the columns. So a SQL join would look like this: select * from TableA INNER JOIN TableB ON LEFT(TableA.ColA, 12) = TableB.ColB Is there any way to map this in NHibernate? ...

Update with Subquery

Hello there, i have a Problem with a query. I have a huge Table with Zipcodes from Germany called 'Postleitzahlen'. There is another table with Companies called 'Firmen' Structure is like this: Firmen ------ ID City State ZipCode Postleitzahlen -------------- ZipCode State Now I want, all empty ( '' or NULL ) State-fields of Firm...

ColdFusion executing unwanted SQL statements

I have an application that loads a vast amount of data from twitter. We have began to notice some performance issues and so I setup SQL Profiler for the applications database. I have noticed the following SQL statement are being executed but do not appear anywhere in my code. Therefore, I am assuming that either SQL Server 2005 or ColdFu...

Need help with a SQL join: Conditional Matching?

I'm joining 2 tables. ACCOUNTS account_number region product 1234 100 AB 2345 0 AB 3456 300 CD 4567 0 CD PRODUCTS product region price AB 100 $1.50 AB 0 $1.25 ...

Do table statistics get updated during the creation of a clustered index?

After I have created a clustered index on a table, is there any point in updating the statistics for that table? Cheers. ...

SQL Server sproc query optimization

I've got an application that generates data for reports that look like: age < 30 | age >=30 | asian | hispanic ----------------------------------------------------------------- clients in prog A | | | ----------------------------------------------------------------- clients in p...

Efficiently finding unique values in a database table

I've got a database table with a very large amount of rows. This table represents messages that are logged by a system. Each message has a message type and this is stored it it's own field in the table. I'm writing a website for querying this message log. If I want to search by message type then ideally I would want to have a drop down b...

Modifying SQL Server Schema Collection

SQL Server XML Schema Collection is an interesting concept and I find it very useful when designing dynamic data content. However as I work my way through implementing Schema Collections, I find it very difficult to maintain them. Schema Collection DDL allows only CREATE and ALTER/ADD nodes to existing schemes. CREATE XML SCHEMA COLLE...

How can I recover Unicode data which displays in SQL Server as ??????

Hi there, I have a database in SQL Server containing a column which needs to contain Unicode data (it contains user's addresses from all over the world e.g. القاهرة‎ for Cairo) This column is an nvarchar column with a collation of database default (Latin1_General_CI_AS), but I've noticed data inserted into it via SQL statements contain...

Changing SQL server compatibility Level

I have a database which was upgraded from 2000 to 2005. Is there any issue using sp_dbcmptlevel to change compatibility level to 90. Will this cause any issues with old queries or stored procedures ...

Is it possible to use ContainsTable to get results for more than one column?

Consider the following table: People FirstName nvarchar(50) LastName nvarchar(50) Let's assume for the moment that this table has a full-text index on it for both columns. Let's suppose that I wanted to find all of the people named "John Smith" in this table. The following query seems like a perfectly rational way to accomplish thi...

blogging software like wordpress for asp.net. IIS7 and Sql Server 2008

i see that wordpress works on LAMP. Does anyone know if there is a software for asp.net with mssqlserver back-end. I am looking for one which i can design with their software and host on my site, not theirs. thanks ...

Create a file in Java for loading into an nvarchar field in SQLServer 2005 using BCP and UTF-16

Hi All, I want to use BCP to load into a SQL Server 2005 table with an nvarchar field using a loader control file. As I understand it, SQL Server 2005 only supports UTF-16 (and I believe it is UTF-16 LE). The file is being output by a Java program. The way I have it currently set up is as follows: An XML format BCP loader file (cre...

Subsonic 3 - Passing null value to stored procedure parameter

Using Subsonic 3.0.0.3 is it feasible to pass a null value to a stored procedures parameter? If so, what is the appropriate way? Details Say I have an sp where one of the parameters has a default value like: CREATE Procedure Test_SPWithNullParams( @p1 int=null, @p2 varchar(50) ) AS SELECT 1 as Stuff Then in my code I want to...

Obfuscate database table names

We're about to undergo a project where we'll be handling highly sensitive data. Apart from encrypting the data I was thinking about obfuscating the table names. So tEmployees would become t58633B7A for example. Would this be a useful to add? after all it's about building layers of security/prevention. P.S. We'll map the obfuscated tabl...

Omitting the Milliseconds in a Date

Hello, When I select from SQL Server, I want to get a date, but omit the millisecond value, and I want it to be as a date type. So if I have a value 1/1/2009 1:23:11.923, I want to omit the millisecond but retain the date type, so that it will be the value 1/1/2009 1:23:11.000 (I know you really can't omit the millisecond value with a ...

Does stsadm backup clear transaction logs?

My database is using the simple recovery model, so the transaction logs are cleared down when it is backed up. If I backup the database as part of a backup using stsadm, will that cause the transaction logs to be cleared? i.e. if I disable the sql server jobs and just keep the database backups that come from stsadm, would that cause my...

Issues with TSQL IN expression

From what I gather about the IN expression, this should work: DECLARE @list varchar(255) SET @list = '''Item1'',''Item2''' SELECT * FROM Table WHERE Item IN (@list) And it should select those items in @list. The items exist in the table. If I execute the query separately for Item1 and Item2 (Item = Item1, then Item = Item2)...