sql-server-2005

How do I for each in SQL as an alternative to using a cursor?

I'm trying to write a SQL script that inserts 2 rows into a table thus: INSERT INTO [table1] ([Id] ,[Name] ,[SequenceNo] ,[EntityId]) VALUES (<newid(), uniqueidentifier,> ,<'SpecificName1', nvarchar(255),> ,<1, int,> ,</*Here's where I need help*/>) INSERT INTO [table1] ([I...

database importing problem with sql server

Hi, I have a database working in my local sql server 2005 express edition. I have to import my local database to a remote server database. For that i established connection to that remote server, and i can now see that database . but when i tried to restore database from my local machine i'm getting an error message when i tried to gi...

SQL Query with conditional JOIN

The scenario: Table1 CatId|Name|Description Table2 ItId|Title|Date|CatId (foreign key) I want to return all rows from Table1 and Title,Date from Table2, where The returned from Table 2 must be the Latest one by the date column. (in second table there many items with same CatId and I need just the latest) I have 2 queries but can't...

T-SQL Script to Delete All The Relationships Between A Bunch Of Tables in a Schema and Other Bunch in another Schema?

Guys, I have a set of tables (say Account, Customer) in a schema (say dbo) and I have some other tables (say Order, OrderItem) in another schema (say inventory). There's a relationship between the Order table and the Customer table. I want to delete all the relationships between the tables in the first schema (dbo) and the tables in t...

Inserting "null" (literally) in to a stored procedure parameter.

I'm trying to insert the word "Null" (literally) in to a parameter for a stored procedure. For some reason SqlServer seems to think I mean NULL and not "Null". If I do a check for IF @LastName IS NULL // Test: Do stuff Then it bypasses that because the parameter isn't null. But when I do: INSERT INTO Person (<params>) VALUES (<stuff...

read contents of a sql table into a data grid view

Im using c# .net windows application form. i have created a database named "resources" in SQL server 2005. In that i have a table named "resourcetable" which has two columns. now i need to read the data in the table into a datagridview. I can do this by using the connection string and querry by giving the table name. But my problem is i...

Converting from SQL Server 2000 to 2005 for ASP.NET web App

Hi there, I'm moving my ASP.NET website to a new provider. Only problem is, old host support my SQL Server 2000 db. New host only supports SQL Server 2005. How should I go about the conversion ? Can I simply produce a backup of the 2000 (.bak) file at the old host, and restore that file into SQL Server 2005 at the new host ? Or is ther...

connecting sql server 2008 from sqlserver 2005

I am not able to connecting to the sqlserver 2008 from my sqlserver 2005....Is it really not possible to connect or there is some way.. please suggest me..if there is some thing.. Thanks. ...

Removing a default value from a Sql Server 2005 table

Hi, I have a tabel in an Sql Server 2005 database. I have the following column IndPL INT DEFAULT 0 NULL I want to change the column to be of the type NVARCHAR but I receive a constraint violation due to the fact that the column has a default value constraint attached to it. I need to find out how to remove a default value constraint...

Use database dynamically

This execution it is giving me an error! Any hints of what am I missing? declare @dbname varchar(500) set @dbname='master' Exec (' Use ' + @dbname + ' go create PROCEDURE [dbo].[krijo_database] @dbname nvarchar(2000), @Direktoria varchar(4000) AS BEGIN declare @stringu nvarchar(100) set @stringu = ''CREATE DATABASE '' +...

VBA Excel To SqlServer

What is the best way to write VBA code to connect to SQL Server 2005 from Excel? The users of the excel file might run XP, Vista, Win7 and I want to prevent driver installation as much as possible. My understanding is that XP uses MDAC while Vista/Win7 uses DAC. Does that mean that a reference to MDAC 2.8 will not work on a Vista machi...

SQL Server Blocking Issue

We currently have an issue that occurs roughly once a day on SQL 2005 database server, although the time it happens is not consistent. Basically, the database grinds to a halt, and starts refusing connections with the following error message. This includes logging into SSMS: A connection was successfully established with the server, bu...

How do I have a subscription email format a hyperlink in the comment field?

email delivery in ssrs 2005 won't format a hyperlink I enter in unless it generates it. How do I get a hyperlink in the email text (the comment field in ssrs) instead of it being written out as plain text? ...

Where can I find Microsoft Sql Profiler 2005?

Is there a way to get the profiler without installing Microsoft Sql Server? If the answer is no, which edition do I need to get the profiler? Do I need the Developer Edition? ...

Unable to Connect to Management Studio Server

I have a nasty situation. I am using Microsoft SQL Server Management Studio Express edition locally on my pc for testing, and once tested I upload database changes to a remote server. I have a situation where I deleted the Default Database on my local machine, and instead of searching hard enough to find an answer to that problem, I un...

Microsoft SQL Server 2005 Function, passing list of start and end times

I'd like to do had a dynamic number of one start/end time pairs passed to a function as an input parameter. The function would then use the list instead of just one start, and one end time in a select statement. CREATE FUNCTION [dbo].[GetData] ( @StartTime datetime, @EndTime datetime ) RETURNS int AS BEGIN SELECT @EndTime =...

installing visual studio 2005 after 2008 already installed

I have a machine with VS 2008/Sql 2008 already installed. I now need to install an instance of vs 2005/Sql 2005 for two reasons. The main reason is for reporting Services 2005. All of the report servers are sql 2005. Now to create a SSRS compatible with 2005 do I just need to install Sql Server 2005 and work with it in VS 2008 or do...

sql server 2005 reporting services-- how to use multiple datasets in report

Hi everyone, I'm new to SQL Server reporting services, and am trying to decipher an existing report. It's nothing too bad, but I notice it does have two report datasets defined. (They are generated via separate stored procedures) I'm trying to figure out where and how the report datasets are linked together so the Fields collection h...

Is there a way to delay compilation of a stored procedure's execution plan?

(At first glance this may look like a duplicate of http://stackoverflow.com/questions/421275 or http://stackoverflow.com/questions/414336, but my actual question is a bit different) Alright, this one's had me stumped for a few hours. My example here is ridiculously abstracted, so I doubt it will be possible to recreate locally, but it p...

SQL Server find and replace in TEXT field

I have a database in SQL Server 2005 that was brought up from SQL Server 2000 and is still using TEXT type fields instead of varchar(max). I need to find and replace a string of characters in the text field but all of the examples of how to do this that I have found don't seem like they would work for me. It seems the UPDATETEXT command...