Friday, May 10, 2013

[T-SQL] Trigger effect

SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)

[T-SQL] Trigger effect


Trigger effect

Posted: 10 May 2013 01:26 AM PDT

Hi, I have a scenario...I have a table Table1 with columns ID, Names, WorkLocationI have created a trigger which onupdation insert a data in some audit table...Update table1SET Name = ......WHERE ID = .....But now I am some another column of this tableUpdate table1SET WorkLocation=.......WHERE ID=.........But when I do update on this WorkLocation column then also that trigger fire..How can I prevent to run that Trigger..That trigger should run when I do update on Name column only...

Weird interview question

Posted: 09 May 2013 06:34 AM PDT

Hello All,I was prescreened for a Senior SQL Program Analyst position and one of the questions asked is shown below. I have been around SQL quite a while but this question doesn't make sense to me. Can anyone help me decipher and understand what the correct answer is and how you got to it? I know this isn't a interview question/answer forum but the subject matter is definitely T-SQL and the correct use of it.6. Field f of a table is indexed. Which of the following query fragments is written so the index cannot be used? (Assume p1 and p2 are the correct data types for their role in each fragment.)a. where f > :p1b. where f between :p1 and dateadd( day, :p2, :p1)c. where dateadd( day, :p2 , f) > :p1d. where dateadd( day, :p2, :p1) < fe. where f not in( select …) Thanks

Another grouping problem

Posted: 09 May 2013 10:34 PM PDT

I have found a bug in my duplicate macthing application and I believe it's with the way I group my records at the end of the matching process.Consider the following example (details are not real!)[img]http://i.imgur.com/zZy2PqS.jpg[/img]52941 matches 8388 and 15799 because mobile number and name is the same80833 matches 8388 and 15799 because name and address matchso this is same as saying 80833 matches 52941, 8388 AND 15799So based on the second result set, I would like to perform a grouping of the outcome to look like this:[img]http://i.imgur.com/NibYbnP.jpg[/img]NOTE, I picked the highest value ID as my Base or Group ID.Any suggestions?

Recursive SQL

Posted: 09 May 2013 08:45 PM PDT

Hi All,Need help on some recursive Data. I would need to get 4 records out of below available If I pass value 395. Since, for 395, COlD (Child of ColA) has value 394. Again we check ColaA for 394 and find the corresponding value in ColD which is 347. Again in ColA 347 corresponds to 0 value in ColD. Total of 4 records.[code="sql"]ColA ColB ColC ColD ColE ColF347 AA 25 0 0 0362 BB 25 347 0 50363 CC 25 362 0 51364 DD 25 347 0 50365 EE 25 364 0 51367 FF 25 365 0 54369 GG 25 347 0 50373 HH 25 347 0 50374 II 25 373 0 51375 JJ 25 374 0 54376 KK 25 374 0 54394 LL 25 347 0 50395 MM 25 394 0 51[/code]I beleive Using While loop this can be done. Any suggestions ?

Add 20 before regular expr (year)

Posted: 09 May 2013 08:39 PM PDT

Hi All,I am getting input file below format.Text-dd.mm.yy.i need to display as 20yy (year) and mm.dd (Issue) For that i am using regular expr. i am using '^Text-(?<Issue>\d{2}\.\d{2}).(?<Year>\d{2})\.txt$'output is yy and dd.mmi need to add 20 before yy i.e. output will be 20yy.Please give your suggestion. Thanks in advance.

T-SQL Testing Options

Posted: 09 May 2013 11:37 AM PDT

Just curious - what are the various options available for testing t-sql code in stored procedures?Specifically how can one step through code as would be done with a .net application.Any advice would be greatly appreciated.Thanks

Pivot table question

Posted: 09 May 2013 10:48 AM PDT

All,I am trying to create a pivot table like the following:Offense ID IncidentID OffenseTypeID etc...[all offense Id rows] [all IncidentID rows] [all Offense TypeID rows]using the following table.[code="sql"]USE [master]GO/****** Object: Database [Lenod] Script Date: 5/9/2013 4:41:43 PM ******/CREATE DATABASE [Lenod] ON PRIMARY ( NAME = N'Lenod', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\Lenod.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'Lenod_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\Lenod_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)GOALTER DATABASE [Lenod] SET COMPATIBILITY_LEVEL = 100GOIF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))beginEXEC [Lenod].[dbo].[sp_fulltext_database] @action = 'enable'endGOALTER DATABASE [Lenod] SET ANSI_NULL_DEFAULT OFF GOALTER DATABASE [Lenod] SET ANSI_NULLS OFF GOALTER DATABASE [Lenod] SET ANSI_PADDING OFF GOALTER DATABASE [Lenod] SET ANSI_WARNINGS OFF GOALTER DATABASE [Lenod] SET ARITHABORT OFF GOALTER DATABASE [Lenod] SET AUTO_CLOSE OFF GOALTER DATABASE [Lenod] SET AUTO_CREATE_STATISTICS ON GOALTER DATABASE [Lenod] SET AUTO_SHRINK OFF GOALTER DATABASE [Lenod] SET AUTO_UPDATE_STATISTICS ON GOALTER DATABASE [Lenod] SET CURSOR_CLOSE_ON_COMMIT OFF GOALTER DATABASE [Lenod] SET CURSOR_DEFAULT GLOBAL GOALTER DATABASE [Lenod] SET CONCAT_NULL_YIELDS_NULL OFF GOALTER DATABASE [Lenod] SET NUMERIC_ROUNDABORT OFF GOALTER DATABASE [Lenod] SET QUOTED_IDENTIFIER OFF GOALTER DATABASE [Lenod] SET RECURSIVE_TRIGGERS OFF GOALTER DATABASE [Lenod] SET DISABLE_BROKER GOALTER DATABASE [Lenod] SET AUTO_UPDATE_STATISTICS_ASYNC OFF GOALTER DATABASE [Lenod] SET DATE_CORRELATION_OPTIMIZATION OFF GOALTER DATABASE [Lenod] SET TRUSTWORTHY OFF GOALTER DATABASE [Lenod] SET ALLOW_SNAPSHOT_ISOLATION OFF GOALTER DATABASE [Lenod] SET PARAMETERIZATION SIMPLE GOALTER DATABASE [Lenod] SET READ_COMMITTED_SNAPSHOT OFF GOALTER DATABASE [Lenod] SET HONOR_BROKER_PRIORITY OFF GOALTER DATABASE [Lenod] SET RECOVERY SIMPLE GOALTER DATABASE [Lenod] SET MULTI_USER GOALTER DATABASE [Lenod] SET PAGE_VERIFY CHECKSUM GOALTER DATABASE [Lenod] SET DB_CHAINING OFF GOUSE [Lenod]GO/****** Object: StoredProcedure [dbo].[generateSP] Script Date: 5/9/2013 4:41:43 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROC [dbo].[generateSP] @DatabaseName varchar(100) = 'Sentinel_Data' , @tableName varchar(100) , @PrintOrExecute varchar(50) = 'Execute'As-- Do we want to generate the SP definitions for every user defined-- table in the database or just a single specified table?-- Assign a blank string - '' for all tables or the table name for-- a single table.DECLARE @GenerateProcsFor varchar(100)SET @GenerateProcsFor = @tableName--SET @GenerateProcsFor = ''-- do we want the script to print out the CREATE PROC statements-- or do we want to execute them to actually create the procs?-- Assign a value of either 'Print' or 'Execute'SET @PrintOrExecute = @PrintOrExecute-- Is there a table name prefix i.e. 'tbl_' which we don't want-- to include in our stored proc names?DECLARE @TablePrefix varchar(10)SET @TablePrefix = 'tbl_'-- For our '_lst' and '_sel' procedures do we want to -- do SELECT * or SELECT [ColumnName,]...-- Assign a value of either 1 or 0DECLARE @UseSelectWildCard bitSET @UseSelectWildCard = 0-- ##########################################################/* END SETTING OF CONFIG VARIABLE -- do not edit below this line */-- ##########################################################-- DECLARE CURSOR containing all columns from user defined tables-- in the databaseDECLARE TableCol Cursor FOR SELECT c.TABLE_SCHEMA, c.TABLE_NAME, c.COLUMN_NAME, c.DATA_TYPE, c.CHARACTER_MAXIMUM_LENGTHFROM INFORMATION_SCHEMA.Columns c INNER JOIN INFORMATION_SCHEMA.Tables t ON c.TABLE_NAME = t.TABLE_NAMEWHERE t.Table_Catalog = @DatabaseName AND t.TABLE_TYPE = 'BASE TABLE'ORDER BY c.TABLE_NAME, c.ORDINAL_POSITION-- Declare variables which will hold values from cursor rowsDECLARE @TableSchema varchar(100)DECLARE @ColumnName varchar(100), @DataType varchar(30)DECLARE @CharLength intDECLARE @ColumnNameCleaned varchar(100)-- Declare variables which will track what table we are-- creating Stored Procs forDECLARE @CurrentTable varchar(100)DECLARE @FirstTable bitDECLARE @FirstColumnName varchar(100)DECLARE @FirstColumnDataType varchar(30)DECLARE @ObjectName varchar(100) -- this is the tablename with the -- specified tableprefix lopped off.DECLARE @TablePrefixLength int-- init varsSET @CurrentTable = ''SET @FirstTable = 1SET @TablePrefixLength = Len(@TablePrefix)-- Declare variables which will hold the queries we are building use unicode-- data types so that can execute using sp_ExecuteSQLDECLARE @LIST nvarchar(4000), @UPSERT nvarchar(4000)DECLARE @SELECT nvarchar(4000), @INSERT nvarchar(4000), @INSERTVALUES varchar(4000)DECLARE @UPDATE nvarchar(4000), @DELETE nvarchar(4000)-- open the cursorOPEN TableCol-- get the first row of cursor into variablesFETCH NEXT FROM TableCol INTO @TableSchema, @TableName, @ColumnName, @DataType, @CharLength-- loop through the rows of the cursorWHILE @@FETCH_STATUS = 0 BEGIN SET @ColumnNameCleaned = Replace(@ColumnName, ' ', '') -- is this a new table? IF @TableName <> @CurrentTable BEGIN -- if is the end of the last table IF @CurrentTable <> '' BEGIN IF @GenerateProcsFor = '' OR @GenerateProcsFor = @CurrentTable BEGIN -- first add any syntax to end the statement -- _lst SET @LIST = @List + Char(13) + 'FROM ' + @CurrentTable + Char(13) SET @LIST = @LIST + Char(13) + Char(13) + 'SET NOCOUNT OFF' + Char(13) + Char(13) SET @LIST = @LIST + Char(13) -- _sel SET @SELECT = @SELECT + Char(13) + 'FROM ' + @CurrentTable + Char(13) SET @SELECT = @SELECT + 'WHERE [' + @FirstColumnName + '] = @' + Replace(@FirstColumnName, ' ', '') + Char(13) SET @SELECT = @SELECT + Char(13) + Char(13) + 'SET NOCOUNT OFF' + Char(13) + Char(13) SET @SELECT = @SELECT + Char(13) -- UPDATE (remove trailing comma and append the WHERE clause) SET @UPDATE = SUBSTRING(@UPDATE, 0, LEN(@UPDATE)- 1) + Char(13) + Char(9) + 'WHERE [' + @FirstColumnName + '] = @' + Replace(@FirstColumnName, ' ', '') + Char(13) -- INSERT SET @INSERT = SUBSTRING(@INSERT, 0, LEN(@INSERT) - 1) + Char(13) + Char(9) + ')' + Char(13) SET @INSERTVALUES = SUBSTRING(@INSERTVALUES, 0, LEN(@INSERTVALUES) -1) + Char(13) + Char(9) + ')' SET @INSERT = @INSERT + @INSERTVALUES -- _ups SET @UPSERT = @UPSERT + Char(13) + 'AS' + Char(13) SET @UPSERT = @UPSERT + 'SET NOCOUNT ON' + Char(13) IF @FirstColumnDataType IN ('int', 'bigint', 'smallint', 'tinyint', 'float', 'decimal') BEGIN SET @UPSERT = @UPSERT + 'IF @' + Replace(@FirstColumnName, ' ', '') + ' = 0 BEGIN' + Char(13) END ELSE BEGIN SET @UPSERT = @UPSERT + 'IF @' + Replace(@FirstColumnName, ' ', '') + ' = '''' BEGIN' + Char(13) END SET @UPSERT = @UPSERT + ISNULL(@INSERT, '') + Char(13) SET @UPSERT = @UPSERT + Char(9) + 'SELECT * from ' + @CurrentTable + ' WHERE [' + @FirstColumnName + '] = scope_identity() ' + Char(13) SET @UPSERT = @UPSERT + 'END' + Char(13) SET @UPSERT = @UPSERT + 'ELSE BEGIN' + Char(13) SET @UPSERT = @UPSERT + ISNULL(@UPDATE, '') + Char(13) SET @UPSERT = @UPSERT + 'END' + Char(13) + Char(13) SET @UPSERT = @UPSERT + 'SET NOCOUNT OFF' + Char(13) + Char(13) SET @UPSERT = @UPSERT + Char(13) -- _del -- delete proc completed already -- -------------------------------------------------- -- now either print the SP definitions or -- execute the statements to create the procs -- -------------------------------------------------- IF @PrintOrExecute <> 'Execute' BEGIN -- PRINT @LIST -- PRINT @SELECT PRINT @UPSERT PRINT @DELETE END ELSE BEGIN -- EXEC sp_Executesql @LIST -- EXEC sp_Executesql @SELECT EXEC sp_Executesql @UPSERT EXEC sp_Executesql @DELETE END END -- end @GenerateProcsFor = '' OR @GenerateProcsFor = @CurrentTable END -- update the value held in @CurrentTable SET @CurrentTable = @TableName SET @FirstColumnName = @ColumnName SET @FirstColumnDataType = @DataType IF @TablePrefixLength > 0 BEGIN IF SUBSTRING(@CurrentTable, 1, @TablePrefixLength) = @TablePrefix BEGIN --PRINT Char(13) + 'DEBUG: OBJ NAME: ' + RIGHT(@CurrentTable, LEN(@CurrentTable) - @TablePrefixLength) SET @ObjectName = RIGHT(@CurrentTable, LEN(@CurrentTable) - @TablePrefixLength) END ELSE BEGIN SET @ObjectName = @CurrentTable END END ELSE BEGIN SET @ObjectName = @CurrentTable END IF @GenerateProcsFor = '' OR @GenerateProcsFor = @CurrentTable BEGIN -- ---------------------------------------------------- -- now start building the procedures for the next table -- ---------------------------------------------------- -- _lst SET @LIST = 'CREATE PROC [dbo].[usp_' + @ObjectName + '_lst]' + Char(13) SET @LIST = @LIST + 'AS' + Char(13) SET @LIST = @LIST + 'SET NOCOUNT ON' + Char(13) IF @UseSelectWildcard = 1 BEGIN SET @LIST = @LIST + Char(13) + 'SELECT * ' END ELSE BEGIN SET @LIST = @LIST + Char(13) + 'SELECT [' + @ColumnName + ']' END -- _sel SET @SELECT = 'CREATE PROC [dbo].[usp_' + @ObjectName + '_sel]' + Char(13) SET @SELECT = @SELECT + Char(9) + '@' + @ColumnNameCleaned + ' ' + @DataType IF @DataType IN ('varchar', 'nvarchar', 'char', 'nchar') BEGIN SET @SELECT = @SELECT + '(' + CAST(@CharLength As varchar(10)) + ')' END SET @SELECT = @SELECT + Char(13) + 'AS' + Char(13) SET @SELECT = @SELECT + 'SET NOCOUNT ON' + Char(13) IF @UseSelectWildcard = 1 BEGIN SET @SELECT = @SELECT + Char(13) + 'SELECT * ' END ELSE BEGIN SET @SELECT = @SELECT + Char(13) + 'SELECT [' + @ColumnName + ']' END -- _ups SET @UPSERT = 'CREATE PROC [dbo].[usp_' + @ObjectName + '_ups]' + Char(13) SET @UPSERT = @UPSERT + Char(13) + Char(9) + '@' + @ColumnNameCleaned + ' ' + @DataType IF @DataType IN ('varchar', 'nvarchar', 'char', 'nchar') BEGIN SET @UPSERT = @UPSERT + '(' + CAST(@CharLength As Varchar(10)) + ')' END -- UPDATE SET @UPDATE = Char(9) + 'UPDATE [' + @TableName + '] SET ' + Char(13) -- INSERT -- don't add first column to insert if it is an -- integer (assume autonumber) SET @INSERT = Char(9) + 'INSERT INTO [' + @TableName + '] (' + Char(13) SET @INSERTVALUES = Char(9) + 'VALUES (' + Char(13) IF @FirstColumnDataType NOT IN ('int', 'bigint', 'smallint', 'tinyint') BEGIN SET @INSERT = @INSERT + Char(9) + Char(9) + '[' + @ColumnName + '],' + Char(13) SET @INSERTVALUES = @INSERTVALUES + Char(9) + Char(9) + '@' + @ColumnNameCleaned + ',' + Char(13) END -- _del SET @DELETE = 'CREATE PROC [dbo].[usp_' + @ObjectName + '_del]' + Char(13) SET @DELETE = @DELETE + Char(9) + '@' + @ColumnNameCleaned + ' ' + @DataType IF @DataType IN ('varchar', 'nvarchar', 'char', 'nchar') BEGIN SET @DELETE = @DELETE + '(' + CAST(@CharLength As Varchar(10)) + ')' END SET @DELETE = @DELETE + Char(13) + 'AS' + Char(13) SET @DELETE = @DELETE + 'SET NOCOUNT ON' + Char(13) + Char(13) SET @DELETE = @DELETE + 'DELETE FROM [' + @TableName + ']' + Char(13) SET @DELETE = @DELETE + 'WHERE [' + @ColumnName + '] = @' + @ColumnNameCleaned + Char(13) SET @DELETE = @DELETE + Char(13) + 'SET NOCOUNT OFF' + Char(13) SET @DELETE = @DELETE + Char(13) END -- end @GenerateProcsFor = '' OR @GenerateProcsFor = @CurrentTable END ELSE BEGIN IF @GenerateProcsFor = '' OR @GenerateProcsFor = @CurrentTable BEGIN -- is the same table as the last row of the cursor -- just append the column -- _lst IF @UseSelectWildCard = 0 BEGIN SET @LIST = @LIST + ', ' + Char(13) + Char(9) + '[' + @ColumnName + ']' END -- _sel IF @UseSelectWildCard = 0 BEGIN SET @SELECT = @SELECT + ', ' + Char(13) + Char(9) + '[' + @ColumnName + ']' END -- _ups SET @UPSERT = @UPSERT + ',' + Char(13) + Char(9) + '@' + @ColumnNameCleaned + ' ' + @DataType IF @DataType IN ('varchar', 'nvarchar', 'char', 'nchar') BEGIN SET @UPSERT = @UPSERT + '(' + CAST(@CharLength As varchar(10)) + ')' END -- UPDATE SET @UPDATE = @UPDATE + Char(9) + Char(9) + '[' + @ColumnName + '] = @' + @ColumnNameCleaned + ',' + Char(13) -- INSERT SET @INSERT = @INSERT + Char(9) + Char(9) + '[' + @ColumnName + '],' + Char(13) SET @INSERTVALUES = @INSERTVALUES + Char(9) + Char(9) + '@' + @ColumnNameCleaned + ',' + Char(13) -- _del -- delete proc completed already END -- end @GenerateProcsFor = '' OR @GenerateProcsFor = @CurrentTable' END -- fetch next row of cursor into variables FETCH NEXT FROM TableCol INTO @TableSchema, @TableName, @ColumnName, @DataType, @CharLengthEND-- ------------------ clean up cursor-- ----------------CLOSE TableColDEALLOCATE TableCol-- -------------------------------------------------- repeat the block of code from within the cursor-- So that the last table has its procs completed-- and printed / executed-- -------------------------------------------------- if is the end of the last tableIF @CurrentTable <> '' BEGIN IF @GenerateProcsFor = '' OR @GenerateProcsFor = @CurrentTable BEGIN -- first add any syntax to end the statement -- _lst SET @LIST = @List + Char(13) + 'FROM ' + @CurrentTable + Char(13) SET @LIST = @LIST + Char(13) + Char(13) + 'SET NOCOUNT OFF' + Char(13) SET @LIST = @LIST + Char(13) -- _sel SET @SELECT = @SELECT + Char(13) + 'FROM ' + @CurrentTable + Char(13) SET @SELECT = @SELECT + 'WHERE [' + @FirstColumnName + '] = @' + Replace(@FirstColumnName, ' ', '') + Char(13) SET @SELECT = @SELECT + Char(13) + Char(13) + 'SET NOCOUNT OFF' + Char(13) SET @SELECT = @SELECT + Char(13) -- UPDATE (remove trailing comma and append the WHERE clause) SET @UPDATE = SUBSTRING(@UPDATE, 0, LEN(@UPDATE)- 1) + Char(13) + Char(9) + 'WHERE [' + @FirstColumnName + '] = @' + Replace(@FirstColumnName, ' ', '') + Char(13) -- INSERT SET @INSERT = SUBSTRING(@INSERT, 0, LEN(@INSERT) - 1) + Char(13) + Char(9) + ')' + Char(13) SET @INSERTVALUES = SUBSTRING(@INSERTVALUES, 0, LEN(@INSERTVALUES) -1) + Char(13) + Char(9) + ')' SET @INSERT = @INSERT + @INSERTVALUES -- _ups SET @UPSERT = @UPSERT + Char(13) + 'AS' + Char(13) SET @UPSERT = @UPSERT + 'SET NOCOUNT ON' + Char(13) IF @FirstColumnDataType IN ('int', 'bigint', 'smallint', 'tinyint', 'float', 'decimal') BEGIN SET @UPSERT = @UPSERT + 'IF @' + Replace(@FirstColumnName, ' ', '') + ' = 0 BEGIN' + Char(13) END ELSE BEGIN SET @UPSERT = @UPSERT + 'IF @' + Replace(@FirstColumnName, ' ', '') + ' = '''' BEGIN' + Char(13) END SET @UPSERT = @UPSERT + ISNULL(@INSERT, '') + Char(13) SET @UPSERT = @UPSERT + Char(9) + 'SELECT SCOPE_IDENTITY() As InsertedID' + Char(13) SET @UPSERT = @UPSERT + 'END' + Char(13) SET @UPSERT = @UPSERT + 'ELSE BEGIN' + Char(13) SET @UPSERT = @UPSERT + ISNULL(@UPDATE, '') + Char(13) SET @UPSERT = @UPSERT + 'END' + Char(13) + Char(13) SET @UPSERT = @UPSERT + 'SET NOCOUNT OFF' + Char(13) SET @UPSERT = @UPSERT + Char(13) -- _del -- delete proc completed already -- -------------------------------------------------- -- now either print the SP definitions or -- execute the statements to create the procs -- -------------------------------------------------- IF @PrintOrExecute <> 'Execute' BEGIN PRINT @LIST PRINT @SELECT PRINT @UPSERT PRINT @DELETE END ELSE BEGIN EXEC sp_Executesql @LIST EXEC sp_Executesql @SELECT EXEC sp_Executesql @UPSERT EXEC sp_Executesql @DELETE END END -- end @GenerateProcsFor = '' OR @GenerateProcsFor = @CurrentTableENDGO/****** Object: StoredProcedure [dbo].[usp_TableToClass] Script Date: 5/9/2013 4:41:43 PM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROCEDURE [dbo].[usp_TableToClass]@table_name SYSNAME--,@nameSpace nvarchar(30)ASSET NOCOUNT ONdeclare @nameSpace nvarchar(100)set @nameSpace = '';if @nameSpace = '' BEGIN RAISERROR (N'You have to hard code the name space in the stored procedure.', 10, 1, NULL, NULL) ENDELSE BEGIN DECLARE @temp TABLE ( sort INT, code TEXT ) INSERT INTO @temp SELECT -10, 'using System;' + CHAR(13) + CHAR(10) INSERT INTO @temp SELECT -9, 'using System.Collections.Generic;' + CHAR(13) + CHAR(10) INSERT INTO @temp SELECT -8, 'using System.Text;' ++ CHAR(13) + CHAR(10) INSERT INTO @temp SELECT -7, 'using System.Data.SqlClient;' + CHAR(13) + CHAR(10) INSERT INTO @temp SELECT -6, 'using System.Data.Common;' + CHAR(13) + CHAR(10) INSERT INTO @temp SELECT -5, CHAR(13) + CHAR(10) INSERT INTO @temp SELECT -4, 'namespace ' + @nameSpace + ' ' + CHAR(13) + CHAR(10) INSERT INTO @temp SELECT -3, '{' + CHAR(13) + CHAR(10) INSERT INTO @temp SELECT 1, 'public class ' + @table_name + CHAR(13) + CHAR(10) + '{' INSERT INTO @temp SELECT 2, CHAR(13) + CHAR(10) + '#region Constructors' + CHAR(13) + CHAR(10) INSERT INTO @temp SELECT 3, CHAR(9) + 'public ' + @table_name + '()' + CHAR(13) + CHAR(10) + CHAR(9) + '{' + CHAR(13) + CHAR(10) + CHAR(9) + '}' INSERT INTO @temp SELECT 4, '

No comments:

Post a Comment

Search This Blog