Vil du oprette en lagret procedure?
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
Åbn derefter din database på SSMS> Programmerbarhed> Lagrede procedurer> Højreklik på den nyoprettede Stored Procedure (ImportData eller hvad du nu kalder det)> Udfør Stored Procedure.
Brugere kan derefter indtaste værdien for @date-parameteren.