sql-server-2005

Pull Data from Text File Before Appending it to Table in SQL-Server 2005 DTS

I have to work in a DTS environment in 2005 (too complicated to explain) and I have a comma delimited text file that is to be appended to the main table. I'd like to pull the last column in the text file out for the first record and use it as select criteria for a delete command. But how can I do this in the older DTS environment? Her...

Generate CREATE scripts for a list of indexes

Hi all! As part of a collation changing exercise, I have a list of indexes (122) that needs to be dropped and then re-created. How can I re-create these indexes without having to go through the GUI and scripting it to a query window each time? My list of indexes is obtained from this script WITH indexCTE AS ( SELECT Table_Nam...

Get last log line per unique host from table

Hi, I have inherited an application that logs the results of certain daily commands that run on multiple hosts to an MS-SQL table. Now I've been asked to provide a view/query that displays the last log line per host to get an overview of the last results. The table is similar to this: ------------------------------ |HOST |LAST_RUN ...

Help me with this SQL: 'DO THIS for ALL ROWS in TABLE'

[using SQL Server 2005] I have a table full of users, I want to assign every single user in the table (16,000+) to a course by creating a new entry in the assignment table as well as a new entry in the course tracking table so their data can be tracked. The problem is I do no know how to do a loop in SQL because I don't think you can bu...

ASP.NET > SqlServer; trust and delegation

Hello all, we have a system where they client wants integrated Windows authentication. This is an ASP.NET 3.5 application, connecting to Sql Server 2005. The web server is Server 2003 R2 SP2. The db server is Server 2003 SP2 (not R2). In the db server, I ran the following script exec sp_grantlogin 'myDomain\myUserGroup' USE myDbNam...

SQL Dynamic Pivot - how to order columns

I'm working on a dynamic pivot query on a table that contains: OID - OrderID Size - size of the product BucketNum - the order that the sizes should go quantity - how many ordered The size column contains different sizes depending upon the OID. So, using the code found here, I put this together: DECLARE @listCol VARCHAR(2000) DE...

How do I copy a CLOB from Oracle into SQL Server

The CLOB is XML data that is > 8k (sometimes > 32k). Any suggestions? ...

Query for total should keep on adding with each row of cost Column

Hi I have table with columns as Operation Cost Material Issue 10 Material Return 20 X 30 Y 40 Z 50 I want want a query where columns are Operation Cost Total Material Issue 10 ...

SQL Server 2005 Perform "RECOVERY" on database restored with "NORECOVERY"

I have full weekly backups, daily differential backups and hourly transaction log backups. To restore the database, I restore the full backup, then the last dif backup then all the transaction log backups specifying NORECOVERY on all the restores except the last one. My question is. If I accidently restore my last transaction log with ...

Store Files in SQL Server or keep them on the File Server?

Hi, Currently we have thousands of Microsoft Word files, Excel files, PDF's, images etc stored in folders/sub folders. These are generated by an application on a regular basis and can be accessed at any time within that application. As we look to upgrade we are now looking into storing all these documents within SQL Server 2005 instead....

SQL Server Tree Hierarchy and Nested Sets with Duplicate Record ids

Given that I have this resultset structure (superfluous fields have been stripped) Id | ParentId | Name | Depth ---------------------------- is it possible to have the records returned in tree order i.e. Parent then Children, if a Child is a Parent, then their Children, if not then Sibling, etc? For example, Id | ParentId | Name | De...

Multiple Search Option in SQL SERVER 2005

I have a requirement. Given say Test1,Test2, I have to perform a like operation. Something like select * from tblname where column_name like('Test1%','Test2%'); i.e. these strings are comma separated How do I solve this? This is in SQL SERVER 2005. Thanks in Advance ...

Insert a value from one cell into another cell from the same record

How can I insert a value from once cell into another cell from the same record for each record in a table, overwriting the original value from the destination? It's a one time query. Using Sql server 2008 e.g.: origin|destination ------|----------- 1 | A 2 | B 3 | C to origin|destination ------|----------- 1 | 1 2 ...

how to convert a single row into Column in SQL Server 2005

Hi, I have a table, and it is returning the data as - Column1 Column2 Column3 Column4 Column5 Column6 ------------------------------------------------------------------- 6 Joy Mycity NZ 123456 [email protected] I need to disply it as - SingleColumn ----------------------- 6 joy mycity NZ 123456 m...

VBScript to connect to SQL Server 2005 and update a table

I am new to VBScript. Can someone please help me to connect to SQL Server 2005 (OLEDB) using VBScript and update a table in the database. My server: sql14\qw My database: fret User id: admin Pasword: pass Table name: lookup ...

Collation Problem - SQL Server 2005

I would like to understand this error I'm getting on a SQL Server 2005 instance. Error below: Cannot resolve the collation conflict between "Latin1_General_CI_AI" and "SQL_Latin1_General_CP1_CI_AI" in the equal to operation. Both databases included in a simple query have Latin1 General CI AI, but had SQL Latin1 General CP1 CI...

How to determine where, or if, a variable is used in an SSIS package

I've inherited a collection of largely undocumented ssis packages. The entry point package (ie: the one that forks off in a variety of directions to call other packages) defines a number of variables. I would like to know how these variables are being used, but there doesn't seem to be an equivalent of "right click/Find All References"...

Stored Procedure: Linked server login failure.

I'm getting "Msg 18456, Level 14, State 1, Line 1 Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'." from when trying to execute the code below. I've change all of the critical information, but you should get the idea. Are some of my parameter incorrect? The local sql admin username is correct and the remote username and password is...

How can I speed up batch processing job in Coldfusion?

Every once in awhile I am fed a large data file that my client uploads and that needs to be processed through CMFL. The problem is that if I put the processing on a CF page, then it runs into a timeout issue after 120 seconds. I was able to move the processing code to a CFC where it seems to not have the timeout issue. However, sometime ...

Mass change datatype and rename of dependent store procedure variables

Hi all I am in the process of optimising my database and I was thinking of changing the datatype for some columns from DATETIME to SMALLDATETIME on my tables. Is there a system stored procedure that returns both the contents/code of a store procedure and the dependent table which will then allow me to do a join on a filtered list of ta...