sql-server

SQL Server single user mode

Im experiencing an issue with a production server. I can connect to the server from only one program at a time. Eg, when I connect from SQL Management Studio then nobody else can, and vice versa with a different user. It's like the server is in single user mode, except, it's in multi user mode. Any ideas? I get this error message when ...

How to calculate difference in hours (decimal) between two dates in SQL Server?

I have to calculate the difference in hours (decimal type) between two dates in SQL Server 2008. I couldn't find any useful technique to convert datetime to decimal with 'CONVERT' on MSDN. Can anybody help me with that? UPDATE: To be clear, I need the fractional part as well (thus decimal type). So from 9:00 to 10:30 it should return m...

C# Sync MS Access database to sql server

I am trying to set up a synchronization routine in C# to send data from a ms access database to a sql server. MS Access is not my choice it's just the way it is. I am able to query the MS Access database and get OleDbDataReader record set. I could potentially read each individual record and insert it onto SQL Server but it seems so was...

Help optimize this query with a huge IN statement

I have an insert that uses a condition checking for a NOT IN. There are about 230k rows in the NOT IN subquery. INSERT INTO Validate.ItemError (ItemId, ErrorId, DateCreated) ( SELECT ItemId, 10, GetUTCDate() FROM Validate.Item INNER JOIN Refresh.Company ON Validate.Item.IMCompanyId = Refresh.Company.IMCompanyId ...

Problem with U+02BB character in SQL server LIKE search

My SQL table has rows like Hawaiʻi 01 abcʻdef ʻabc abcʻ All "apostrophes" are actually okina characters (U+02BB) When I use the following search statement select text01 from atable where text01 like N'%ʻ%' I get all rows returned, even "01" ESCAPE clause (e.g. LIKE N'%!ʻ%' ESCAPE '!') does not help SQL Server 2005 SP3 Any idea...

Big Table Advice (mssql)

Hey all, I'm experiencing massive slowness when accessing one of my tables and I need some re-factoring advice. Sorry if this is not the correct area for this sort of thing. I'm working on a project that aims to report on server performance statistics for our internal servers. I'm processing windows performance logs every night (12 ser...

Difference b/w connecting to SQL Server from ASP.net and Desktop application. In terms of CAL?

-What is difference between connection to SQL Server from ASP.net and Desktop application? Why purchasing a Client Access License (CAL) for every device that accesses your server is not needed in web? If I have a CAL for 10 devices and I need one more device to connect to SQL Server, can I do this using Web service? Thanks ...

Does SQL Server's Database Tuning Advisor modify data?

I've been trying to increase performance and diagnose deadlocks on a SQL Server 2005 instance. It had been running SQL Server 2000 until a month ago, when an in situ upgrade was done. After the upgrade, we've experienced a number of issues- performance is down and deadlocks are way up. MS suggested we use 2005's Database Engine Tuning Ad...

Calculate fiscal year in SQL Server

How would you calculate the fiscal year from a date field in a view in SQL Server? ...

SQL Server BETWEEN not as efficient

I recall hearing or reading somewhere that SELECT * from TABLE where date >= '2009-01-01' AND date <= '2009-12-31' is more efficient than SELECT * from TABLE where date BETWEEN '2009-01-01' AND '2009-12-31' Where date column is a DATETIME type and has the same index. Is this correct? ...

Why can't I see the "value" column in SYS.EXTENDED_PROPERTIES?

I have some extended property column descriptions in a SQL Server 2008 database, and when I login to management studio and do a simple query: Select * from SYS.EXTENDED_PROPERTIES; I can see all the columns in that table, including the extended property "value" column. When I have an ASP.NET page login to the db, perform that query, ...

Import huge XML data (> 1Gb) into SQL Server 2008 daily

Dear all: I have encountered a problem that I need to import a huge XML (> 1Gb) into SQL Server 2008 daily. What I have now is a sample XML file and the XML schema of it. The XML schema is pretty complex which contains many custom defined simple type, and element with complex type such as: <xs:element name="xxxx_url"> <xs:complexT...

SQL: Deleting duplicate records in SQL Server

hi! I have an sql server database, that I pre-loaded with a ton of rows of data. Unfortunately, there is no primary key in the database, and there is now duplicate information in the table. I'm not concerned about there not being a primary key, but i am concerned about there being duplicates in the database... Any thoughts? (Forgive...

sys.dm_exec_query_stats column descriptions?

Hello, Does anyone know the definitions for all the columns returned by sys.dm_exec_query_stats? ...

Troubles formatting if statements in SQL

I've created the following sql statement, every thing in $() is a variable (comes from the module we're using on our site so $(varname) is the right format in this case, not @varname. It keeps telling me there's an error near THEN... how am I supposed to format this properly? IF ($(Shiptobilling) = 'yes') THEN BEGIN CardOrd...

What sql database role must a user have to use a MS Access project file

Today i tried changing a users role from db owner to db data reader and db data writer. This user uses an Access ADP file, to edit, add and delete records from a few tables in the SQL Server database. However, after doing so he got an OLE error from access on trying to open the ADP. Are there certain security priveleges required by the A...

Advantages of using SSIS packages over stored procedures?

If I can do the required ETL requirements using stored procedures, any advantages of using SSIS packages instead? My ETL stuff is nothing major. I feel like using an old technology. I like SQL. Old technology does not equal obsolete as stored procedures won't go away any time soon. ...

Sum total amount returned from query

I have a query below that is returning individual sales records with amounts for each order placed for a specific product SKU. How would I go about summing the total amount? The column is "extprice" that I need to sum. Any help would be appreciated, thanks... select partno4pt,orders.orderdate,orders.processdate,orderdetails.qty,o...

Problems installing sql management studio express on win7-64

Here's what happened: install sql express 2008 install sql 2008 sp1 download and install SSMSE x64. There is a popup re incompatibility with the OS, and the help takes you back to the sp1 download page. It won't install... in fact the install that comes up appears to be for sql server express and I see no mention of SSMSE anywhere in ...

outlook contacts to sql server

is there any way to export outlook contacts directly into a sql server db. this could be using a tool or programatically ...