Vytvořit uloženou proceduru?
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= CREATE PROCEDURE [dbo].[ImportData] @date varchar(15) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here DECLARE @query AS varchar(MAX) SET @query = 'CREATE DATABASE aug29 USE aug29 BULK INSERT dbo.Table FROM ''\\Drive\Documents\''' + @date + '''-xxx.txt'' WITH (FIRSTROW = 2, FIELDTERMINATOR = ''\t'', ROWTERMINATOR = ''\n'')' EXEC(@query) END
Poté na SSMS otevřete svou databázi> Programovatelnost> Uložené procedury> Klikněte pravým tlačítkem na nově vytvořenou uloženou proceduru (ImportData nebo jakkoli ji pojmenujete)> Spustit uloženou proceduru.
Uživatelé pak mohou zadat hodnotu parametru @date.