Viewing 15 posts - 1 through 15 (of 683 total)
One option (of many) is to simply adapt the above (by adding a distinct and removing the ids):
declare @t table (id int identity(1, 1), v varchar(50))
insert @t
...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
October 28, 2010 at 9:15 am
A few alternatives (just for fun)...
--row_number() version [generally the preferred approach, I would imagine]
; with t1 as (
select *, row_number() over (partition by ProductID order...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
January 29, 2010 at 3:47 am
I should select all alpha-numeric name
This makes it sound like you have a different requirement, since the original poster was asking for non-alphanumeric data. Maybe you want something like this?
--Sample...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
January 6, 2010 at 11:41 am
This?
declare @SOURCE table (membershipid varchar(100), membername varchar(100), membershiptype varchar(100))
insert @SOURCE
select 424400000000, 'Andre Sim', 'Premium'
union all select 424400010000, 'Hello',...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
December 11, 2009 at 9:46 am
Similar question (and answer) here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=130994
Recommended article here: http://www.sommarskog.se/dynamic_sql.html
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
December 11, 2009 at 9:01 am
Here's my first stab in the meanwhile...
; with
t1 as (SELECT *, row_number() over (order by start_id) drow FROM @destination_scenario1)
, t2 as (select id, max(drow) as drow from @source_scenario1...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
December 10, 2009 at 5:18 am
Can you explain why...
1. -700 -600 is not inserted into @destination_scenario1?
2. -400 -260 and -260 -120 are not expected outputs for scenario 2
Thanks 🙂
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
December 10, 2009 at 5:12 am
Here's some stuff to play around with, should you wish...
--structure
create table dbo.Myversionbatchlog (id int, versionsxml xml)
--/
--data
insert dbo.Myversionbatchlog
select 11, '<xml><version rowid="1"...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
December 4, 2009 at 3:05 am
Maybe it's the table variable. Can you eliminate it with something along these lines?
declare @versionbatchlog table (id int, versionsxml xml)
insert @versionbatchlog
select 11, '<xml><version rowid="1" alias="hello world" />
...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
December 3, 2009 at 12:07 pm
There's an old article on it on this site...
http://www.sqlservercentral.com/articles/SQL+Server+2005+-+TSQL/dedupingdatainsqlserver2005/2260/
This option became available with SQL Server 2005.
Jim C-203340 (11/30/2009)
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
November 30, 2009 at 6:42 am
unladenswallow (4/28/2009)
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 29, 2009 at 3:21 am
GSquared (1/12/2009)
Normally you can't update a view that has a union operator in it, unless you follow very specific rules about partitioned tables.
Good catch, GSquared - I was careless with...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
January 12, 2009 at 8:29 am
Thanks Frédéric 🙂
I dare say that's my first ever 'publication' in a foreign language - great stuff!
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
January 9, 2009 at 4:35 pm
I guess you could create a view which is the union of all your tables, and then update the view.
Having many similarly named tables is usually an indication that a...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
January 9, 2009 at 10:29 am
Frédéric BROUARD (1/8/2009) ...
Here's something similar for comparison, making use of powers of 2 rather than LIKE, and XML rather than string manuipulation.
--preparation
IF OBJECT_ID('tempdb.dbo.#t1') IS NOT NULL DROP TABLE...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
January 9, 2009 at 4:39 am
Viewing 15 posts - 1 through 15 (of 683 total)