Home Forums SQL Server 2008 T-SQL (SS2K8) Need to pull the data out of a row and into a comma separated string referencing the columnID RE: Need to pull the data out of a row and into a comma separated string referencing the columnID

  • Here is the output form the process that is needed:

    INSERT [dbo].[Address] ([ID], [Address1], [Address2], [City], [State], [ZipCode], [AddressTypeID], [IsPrimary], [CountryId], [Address_no_old]) VALUES (4, N'52123 Go Street', N'', N'Othertown', N'CA', N'92610', 73, 1, 741, NULL)

    Where the function that creates this is the core of what I have not been able to convey

    The catch is that the function needs to work for all tables in the database.

    It is easy to get the Insert column list, data is the problem

    Here is how they want to call ....

    Table Key Key

    Name Column Value

    called by exec [dbo].GenerateSingleInsert 'dbo.CLPower', 'CLPowerId', 100

    These values are used in the where clause