Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 CSV VALUES

Author  Topic 

faijurrahuman
Starting Member

15 Posts

Posted - 2012-03-14 : 10:19:45
Dear all;


DECLARE @id INT
DECLARE @type INT
DECLARE @name VARCHAR(max)
DECLARE @tables VARCHAR(max)
DECLARE @physical NVARCHAR(max)

--CREATE TABLE #tmp (id INT IDENTITY(1,1),physical_name VARCHAR(max))

--DROP TABLE #tmp
DECLARE tmp CURSOR FOR
SELECT id,type,name,tables FROM dbo.dynamic_update_pages
OPEN tmp
FETCH NEXT FROM tmp INTO @id,@type,@name,@tables
WHILE @@FETCH_STATUS = 0
BEGIN
--INSERT INTO #tmp
SELECT DISTINCT D.name,t.physical_name
FROM dbo.Split2(@tables, ',') A
JOIN tables t ON t.id=A.id
JOIN dynamic_update_pages d ON d.name=@name
FETCH NEXT FROM tmp INTO @id,@type,@name,@tables
END
CLOSE tmp
DEALLOCATE tmp


OUTPUT

View Art Work artwork
View Art Work print_ads

Expected Output
View Art Work artwork,print_ads

I want the csv values for t.physical_name any ony help the issue

Thanks

Share Knowledge team

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-14 : 10:26:45
Please give
table structure
sample data
wanted result


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

faijurrahuman
Starting Member

15 Posts

Posted - 2012-03-14 : 10:38:57
Hi

This is my table(dynamic)
id type dynamic_name dynamic_table_id
2 2 View Art Work 1072,1310
3 2 Update Art Work 1072
4 2 View Module 1090

Here i want compare these table_id in tables table

Tables table structure

table_id table_name
1072 Print Ads
1090 Modules
1310 Print Adss

I want compare to this tables table table_id and dynamic table table_id and to select the table_name in tables table.

dynamic_name , dynamic_table_id , table_name
View Art Work 1072,1310 Print Ads,Print Adss
Update Art Work 1072 Print Ads
View Module 1090 Modules



This is expected output.


Share Knowledge team
Go to Top of Page
   

- Advertisement -