April 16, 2010 at 11:59 pm
I have a function that returns me values passed in comma separated string in table format.
select sectionnumeric from dbo.CreateSectionTableFromString('placementcandidatelanguageproficiency,placementcandidatetrainingsinternshipsprojects')
This will return values as:
placementcandidatelanguageproficiency
placementcandidatetrainingsinternshipsprojects
These two values returned are tablenames
I want to fire the delete statement from these tables now.
Please help in writing the query
April 17, 2010 at 1:26 am
Is your expected output
DELETE FROM placementcandidatelanguageproficiency
DELETE FROM placementcandidatetrainingsinternshipsprojects
If it is so, then you can create the script using Dynamic SQL
DECLARE@strSQL VARCHAR(MAX)
SELECT@strSQL = COALESCE( @strSQL + CHAR(10), '' )
+ ' DELETE FROM ' + sectionnumeric
FROMdbo.CreateSectionTableFromString('placementcandidatelanguageproficiency,placementcandidatetrainingsinternshipsprojects')
PRINT( @strSQL )
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
April 17, 2010 at 1:55 am
This is not working. Stored prcoedure is returning the query as :
DELETE FROM sectionnumeric
FROM dbo.CreateSectionTableFromString(placementcandidatelanguageproficiency,placementcandidatetrainingsinternshipsprojects,placementcandidatequalificationdetails)
This query is giving lot of errors. I think some syntax mistake is there
April 17, 2010 at 4:42 am
gaurav-404321 (4/17/2010)
This is not working. Stored prcoedure is returning the query as :DELETE FROM sectionnumeric
FROM dbo.CreateSectionTableFromString(placementcandidatelanguageproficiency,placementcandidatetrainingsinternshipsprojects,placementcandidatequalificationdetails)
This query is giving lot of errors. I think some syntax mistake is there
Something like this :
DECLARE @SQL VARCHAR(MAX)
SELECT@SQL = ''
SELECT @SQL = @SQL + ' DELETE FROM ' + SectionNumeric + CHAR(13)
FROM dbo.CreateSectionTableFromString('placementcandidatelanguageproficiency,placementcandidatetrainingsinternshipsprojects,placementcandidatequalificationdetails')
PRINT ( @SQL )
--OR
EXECUTE ( @SQL )
Vaibhav K Tiwari
To walk fast walk alone
To walk far walk together
April 17, 2010 at 12:35 pm
gaurav-404321 (4/17/2010)
This is not working. Stored prcoedure is returning the query as :DELETE FROM sectionnumeric
FROM dbo.CreateSectionTableFromString(placementcandidatelanguageproficiency,placementcandidatetrainingsinternshipsprojects,placementcandidatequalificationdetails)
This query is giving lot of errors. I think some syntax mistake is there
Can you give us the expected output. That would be helpful for us to understand what you need.
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
April 18, 2010 at 8:25 pm
Better still, explain what you are seeking to achieve as a whole - there is almost certainly a better design.
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply