tsql

select query by range

Hi I want to select values from tables by passing two parameters like start and end ranges How can i get it? Ex: sid sname s001 name1 s002 name2 s003 name3 s004 name4 s005 name5 s006 name6 s007 name7 s008 name8 s009 name9 s0010 name10 here i want to pass two values like 3 and 5 so that my quer...

How to get last modification datetime on Sql Server 2005?

Is there any way to get a table's last modification datetime on Sql Server 2005? Preferably without creating triggers.. And for databases? EDIT The solution of this question contemplated only CREATE and ALTER modifications. For INSERT, UPDATE and DELETE please look my next question ...

How to get last insert/update/delete datetime on Sql Server 2005?

not a duplicate of my previous question Is there any way to get the latest datetime when a table/database had an insert/update/delete on Sql Server 2005? Preferably without creating triggers.. I know that when you need the last update per row, you need triggers. But I am not sure if they are needed when you just want to get the last up...

How do I search a NTEXT column for XML attributes and update the values? MS SQL 2005

Duplicate: this exact question was asked by the same author in http://stackoverflow.com/questions/1221583/how-do-i-update-a-xml-string-in-an-ntext-column-in-sql-server. Please close this one and answer in the original question. I have a SQL table with 2 columns. ID(int) and Value(ntext) The value rows have all sorts of xml strings in...

How can I accomplish this? Would a cursor be appropriate?

I am trying to use TOAD and T-SQL to approximate a user's spreadsheet. Here are the basics of what they want: Order Number Customer Name June July Aug Sept Oct Nov Dec 12345 Bleh Company 1000 800 200 The first row represents when the order value was received and t...

SQL query question

I have a table that has about 6 fields. I want to write a SQL statement that will return all records that do not have "England" in the country field, English in the language field & english in the comments field. What would the sql query be like? ...

Best way to get rid of unwanted sql subselects?

I have a table called Registrations with the following fields: Id DateStarted (not null) DateCompleted (nullable) I have a bar chart which shows the number of registrations started and completed by date. My query looks like: ; WITH Initial(DateStarted, StartCount) as ( select Datestarted, COUNT(*) FROM Registrations GROU...

Which free database (other than SQL Express) has SQL syntax most similar to T-SQL?

I think there is an upgrade/downgrade path between MySQL and DB2 because they are both pretty ANSI standards compliant. Other than SQL Express, is there a similar pairing of free-"ish"/paid databases for SQL Server? Another way to state the question-- of the free db engines that exist, which is the least painful to migrate T-SQL to? ...

SQL Insert Procedure

Why isn't my insert procedure returning the ID of the newly inserted row? AND, when calling this procedure, why do I have to supply a value for @EventId? That column is a PK with IDENTITY. IF OBJECT_ID ( 'vjsql.EventsINSERT', 'P') IS NOT NULL DROP PROCEDURE EventsINSERT GO CREATE PROCEDURE EventsINSERT @EventId int OUTP...

SQL Server add job agent T-SQL script issue

Hello everyone, I am using SQL Server 2008 Enterprise. I have created a very simple test SQL Server Agent job which just print out a string. And then I add a schedule to let the job run once a day. Then I select from SQL Server Management Studio => Jobs => Select the test job => Script Job as => Drop and Create To, here is the generate...

import data from one table to another table

Hello everyone, I am using SQL Server 2008 Enterprise. I need to import all data from Server/Instance "Server Foo", Database "Foo" and table "Foo", into destination Server/Instance "Server Goo", Database "Goo" and table "Goo". Table Foo and Table Goo are of the same schema. If the same row exists for table Goo, I want to keep the origin...

How to modify multiple nodes using SQL XQuery in MS SQL 2005

In an table I have the following. ParameterID (int) ParameterValue (XML) ------------ -------------- 1 <USER><User ID="1" Name="Billy"/><USER> <USER><User ID="2" Name="Billy"/><USER> <MANAGER><User ID="1" Name="Billy"/><MANAGER> 2 <USER><User ID="1" Name="John"/><USER> ...

Fastest way for this query (What is the best strategy) given a date range

I have a table A that has a startDate and an end dateDate as 2 datetime columns besides some more other columns. I have another table B that has one datetime column call it dates column. This is in SQL Server 2005. Here the question: How to best set up the indexes etc to get the following: select .... from A , B where A.startDate >= B...

Which SQL do you write?

When joining two tables, what are the difference between the two blocks below and which is the better approach? Pattern A: SELECT ... FROM A INNER JOIN B ON A.PK = B.FK WHERE 1=1 AND A.Name = "Foo" AND B.Title = "Bar" Pattern B: SELECT ... FROM A INNER JOIN B ON A.PK = B.FK AND B.Title = "...

Trigger fired in periods.

Can I make a trigger that is fired every x hours? ...

isdate function in ssis derived component

Hi Is there any way to check Date(like isDate function in TSQL) column in SSIS package derived column expression after extraction from Sourcefile before loading to target dtabase? Thanks ...

SQL Query to get Matrix reporting

My "FeedbackSummary" table structure is GivenBy varchar(50) GivenTo varchar(50) Points decimal(15, 2) Sample Data Alice Janet 4.50 Alice Bruce 3.50 Bruce Alice 2.87 Bruce Janet 4.75 Janet Alice 5.45 Janet Bruce 3.78 What I am trying to achieve GivenBy_GivenTo Alice Bruce Janet Alice NULL 3.50 4.50 Bruce 2.87 ...

Error converting data type varchar

Hi, I currently have a table with a column as varchar. This column can hold numbers or text. During certain queries I treat it as a bigint column (I do a join between it and a column in another table that is bigint) As long as there were only numbers in this field had no trouble but the minute even one row had text and not numbers in t...

Seeking Modularity In SQL Server 2005 - Returning Multiple Recordsets To A Stored Procedure

Hi, I've had this problem a few times and solved it the same way. But it's not pretty and I was wondering if anyone knew of anything a bit more elegant... The Basic Aim: - I have a piece of code that is common through-out many Stored Procedures. - For maintenance purposes I like modularity. - So I want to put that common code in it's o...

Split string in T-SQL.

How can I get the string "text." from the string "This is my text."? ...