I spend y'day and today trying to implement promotion and loyalty funcanaliity to our winPOS. It was not that easy when I discuss the funcations, but when i put it in to a paper and wrote down the logic how to implelemnt it wasn't that much. prob i was thinking too much and strees out.
I found a very intersting artical today at SQLServerCentral check it out
http://www.sqlservercentral.com/columnists/sjones/...
SP to Script SQL Server tables ..
/********************************************************/
/****** Object: Stored Procedure dbo.proc_genscript
/******Script Date: 5/8/2003 11:06:52 AM ******/
/****** Created By: Shailesh Khanal ******/
/********************************************************/
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[sp_ScriptObject]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[sp_ScriptObject]
GO
/* This procedure will script out one object so it can be recreated using a T-SQL Script
Modified 11/18/04 to handle Alerts and Operators
Usage:
exec sp_ScriptObject
@ServerName = 'Server Name',
@DBName = 'Database Name',
@ObjectName = 'Object Name to generate script for',
@ObjectType = 'Object Type',
@TableName = 'Parent table name for index and trigger',
@ScriptFile = 'File name to save the script'
*/
CREATE PROCEDURE sp_ScriptObject
@ServerName VARCHAR(30),
@DBName VARCHAR(30),
@ObjectName VARCHAR(256),
@ObjectType VARCHAR(10),
@TableName VARCHAR(50),
@ScriptFile VARCHAR(256)
AS
DECLARE @CmdStr VARCHAR(256)
DECLARE @object INT
DECLARE @hr INT
SET NOCOUNT ON
SET @CmdStr = 'Connect('+@ServerName+')'
EXEC @hr = sp_OACreate 'SQLDMO.SQLServer', @object OUT
--Comment out for standard login
EXEC @hr = sp_OASetProperty @object, 'LoginSecure', TRUE
/* Uncomment for Standard Login
EXEC @hr = sp_OASetProperty @object, 'Login', 'sa'
EXEC @hr = sp_OASetProperty @object, 'password', 'sapassword'
*/
EXEC @hr = sp_OAMethod @object,@CmdStr
SET @CmdStr =
CASE @ObjectType
WHEN 'Database' THEN 'Databases("'
WHEN 'Procedure' THEN 'Databases("' + @DBName + '").StoredProcedures("'
WHEN 'View' THEN 'Databases("' + @DBName + '").Views("'
WHEN 'Table' THEN 'Databases("' + @DBName + '").Tables("'
WHEN 'Index' THEN 'Databases("' + @DBName + '").Tables("' + @TableName + '").Indexes("'
WHEN 'Trigger' THEN 'Databases("' + @DBName + '").Tables("' + @TableName + '").Triggers("'
WHEN 'Key' THEN 'Databases("' + @DBName + '").Tables("' + @TableName + '").Keys("'
WHEN 'Check' THEN 'Databases("' + @DBName + '").Tables("' + @TableName + '").Checks("'
WHEN 'Job' THEN 'Jobserver.Jobs("'
WHEN 'Alert' THEN 'Jobserver.Alerts("'
WHEN 'Operator' THEN 'Jobserver.Operators("'
END
SET @CmdStr = @CmdStr + @ObjectName + '").Script(5,"' + @ScriptFile + '")'
EXEC @hr = sp_OAMethod @object, @CmdStr
EXEC @hr = sp_OADestroy @object
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
No comments:
Post a Comment