sql-server

Attach and detach database

When i attach a Northwind database(using sp_attach_db) to SQL server 2005 ,it finished successfully. but when i run this query SELECT FT_TBL.Description, FT_TBL.CategoryName, KEY_TBL.RANK FROM Categories AS FT_TBL INNER JOIN CONTAINSTABLE (Categories, Description, '("sweet and savory" NEAR sauces) OR ("sweet and...

How to use the identity as a column value during an insert

I have a stored proc containing an SQL statement which is something like: CREATE PROCEDURE SaveUser @UserName nvarchar(10), @FirstName nvarchar(150), @LastName nvarchar(150) AS BEGIN INSERT INTO Users (UserName, FirstName, LastName) VALUES (@UserName, @FirstName, @LastName) SELECT SCOPE_IDENTITY() END Some users cannot...

Ensuring correct data in MS SQL Server, DB Level

Hey Stackoverflow. Say I have a table with the following layout: Id Int PRIMARY KEY IDENTITY DateFrom datetime NOT NULL DateTo datetime NOT NULL UserId Int UserId is a foreign key to a users table, and well obviously there's more data which is irrelevant to this question. What I want to do, is to make sure that per User, there can ...

uninstall sql server 2005 instance with database issues

On a non-production machine, I have two instances of SQL Server 2005. I want to uninstall the second instance, but I have two problems. Although this is a non-production machine, I want to be sure to keep the first instance safe so that I don't have to re-build anything. I have had the second instance off for a month. When I started ins...

Send email for each row in a result set

I'd like to send an email for each row of a result set using sp_send_dbmail. What is the appropriate way to accomplish this without using loops? Edit: I'm not insisting a loop is not proper here, but is there a set based way to do this. I've tried creating a function, but a function cannot call a stored proc inside it. Only anoth...

How to get a date in YYYY-MM-DD format from a TSQL datetime field?

How do I retrieve a date from SQL Server in YYYY-MM-DD format? I need this to work with SQL Server 2000 and up. Is there a simple way to perform this in SQL Server or would it be easier to convert it programatically after I retrieve the result set? I've read the CAST and CONVERT on Microsoft Technet, but the format I want isn't listed a...

.Net client connecting to SQL 2005 with wrong provider

I am trying to connect to a database on a server from a developer machine. The server has the named pipes protocol disabled. For some reason from one developer's box we get the following error message. Two other developer boxes can connect using the same code just fine (using tcp/ip). I have tried disabling The named pipes protocol o...

identity column in Sql server

Hi, Why does Sql server doesn't allow more than one IDENTITY column in a table?? Any specific reasons. ...

INNER and LEFT OUTER join help

Say I have 3 tables. TableA, TableB, TableC I need to operate the recordset that is available after a INNER JOIN. Set 1 -> TableA INNER JOIN TableB Set 2 -> TableC INNER JOIN TableB I need the Set 1 irrespective of if Set 2 is empty or not (LEFT OUTER JOIN) comes to mind. So essentially, I am trying to write a query and have come th...

Dynamically changing parameter based on another in an SSRS report

We have a report that in 2005 version of SSRS, we could dynamically update one parameter (which is a text box) from another report parameter (which is a drop down). Each time the drop down changes, the text box would update. No problem. Now in 2008, it only happens when we first preview the report (in other words, the text box is upda...

SQL Server 2005 - If condition with union

Hello, I have a SP that has the following algorithm. IF <SomeCondition> BEGIN SELECT * FROM TABLE1 END ELSE BEGIN SELECT * FROM TABLE2 END --Union the above with the query below UNION SELECT * FROM TABLE3 The recordset returned is EXACTLY the same. I need to do a UNION of that resultset and another query. Is there a way to do ...

Keep Group on One Page using Reporting Services

I created a report as part of a C# application using Reporting Services and I cant find some functionality I am used to seeing in other environments. I believe both MS Access and Crystal reports have an option called "Keep Together" so that you can keep a specific grouping of data on one page instead of the information being split over ...

use sharepoint forms authentication users to login to remote sql server

The Sharepoint setup I am dealing with is as follows: - forms-authentication sharepoint server - with the users database stored on a remote sql server - we have a custom asp .net application put on tip of sharepoint, that is being run from the __layouts_ folder; the application gets all its content from a remote sql server (nothing to do...

Is it possible to restore a backup of a SQL Server 2008 database onto an instance of SQL Server 2000?

Is it possible to restore a backup of a SQL Server 2008 database onto an instance of SQL Server 2000? I need to work on an sample application for which database backup is in sql server 2008. But I'll not be able to install 2008. So is it possible to restore that back up in 2000? ...

What would be causing SQL server to give does not exist or acces denied

Hi, I have SQL server 2005 DB that is accessed by an MSACCESS database using link tables. Occasionally we are getting SQL server does not esit or access denied messages when a works fine at most other times. From clients this is of course. What we be some possible causes of this?? Malcolm EDIT: This is actually a ODBC message. ...

How to update a datawarehouse after migrating to sql2005 from sql2000

Hi Guys, I apologise for asking basic questions but I'm new to Analysis Services and dimensional data. My current situation is, I have a sql server2000 database with a warehouse which was built by a previous developer. The warehouse and the transactional DB are on the same physical server. The warehouse is filled nightly by stored proce...

Is there any known issues with using linked servers between 64bit sqlserver2005 and 32bit sql2000

I seem to have problem getting linked servers working to query between database/servers running sql2000 32bit and 64bit sql2005. Is this a known bug? If so, is there a workaround, or fix? ...

Whats a good .net sql server ecommerce store that I can integrate existing logins into the customer databse, and import some 3000 products with realtive ease (from an Erol store)

I need a quick list of stores and why you think they are the best. ...

can we install sqlserver2005 before installing vs2005?

Hi i want to install sqlserver2005 on my server2003 machine. i heard that sqlserver2005 should be installed prior to visualstudio2005. is it right or wrong. thanks in advance ...

How to save an arbitrary DataTable to a new SQL Table

Suppose I have an ADO.NET DataTable that I was to 'persist' by saving it to a new table in a SQL Server database - is there a fast way of doing this? I realise I could write code generating the DDL for the 'CREATE TABLE' statement by looping through the DataColumns collection and working out the right type mappings and so on ... but I'm...