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. Being a piece of the Internet business industry, you presumably know that it is so significant to stand apart from the group and establish a long term connection with your clients. This you can quickly accomplish on the off chance that you enlist Magento 2 engineer.

    Such a developer will assist your internet based store with turning out to be genuinely exceptional and communicated your image vision as best as could really be expected. Given the huge number of modules and formats presented by Magento and the mastery of an ensured engineer, you will make a site that will establish a five star connection with your clients and abandon your rivals>> affordable magento development

    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

Publicar un comentario

Entradas populares de este blog

The Deep Sea: una web interactiva para explorar las profundidades el mar y descubrir las extrañas criaturas que viven en él

Detectar el usuario de Windows utilizando C#

Lo nuevo de SQL Server 2008 respecto a SQL Server 2005