sql-server-2005

How to create automatically a table populate script from current data in SQL Server?

Is there a tool that allows me to create a sql populate script for a table using its current data? ...

Can SQL 2008 Business Intelligence Studio SSIS packages run in SQL 2005?

Is it possible to run an SSIS package created by SQL 2008 Business Intelligence Studio in a SQL 2005 environment? I'd rather not have to install SQL 2005 / VS 2005 in my development environment. ...

Want the data of Upline and Downline for particular ID

here is the table and data like: id name 1 test1 2 test2 3 test3 4 test4 5 test5 6 test6 From above data i want the data like if i pass the id as parameter and return the data from from up and gown by order Example if i pass the id as parameter = 4 then it should be return upline 2 row and downline 2 row for particular id,...

Recording SQL Server call stack when reporting errors

This is a follow up to the question Nested stored procedures containing TRY CATCH ROLLBACK pattern? In the catch block I use a stored procedure to report (reraise) the error by reading from ERROR_MESSAGE(), ERROR_PROCEDURE(), ERROR_LINE(), etc. As described here I also have a check so that it can determine if the error has already been ...

selecting latest rows per disctinct foreign key value

excuse the title, i couldn't come up with something short and to the point... I've got a table 'updates' with the three columns, text, typeid, created - text is a text field, typeid is a foreign key from a 'type' table and created is a timestamp. A user is entering an update and select the 'type' it corresponds too. There's a correspon...

How to synchronize SQL Server 2008 database with SQL Server 2005 database?

I am using VS 2008 Team Suite and SQL Server 2008 in my development environment. I am deploying to a shared-host website with shared-host SQL Server 2005. I want to push changes from my development environment to my production host. I tried using Data | Schema Compare... and it reports to me that it does not support SQL Server 2008. W...

SQL HAVING SUM GROUP BY

Using SQL Server 2005. I am building an inventory/purchasing program and I’m at the point where I need the user to “check out” equipment. When he selects a product, I need to query which stock locations have the available Qty, and tell the user which location to walk to/ retrieve product. Here is a query for a particular [StockLocation_...

SSIS script component question - no output columns defined, but I do get output

Hi everyone, I have an SSIS package that runs a script component as one step in a series that transforms data from a flat file to a SQL table. The script component itself is pretty straightforward, but I had a question about its input and output columns. As you can see from this image the script appears to have no output columns defin...

List SQL Express 2005 instances using VB6 code

How to list all the instances of SQL Server 2005 Express Edition using vb6 application? ...

SQL Server query : SELECT 1 WHERE EXISTS versus SELECT TOP 1 1

I need to present a flag - 0 if a condition is not meet, 1 if it is - and I can do it in two different ways : Get Employee ID, name, 1 if has others in suborder - 0 if not : SELECT e.ID , e.Name , ISNULL ( ( SELECT TOP 1 1 FROM Employee se WHERE se.ManagerID = e.ID ) , 0 ) AS HasSubordinates FROM Employee e or SELECT ...

Parent Child table record - Building SQL query

Here is my table and data of these tables Table name: Code CID Code 1 abc 2 def 3 xyz Table Name : Details ID Date Value1 CID 1 1/1/2009 12 1 2 1/1/2009 25 2 3 1/1/2009 18 3 4 1/2/2009 36 1 5 1/2/2009 45 2 6 1/3/2009 19 1 Resulta...

Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Splitfn", or the name is ambiguous.

Hai guys, I ve used the following split function, CREATE FUNCTION dbo.Splitfn(@String varchar(8000), @Delimiter char(1)) returns @temptable TABLE (items varchar(8000)) as begin declare @idx int declare @slice varchar(8000) select @idx = 1 if len(@String)<1 or @String is null retur...

SQL Server 2005, bulk UPDATE or INSERT

Hello, I'm looking for a solution to perform Insert, on duplicate key Update like operation in SQL Server 2005. This operation might Insert or Update large number of entries. SQL Server 2008 has a neat operation MERGE which would do it perfectly, the problem is we're stuck with SQL Server 2005. I've looked into standard solutions, but a...

update statement in sql server 2005

Consider the following Dig, Assume that all the three tables have a column Is_Deleted by default it is set to 0... I want to update Is_Deleted=1 field of Customers table where CustId=2 only when the rows containing CustId=2 and Is_Deleted=1 in Orders and OrderItems Tables... I dont want to use Cascade option.. Any suggestion ...

How can remove lock from table in SQL Server 2005?

I am using the Function in stored procedure , procedure contain transaction and update the table and insert values in the same table , while the function is call in procedure is also fetch data from same table. i get the procedure is hang with function. Can have any solution for the same? ...

Converting Data in SSIS

This is probably an easy task in SSIS but having little experience with the tool and having failed to find the answer in the documentation, I turn to the experts here. I appreciate any and all help I might get. I've got an SSIS package that reads the contents of an Excel spreadsheet and dumps the information into a database table. Tha...

Design Tables to hold multi-Country data

We're becoming an international company and I have been tasked with designing how we're going to store the different countries' specific data. Such as language, postal code regex, telephone number regex, country calling codes, currency, etc. Currently we have tables like these: Countries, Languages, CountryLanguages, CountryCallingCod...

Update multiple columns from a subquery?

How can I avoid the duplicated subquery in the following T-SQL statement: update r set column1=(select top 1 max(column1) from region r2 where (overlapping test conditions)), column2=(select top 1 max(column2) from region r2 where (overlapping test conditions)) from region r Basically, I have a table containing rectangle regions. ...

TSQL - Use a Derived Select Column in the Where Clause

Is there a way in TSQL to do something like this: select a,b,c, case when a=1 then 5 when a=2 then 6 end as d from some_table where d=6 The actual case statement is really complex, so I'm trying to avoid repeating it in the where clause? Are there any tricks to do this? (I think there's a trick in MySQL to use "having d=6"). ...

Fetch the row which has the Max value for a column in SQL Server

I found a question that was very similar to this one, but using features that seem exclusive to Oracle. I'm looking to do this in SQL Server. I have a table like this: MyTable -------------------- MyTableID INT PK UserID INT Counter INT Each user can have multiple rows, with different values for Counter in each row. I need t...