sql-server-2005

Get the inverse of a join?

I am using SQL Server 2005. I have three tables - Users, Groups, and GroupUsers. GroupUsers contains the two PKs for a many-to-many relationship. I have a view to get all the user information for a group as follows: SELECT * FROM GroupUsers JOIN Users ON GroupUsers.UserID = Users.UserId I want to create the inverse of this view - I w...

Add Package-scope Variable to Output (SSIS)

I'm trying to create an SSIS package to move data from an Excel spreadsheet into a SQL Server 2005 table. It's mostly going okay, considering that this is the third time I've tried to build a package at all (not what you'd call a flat learning curve). The one thing I'm just not getting through my skull is how to include a package-scope...

SQL Server: View and DateTimes

I have the following table Foo: start | end | cause -------------+-------------+---------- 2007/12/22 | 2008/02/12 | 2 2008/03/18 | 1900/01/01 | -1 there are stored various periods of time. cause '-1' and end '1900/01/01' means the time period has no end. Under certain conditions, the application using thi...

Update function in TSQL trigger

I have a question about TSQL function Update. For example, I have a table with a field Name. If I check if the field Name is changed or not in a After Update trigger likes this: if Update(Name) Begin -- process End Will the Update still return TRUE even if Name is not changed? The following update statement will update it wi...

SQLDateTime overflow in SqlServer 2005, but not in 2008

This is a slightly odd problem, which means the solution is probably something trivial that im just missing. I have SQLServer 2008 developer on my local. I was using the Date type, and then realized godaddy uses 2005 which Only supports datetime. Im using LINQ, so I just changed to a datetime on the database side and changed the server ...

What data type is best for storing comments in SQL Server?

What is an effective datatype in SQL 2005 to store a comments field? ...

Querying Active Directory from Sql Server 2005

How I can query Active Directory from Sql Server 2005? ...

Terminating a script once condition is met

Hi everyone, I am trying to solve this problem. I have a series of SELECT statements like below. SELECT Name FROM Table1 WHERE Name LIKE '%Tom%' SELECT Name From Table2 WHERE Name LIKE '%Tom%' . . . SELECT Name FROM Table10 WHERE Name Like '%Tom%' Without using IF ELSE statements, is there any way I can terminate this script halfw...

SQL Server Enterprise Manager 2005 with sqlserver 2005 express

Is it possible to use Enterprise Manager 2005 with sqlserver 2005 express? I want to use full text creation wizards that available only in Enterprise Manager, with sqlserver 2005 express. ...

SQL Server 2005 - Are there any major negative implications to returning multiple tables w/ stored procedures?

I've run across multiple situations in the last few months where legacy sql SP's are returning a single table made up mostly of redundant information. Example: Select CustomerID, CustomerEmail, CustomerAddress, InventoryLineItem, ShipQty from ... Returns: 55 [email protected] 723 StreetName InvLineItem#1 45 55 [email protected] 723 StreetName InvLineIt...

The different combinations of join are confusing, can someone boil it down a little?

Looking at JOIN's this weekend. I was reading up on Join and seeing a ton of combinations of JOIN, LEFT, RIGHT, OUTER, FULL, INNER. I checked the MSDN docs and it looks like the only allowed combinations are in the form: < join_type > ::= [ INNER | { { LEFT | RIGHT | FULL } [ OUTER] } ] [ < join_hint > ] JOIN so from tha...

Excel to SQL direct import error

Working for a considerable time on cracking some sales data, I came across an error which started to bug me for so real, eating my time of work. After so much of an effort, I was so fed up and nearly to give up on un-importable records. The scenario: Bulk sales data comes on txt/csv format needs to be imported to SQL database and then...

Counting consecutive duplicate records with SQL

I have a data-analysis question, that I could easily solve with some T-SQL or some scripting, but I was wondering if there was a clever SQL solution. The problem is that it messes a bit with SQL's row-independence assumption a bit. I have a table that consists of name-value pairs associated with a user and ordered by submission, for exa...

Does creating a unique constraint on a column automatically create index?

Consider this unique constraint: ALTER TABLE Posts ADD CONSTRAINT UQ_Posts_Name UNIQUE (Name); Does it automatically create index on Name column? ...

Is it possible to make SP/Function as private ones?

I am using Microsoft SQL 2005 server. I have created several SP and Functions in TSQL. After more than one year's development, the number of SP/Functions have grown dramatically. Only a few of SP/Functions are used as scheduled jobs or triggers, and most of them are used internally(I mean they are called by SP/Functions in jobs and trigg...

Debugging Stored Procedures In Visual Studio 2008

I have a similar question link text The database is located on the server (not attached in App_data folder) When I set breakpoints, and click Step Into Stored Procedure, The breakpoints get disabled: the breakpoint will not currently be hit. unable to bind sql breakpoint at this time ...

Combining INSERT and UPDATE statement (SQL2005 Stored Procedure)

Hi, I need to extract records from a table, copy the data to a second table and then update the records in the first table to indicate that they have been copied across successfully. My current SP code is this: SELECT TBL_ADDRESSBOOKADDRESSES.* FROM TBL_ADDRESSBOOKADDRESSES INNER JOIN TBL_CAMPAIGNS ON TBL_ADDRESSBOOKADDRESSES.adds_AB...

Determine what user created objects in SQL Server

I'm trying to go through our development DB right now and clean up some of the old test procs/tables. Is it possible to determine what user created objects in a SQL Server 2005 database? If so, how would I go about finding that information? Edit: Just wanted to clarify that the objects in question already exist. Setting up auditing and ...

[SSRS 2005] ReportViewer duplicate toolbar on bottom of report?

Is there a means to duplicate the toolbar so it shows at the top and bottom of the report page? It can be a pain on long reports to scroll up to the top of the page in order to use various functions. In my searching, I found this link about extending the ReportViewer control. Has anyone worked with it? ...

SQL Server 2005 longest running query per database

Hi all, I am using this SELECT * FROM sys.dm_exec_query_stats s CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t ORDER BY s.max_elapsed_time DESC to get the longest running queries on the server level. How do I get the longest running queries per database? I would like to focus only on one database at a time. Thanks, Edi ...