On Feb 27, 12:52 am, shapper <mdmo...@gmail.com> wrote:
> Hello,
>
> I am using a Numbers table to create test data:
>
> -- Categories
> insert into dbo.Categories (CategoryID, [Name])
> select
> newid(),
> 'Category ' + cast(n as nvarchar)
> from @Numbers
> where n <= @categories
>
> @categories is the number of categories I want to create. I create
> articles the same way.
>
> Now I want to associate each article to X categories.
>
> However, for each article X should be a random number between @Min and
> @Max.
>
> Of course I will set @Max smaller than the number or articles.
>
> I also have a Random Function that returns an integer between
> @StartInt and @EndInt:
>
> create function dbo.NumberTable
> (
> @startint int,
> @endint int
> )
> ...
>
> My question is how to do the inserting?
> What I have in this moment is the following:
>
> insert into dbo.ArticlesCategories(ArticleID, CategoryID)
> select ArticleID, CategoryID
> from dbo.Articles
> join dbo.Categories on CategoryID in (
> ?????????????????????????????????????
> from dbo.Categories c
> order by newid()
> )
>
> Thanks,
> Miguel
Sorry, wrong forum.
Thanks,
Miguel
|