Como crear 10 o 100 tablas en SQL Server

   declare @count int=1

  declare @sql varchar(100)


  --select @sql

  WHILE (@count =<10)

  BEGIN

set @sql=CONCAT('create table',SPACE(1),'T',@count,

  '(c1 int)')

execute (@sql)

set @count=@count+1

  END

El código crea tablas t1, t2, t3 hasta el 10. Si uno desea crear más tablas cambia el 10 por el número de tablas que desea.

Básicamente se tiene un contador que se llama count. Y ese contador le aumenta el nombre de manera dinámica. El comando CONCAT concatena la sentencia create table y usando la variable count.



Comentarios

  1. Este comentario ha sido eliminado por el autor.

    ResponderEliminar
  2. A hook maker for essay is an invaluable tool for captivating your readers right from the start. It provides the perfect opening line or paragraph that grabs attention and sets the tone for your entire essay. With a hook maker, you can create compelling introductions that leave a lasting impression, making your essay stand out and engage your audience from the very beginning.

    ResponderEliminar
  3. This article provides a detailed comparison between Flutter vs React Native, helping readers make an informed decision on which framework to choose for their mobile app development. The analysis of various aspects such as performance, development speed, and community support is valuable for anyone looking to delve into cross-platform app development.

    ResponderEliminar

Publicar un comentario

Entradas populares de este blog

Detectar el usuario de Windows utilizando C#

La página oficial del dólar blue en Bolivia

Lo nuevo de SQL Server 2008 respecto a SQL Server 2005