sql-server

How to find persons who are absent continuously for n number of days?

Database: MS SQL 2005 Table: EmployeeNumber | EntryDate | Status Sample Data: 200 | 3/1/2009 | P 200 | 3/2/2009 | A 200 | 3/3/2009 | A 201 | 3/1/2009 | A 201 | 3/2/2009 | P Where P is present, A is absent. I have tried row_number over partion. But it does not generate the sequence which I expect. For the above data the sequence...

SQL Server 2005: Detecting cycles in hierarchical data

I have a typical table of hierarchical data in id, parentId form. CREATE TABLE Hierarchy (Id int, ParentId int NULL, Name varchar(128)); INSERT INTO Hierarchy VALUES (1, NULL, '1'); INSERT INTO Hierarchy VALUES (2, NULL, '2'); INSERT INTO Hierarchy VALUES (3, NULL, '3'); INSERT INTO Hierarchy VALUES (4, 1, '1.1'); INSERT INTO Hierarchy ...

ASP.NET and a One-to-Many-to-Many Scenario

I'm new to ASP.NET but not to programming. I am migrating our current site from PHP/MySQL to ASP.NET(3.5)/SqlServer. I've been lurking here since the site's launch, so I'm confident that one (or more) of you can help me out. Here's the scenario: This is a training department site and the dept. has a course catalog stored in the table co...

Create a new db user in SQL Server 2005

how do you create a new database user with password in sql server 2005? i will need this user/password to use in the connection string eg: uid=user;pwd=password; ...

Errors While deploying SSAS 2005 Cube on Server

Hi, I am stuck with something really nasty here. I have a SSAS Cube that was working fine till day before yesterday. Had some performance issues on the server and got cummulative patch 938077 on top of Service Pack2. Since then I have not been able to deploy the cube - with a strange error - File System Error: The following error occu...

Difference between mysql and sql server? Performance, features,...?

What are the differences between MySQL and Sql server? What are the parameter to chose between the two? ...

Table Spool/Eager Spool

I have a query select * into NewTab from OpenQuery(rmtServer, 'select c1, c2 from rmtTab') When I look at the execution plan, it tells me that it performs a 'Table Spool/Eager Spool' that 'stores the data in a temporary table to optimize rewinds' Now I don't anticipate any rewinds. If there is a crash of some sort, I can just drop ...

how Stop strange users from trying to connect to my SQL server db?

I have an asp.net website on a server and the db MS SQL 2005 on another server, the last few days the website show me this error message: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that S...

Adding Content Database with STSADM, but failing to connect to SQL Server

I'm trying to add a content database to my MOSS 2007 site, but I can't seem to connect to the SQL Server. I run the following from the command prompt: stsadm -o addcontentdb -url htt://testserver:101 -databasename WSS_ Content_MySite -databaseserver SHAREPOINT01 STASADM gives me this error: "An error occured while establishing a conne...

Best method of doing multiple calculation on a databse (.NET 2.0 VB)

Hi Is it better to create lots of SQL statements or to cache the data in asp .NET and manipulate the data from there? cheers ...

SQL Server Browser showing only hostname, not instance name

The title says it all. I just setup a new Windows Server 2008 machine with an instance of SQL Server 2008 Express. The SQL Browser service does not appear to be working correctly. In Management Studio, browsing for servers shows the hostname of the new server, but not the instance name. When you choose the hostname form the list it d...

SQL SERVER | Bitwise operations on an int/smallint/tinyint field

I was wondering if you can do bitwise operations on an int/uint fields in SQL SERVER? ...

What happens if I Select SCOPE_IDENTITY() after an insert fails (SQL Server 2005)

The MSDN docs weren't entirely clear on this one. or perhaps I'm not reading them well enough. If I do an insert (which may insert zero rows), followed by ;SELECT SCOPE_IDENTITY() And then call the command by ExecuteScalar()... What will the result be if the Insert doesn't insert any rows? I want to stop if it fails so that I don'...

Running a SQL install script with SMO. Alternative solutions needed.

Hi folks, I've got a web application that uses Microsoft Sql Management Objects (SMO) dll's. I'm wondering how I go about redistributing the libraries for a remote machine. As I understand it, these come with SQL server or Sql express - which isn't on the remote (shared) webserver. Asking the host to install them, is probably out of t...

Getting stored procedure usage data on SQL Server 2000

What is the best way to get stored procedure useage data on a specific database out of SQL Server 2000? The data I need is: Total of all stored procedure calls over X time Total of each specific stored procedure call over X time. Total time spent processing all stored procedures over X time. Total time spent processing specific stored...

What tool can monitor my SQL Server usage and suggest optimizations?

I have a vague recollection of hearing about a profiling tool that could sit and watch the SQL Server that is serving data to my production website. In particular, I'm looking for a tool that can, based on profiling what is actually taking the most time, do things like make suggestions for new indexes or other sorts of simple optimizati...

SQL Server - OPENXML how to get attribute value

I have the following XML: <Field FieldRowId="1000"> <Items> <Item Name="CODE"/> <Item Name="DATE"/> </Items> </Field> I need to get the FieldRowId using OPENXML. The SQL i have so far: INSERT INTO @tmpField ([name], [fieldRowId]) SELECT [Name], --Need to get row id of the parent node FROM OPENXML (@idoc...

SQL Server Batch Error Handling Problem.

How do I get this batch of SQL to get to the RollBack Transaction part at the end? SQL just stops halts script execution on the bad line of code. I know I can use a try/catch construct but i'm more interested in how this was this handled before SQL added try/catch. BEGIN TRAN CREATE TABLE TempTable (c1 INT NULL) INSERT INTO TempTable ...

Solving Erratic Behavior with HttpWebrequest in SQL 2008 CLR UDF

We're currently attempting to implement a sql server 2008 udf to do expansion of shortened urls. We have it working quite well against most of the major url shortening services. However, at seemingly random times it will "hang" and refuse to work against a certain domain (for example bit.ly) while subsequent calls to other services...

In which scenario would you prefeer to use mysql over sql server or viceversa?

In which pratical scenarion would you prefeer one or the other? I know there are a lot of parameter you can compare, can you give me some practical examples? Example: mysql in case of multiple databases with few tables, sql server for single database with lots of tables because.... ...