sql-server-2005

ThreadAbortException in SQL Server CLR stored procedure

This is kinda weird... I remember that I once had this, but can't remember the cause or solution... In a CLR stored procedure (SQL Server 2005) of mine I get a ThreadAbortException. All the details I have are the following: System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Server.SmiContextFactory' th...

Reporting Services Object Reference Error

...

How to update another table with the most recent data in SQL?

I'm trying to update Table1 in DB1 with data from Table2 in DB2. I can connect and get the data from DB2 Table2 into DB1 Table1, but the issue I'm having is getting the MOST RECENT data from DB2 Table2. I'm looking at 3 fields in DB2: f1, f2, & f3. f1 contains duplicates (and is where I'm matching from DB1 Table1) and f3 is a date f...

sql server - passing unquoted constants to functions like DATEPART does

i would like to create a function which accepts a constant like the datepart function accepts yy/mm/dd/hh/ like: select datepart(dd, getdate()) i would like to create my own function that accepts dd not char like 'dd' i want select MyFunc(dd, getdate()) and not select MyFunc('dd', getdate()) ...

Can I create a One-Time-Use Function in a Script or Stored Procedure?

In SQL Server 2005, is there a concept of a one-time-use, or local function declared inside of a SQL script or Stored Procedure? I'd like to abstract away some complexity in a script I'm writing, but it would require being able to declare a function. Just curious. Thanks!! ...

SQL server management from visual studio

I need to make some permission changes on a MS SQL server (2005) database. Some tables read only for all but dbo, some tables read-write for all etc. In the past I used the management program that came on the SQL server disk. That is not an option for me right now. I cannot find a place in visual studio to alter table permissions. D...

SQL update query using joins

I have to update a field with a value which is returned by a join of 3 tables. Example: select im.itemid ,im.sku as iSku ,gm.SKU as GSKU ,mm.ManufacturerId as ManuId ,mm.ManufacturerName ,im.mf_item_number ,mm.ManufacturerID from item_master im, group_master gm, Manufacturer_Master mm where im.mf_...

TransactionInDoubtException using System.Transactions on SQL Server 2005

The underlying question to this post is "Why would a non-promoted LTM Transaction ever be in doubt?" I'm getting System.Transactions.TransactionInDoubtException and i can't explain why. Unfortunately i cannot reproduce this issue but according to trace files it does happen. I am using SQL 2005, connecting to one database and using one ...

Which tables/views contain the list of objects used by Service Broker?

Hey StackOverflow, I work with Service Broker. I need to know which Service Broker entities (message types, contracts, etc.) have been added to the database I am dealing with. The question refers to MS SQL Server 2005. Thank you! ...

Delete duplicate records from a SQL table without a primary key

I have the below table with the below records in it create table employee ( EmpId number, EmpName varchar2(10), EmpSSN varchar2(11) ); insert into employee values(1, 'Jack', '555-55-5555'); insert into employee values (2, 'Joe', '555-56-5555'); insert into employee values (3, 'Fred', '555-57-5555'); insert into employee values (4, '...

How do I update tables in SQL so that related strings match?

Suppose I have 2 tables Table1 ID Path -- ---- 1 PathA 2 PathB 3 PathC 4 PathD Table2 ID Path Table1ID -- ---- -------- 23 PathA 1 24 PathX 2 25 PathC 3 26 PathZ 4 In the above, PathX should be PathB and PathZ should be PathD How do I sync all the path values in Table2 with values in Table 1, the tables could be large so woul...

Accessing huge data from Remote Server in C#

Hi, I have a database based in NY and my HK users are trying to get the data from this database. The data retrieved is approximately 20 mb (if you save the Datatable as csv the file size is 20 mb). It is taking around 20 mins for the data to come. I am using SQL Server 2005 as database and c# as desktop application. I cannot have a se...

SQL 2005 Maintenance Cleanup Task .bak files not being deleted

I have a SQL 2005 Maintenance plan that runs a backup to create a .bak file, and, on successful completion is supposed to run a Maintenance Clean Up task to delete any .bak files in the folder the back up task saves to that are older than 5 days. My backups are being created, but my old files aren't being deleted. I don't see any error...

what is faster query (select name .... or select top(1) name...

Hi what is faster query ? select Name from Worker or select TOP(1) Name from Worker I have 1,000,000 records thank's in advance ...

SQL Server replication without deletes?

Is there a way to replicate a sql server database but not push out deletes to the subscribers? ...

grabbing first result set from a stored proc called from another stored proc

I have a SQL Server 2005 stored proc which returns two result sets which are different in schema. Another stored proc executes it as an Insert-Exec. However I need to insert the first result set, not the last one. What's a way to do this? I can create a new stored proc which is a copy of the first one which returns just the result set ...

Difference between a inline function and a view

I am a newbie in using functions and it appears to me that an inline function is very similar to a view. Am I correct? Also, can I have UPDATE statements within a function? ...

"Invalid character value for cast specification" for linked 2008 SQL server in 2005 instance

I am attempting to create a linked server from a 2005 to 2008 Microsoft SQL Server. I do this regularly for 2005 instances, but this is the first step of my long journey into SQL 2008. I am able to create the linked server as any other linked server, I receive no errors, however any time I try to use the linked server for anything (a sim...

Can Reporting Sevices be used to format XML returned in an XML data type column?

Using SQL Server 2005 and Reporting Services, I have a stored proc that returns several columns, one of which is of the XML data type. Can I manipulate/format/style that XML column in my Reporting Services report? If so, how? ...

Attached SQL 2000 DB in a SQL 2005 Server, Now getting VB6 App throwing errors

A SQL 2000 db was detached, SQL 2000 was uninstalled. Then SQL 2005 installed in the same machine. Then the database was attached to the newly installed SQL 2005 server. It seemed to work at first but after the users started to poke around, error related to null started to pop. Null values from datetime columns that DID NOT have nulls, a...