sql-server-2005

Reconfigure publishing and distribution in SQL Server for changed Hostname

I have SQL Server 2005 running on a development machine that is administered by people rather far away, metaphorically speaking. They decided it would be fun to change the Network Name/Computer Name/Hostname in command prompt of this machine from "OldName" to "NewName". SQL Server was installed and distribution and publishing set up un...

Problem using ROW_NUMBER() to get records randomly (SQL Server 2005)

Hi all, I want to get 1000 records from a table randomly, so I use: SELECT top 1000 mycol1 , mycol2 , ROW_NUMBER() OVER (ORDER BY NEWID()) rn FROM mytable However, I don't want to see rn in my resultset, so I do: SELECT mycol1 , mycol2 FROM ( SELECT top 1000 mycol1 , mycol2 , ...

SQL Server 05\08: Grant Exec with special char in login

Trying to run the command: grant exec on GetPrograms to fp\ouruser_api When I run it, I get the error message "incorrect syntax near \", but this is the login id stored in our database, how can I grant this user permissions? Thanks ...

SQL Server 2005 - Stripping Only Alpha Values from String

I am using SQL Server 2005 and I want to extract the alpha part of a string. i.e. From ABC123, I would like to get ABC From AB1234, I would like to get AB. etc etc. What is the easiest way to do this? ...

How to run an SSIS package in SQL 2005?

Every month I get an updated list of USPS ZIP codes, which I dutifully import into my SQL Server 2005 database. It's really a simple process, and during the import process, there's a little tick-box that allows me to "Save as SSIS package". Which, of course, I did. But this is the really crazy part... now that I've saved it - where is...

insert or update if record is in table

I have a tables Cars and CarDescriptions cars: IDCar(int, PK, autoincrement) carsDesciptions(IDDescription, Header(nvarchar),Content(nvarchar),idCar(int,FK) In application I am adding cars and editing existing ones. My problems: 1.How to save changed Car with descriptions in database ?? I have ID of Car, and I have ID's of D...

Using LINQ with databases other than SQL Server Express 2005

I'm just starting to look into using LINQ for my database (and XML, and data object!) needs, but need to decide on which database to go with. I've been reading Pro LINQ, and it says that currently, LINQ in .NET 3.5 only supports SQL Server. I have done some googling, and have found references to using LINQ with MySQL and PostgreSQL (my...

How can I delete from three tables with foreign keys?

I want to be able to choose a groupID and do a cascading delete through three tables which are found in a MS SQL server database. The tables look like the following: table 1 - GROUP ------------------------------------------- groupID | description | etc table 2 - MEMBER ------------------------------------------- memberID | name | et...

Simulate records in database without entering any

Hi, I've nearly finished the development of a project and would like to test its performance, especially the database query calls. I'm using Linq to SQL to search via usernames, but I've only got around 10 'users' in my database, so I can't really get a decent speed reading. How can I simulate thousands/millions of users in the databas...

File gets corrupted when reading/writting from SQLServer 2005/2008 from C#?

I've wrote two little methods to save and load .docx (and later on other type of files) files into database (SERVER 2005/2008 with VarBinary(MAX) as column). Everything seems nice but when i read the file back it's created but Word complains that it's corrupted but finally opens it up with everything in it. What's wrong with the code? ...

Snapshot transaction Isolation levels: it really works as advertised?

Have you any problems using it on high concurrency environment? It's really works as advertised by MS? I'm using SQL Server 2005 and would like to hear the experiences of those who are/was using it on applications using it on production. Snapshot isolation per se is not new for me as I develop/administer Firebird/Interbase as well - whe...

SQL Server 2005 Execution Plan

I am attempting to troubleshoot a slow running stored procedure in SQL Server 2005. I am analyzing the execution plan and see a SORT that is 45%, but I am not using an ORDER clauses. What would be causing this. UPDATE SP (cleaned up, and made change on OR's) SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[Rp...

The version of component "x" is not compatible with this version of the DataFlow.

Getting this error trying to run an SSIS Package on a 64 bit install of SS2K5 Enterprise Edition SP3. Package was developed using 32 bit BIDS, and deployed successfully to 64 bit SS2K5 Enterprise Edition SP2, and 64 bit SS2K5 Developer Edition SP3. Have upgraded client tools to SP3 with same result. Amy ideas? ...

No query plan for procedure in SQL Server 2005

We have a SQL Server DB with 150-200 stored procs, all of which produce a viewable query plan in sys.dm_exec_query_plan except for one. According to http://msdn.microsoft.com/en-us/library/ms189747.aspx: Under the following conditions, no Showplan output is returned in the query_plan column of the returned table for sys.dm_exec_quer...

Sql 2005, is it faster to sort by datetime or by int ?

If sorting by int is faster, what is the trick to sort a table by DateTime using the power of sorting by int ? ...

SQL SERVER Project

My Application Database Without Project and without Source safe, i planned to make my DB to be as project and add it to TFS, but I have no idea how to script the stored procedures, Triggers, Views, Functions, and what is the best practice to Make Update Script for All My stored procedures, Triggers, Views, and Functions to My customers D...

Changing table schema in sql 2005

I have a sql 2005 database and I have a table named dbo.AgencyProfile However, I want to remove the dbo prefix. How can I accomplish this? ...

Recursive Query - Only select nodes where leaf nodes represent active data

Given the following recursive query: WITH DepartmentHierarchy (DepartmentID, Name, IsInactive, IsSpecial, ParentId, HierarchyLevel) AS ( -- Base case SELECT DepartmentId, Name, IsInactive, IsSpecial, ParentId, 1 as HierarchyLevel FROM StoreDepartment WHERE ParentId IS NULL UNION ALL ...

Sql server table can be queried but not updated

i have a table which was always updatable before, but then suddenly i can no longer update the any of the columns in the table. i can still query the whole table and the results come back very fast, but the moment i try to update a column in the table, the update query simply stalls and does nothing. i tried using select req_transact...

Delete from multiple tables (linq to sql)

hi, I'm using Linq to SQL to access my database. I want to have a 'delete account' feature which basically gets rid of all records in all tables that belong to a given user. What would be the most efficient way of doing this? The deletion has to occur in a certain order, otherwise there are foreign key integrity errors. I can do this m...