sql-server

SQL Server Compact 'Data Directory' macro in Connection String - more info needed

So, as described on this msdn page, when you define a Connection String for SQL Server Compact 3.5, you can use the "Data Directory" macro, like this: quote from this msdn page: Data Directory Support SQL Server Compact 3.5 now supports the Data Directory macro. This means that if you add the string |DataDirectory| (enclosed in p...

SQL query to calculate part of visit duration from log table

Hello, I have a table which logs the userid, course, sessionid and requestdate each time a webpage is loaded. I want to calcuate the duration per userid for a given courseid. It is problematic to do this due to overlapping timespans. The data provided here should result in 10 minutes duration per user for course 1. I can't seem to get ...

Converting nested Selects in WHERE .. OR .. to INNER JOINS

Hi How would I convert the following to use INNER JOIN rather than nested SELECT? SELECT [Name].[NameValueID], [Name].[NameTypeID], [Name].[NameID], [Name].[Value] FROM [Name] WHERE Name.NameTypeID IN ( SELECT NameTypeID FROM @tbNameType ) OR Name.NameID IN ( SELECT NameID FROM @tbName) ...

EAV vs XML in SQL Server 2005/2008 and LINQ

I am considering the use of an EAV table in SQL Server to store some hierarchical/structured data, all the while knowing the capabilities of XML in SQL Server. I am aware of some of the performance draw backs of EAV due to excessive joins, however, does client side LINQ to object solve any of these problems? I am looking for some advic...

SQL Free Text And Like

If I use like '%fish%' the following is returned AQUARIAN GOLDFISH FLAKES but if I use Contains([Description],' "fish*" ' ) it isn't is there something I can do? Basically I want to return anything that has the word fish in it anywhere. ...

Peculiar case with SQL Server, indices and parameters

I have a table, let's call it History. The primary key (aka Clustered Index) is called HIST_ID. The table has some 2300 rows in the development DB. Now consider the following two queries: Query 1: declare @x int set @x = 14289 select * from History where hist_id=@x Query 2: declare @x int set @x = 14289 select * from History where...

Preferred approach for producing ranked SQL results?

Hi. I need to build some searching logic that produces ranked results. A simple example would be querying a table with firstname, lastname and zip code columns. The required output would be a list a rows that match, in order of the 'degree' of match. I.e., the top results would be those that matched on all three columns, followed by tho...

SSAS data sourcing with Netezza

We were extracting data out of Netezza into txt files, loading into SQL Server and processing our SSAS cube(s) from there. We want to change that and load the cube directly from Netezza. What are the things to keep in mind for this? ...

How do I retrieve a file from a SQL Server database?

I have successfully uploaded files into my SQL Server database. I can bring back the information into a GridView. I am unable to figure out how to create a hyperlink to actually open the file. ...

How to use SqlBulkCopy with nullable columns

I’m having an issue using SqlBulkCopy when nullable columns are involved. It sounds like SqlBulkCopy doesn't know how to deal with nullable columns and throws an illegal size error when it encounters a zero length column. The error is "Received an invalid column length from the bcp client..." I’m wondering what the best practice is for ...

Is it possible to tie sql server paging to the report viewer

Can we improve the performance of the report viewer. Instead of bringing the whole dataset, can we bring only the page? ...

SQL Server: Need to find the origin of a particular string value

Is there a way I can search for a particular string value in a SQL SERVER 2005 database? I have this image path value that I want to modify and I think it's stored in the database. Also - is there a way that I can search for a column's name for any table in a database? Likewise, search for a tables name in a database? ...

How can I test for SQL Server connectivity from DOS?

I am trying to figure out how to "test for connectivity" to a SQL Server database from DOS. If the connection fails I need to detect the failure. sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS You'll notice that that command doesn't return a true/false value. Also, if the instance doesn't exist, it times out. I want something like th...

SQL Query Help for Queue Quantities

I have a database which has an orders table and inventory table. The order-items table has a 1 record per 1 qty layout, so if a person places an order for 7 'ABC's, and 4 'XYZ's, I get 11 records in the table. id, item, qtyNum 01 ABC 1 02 ABC 2 03 ABC 3 04 ABC 4 05 ABC 5 06 ABC 6 07 ABC 7 08 XYZ 1 09 XYZ 2 10 XYZ 3 11 XYZ 4 The...

Table vs Temp Table Performance

Which is faster for millions of records: Permanent Table or Temp Tables? I have to use it only for 15 million records. after Processing complete. we delete these records.. ...

SQL Server - Get Inserted Record Identity Value when Using a View's Instead Of Trigger

For several tables that have identity fields, we are implementing a Row Level Security scheme using Views and Instead Of triggers on those views. Here is a simplified example structure: -- Table CREATE TABLE tblItem ( ItemId int identity(1,1) primary key, Name varchar(20) ) go -- View CREATE VIEW vwItem AS SELECT * F...

Granting SA privileges for Developers on the development box

In spite of our vehement protests, our management has decided that the development team must be granted 'sa' rights on the development server. The catch is that we, the DB support group are still responsible for maintaining this box. We have now been entrusted the task of coming up with a list of Dos and Don'ts for the development teams...

GSS-API MSSQL JDBC Driver

Has anyone found a JDBC Driver that supports GSS-API for MSSQL. I need to connect to a sql server using windows authentication. The fun part is it's the user logged into the application via JAAS not the user the application is running as. ...

SQL Server instance name with IP address

I have a very strange situation happening and I'm hoping someone here knows why. I have TCP/IP enabled for all ports on the default port 1433. All tests are consistent with SQL Server Management Studio and my program. This works: ComputerName\InstanceName 127.0.0.1 127.0.0.1,1433 192.168.1.100 192.168.1.100,1433 This does NOT wor...

How do I move the same columns data within the same table without looping

Here is what I want to do: I am trying to obfuscate data and create a working database to be used for documentation. I have a list of first names that I want to mix up in a table. KEY FIRSTNAME 135 CYNTHIA 181 MARK 186 MARGARET 212 DESIVANITA 506 AMY 606 BRENDA 628 KATHLEEN 629 Johnna 636 TAMARA 652 KATHLEEN Th...