Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create data from a range
Message
De
17/10/2014 07:11:21
 
 
À
17/10/2014 06:50:58
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01609576
Message ID:
01609577
Vues:
39
>Hi
>
>I have a list of data
>
>ID From To
>1001 100 103
>
>I want to use this to create data rows in another table
>
>ID Type
>1001 100
>1001 101
>1001 102
>1001 103
>
>any thoughts on the best way to do this in sql
>
>Thanks
>
>Nick

I've got it thanks
 WITH each AS
(
    SELECT an_eventid,  an_label_range_start AS n, an_label_range_end
      FROM SERVER01.dbo.campaign where an_label_range_start is not NULL
    UNION ALL
    SELECT an_eventid,  n + 1, an_label_range_end
      FROM each
     WHERE n + 1 <= an_label_range_end
)
SELECT an_eventid,  n
FROM each order by an_EventID,n 
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform