Click here to Skip to main content
15,885,658 members

Comments by Member 9831003 (Top 5 by date)

Member 9831003 30-Mar-17 7:36am View    
could you please provide table structure with some sample data
Member 9831003 13-Dec-16 4:14am View    
you can try below code.

DECLARE @Inserttbl nvarchar(4000)
DECLARE @TableName varchar(50)
DECLARE @Text varchar(50)
--DECLARE @count int
SET @TableName = 'test'
SET @Text = NULL

if (@Text is not null)
begin
SET @Inserttbl = ' Insert into dbo.' + @TableName + ' values (3,' +''''+@Text+'''' + ',1)'

EXEC sp_executesql @Inserttbl
end
else
begin
Print 'NULL Value will not inserted'
end

And yes there is possibility of sql injection even under sp_executesql. Check below link also for validating your parameter
https://msdn.microsoft.com/en-us/library/ms161953(SQL.105).aspx
Member 9831003 12-Dec-16 4:07am View    
try with xml data type. Check below link may be help full
http://stackoverflow.com/questions/2497678/storing-json-in-an-mssql-database
Member 9831003 8-Nov-16 4:05am View    
Thanks, if possible can you please make some insert statement for these tables.
Member 9831003 4-Nov-16 9:25am View    
Send your table schema with sample data