February 25, 2009 at 7:27 am
Comments posted to this topic are about the item Script all data of a table
June 17, 2009 at 11:07 pm
Nice script there, I too had written a similar script
http://www.sqlservercentral.com/scripts/insert+script+generator/65407/
but the bad thing about mine would be the fact that I had made use of cursors....and also since it was written for sql server 2000 it has its limitation when tried in 2005.....
July 10, 2009 at 11:36 am
When I used it, there was an Error if the @column_names = 0. The word VALUES would concatenate at the end of the table name without a space(i.e. INSERT INTO dbo.FolderLevelLookupVALUES (0, 'None')
) . I just added a space before the word VALUES to fix it in the script.
...
PRINT ' '' VALUES ('' +'
...
Great script. Thanks
David Petersen
dipetersen.com
July 11, 2009 at 5:07 am
Linson.Daniel (6/17/2009)
Nice script there, I too had written a similar scripthttp://www.sqlservercentral.com/scripts/insert+script+generator/65407/
but the bad thing about mine would be the fact that I had made use of cursors....and also since it was written for sql server 2000 it has its limitation when tried in 2005.....
Hi Daniel
Sorry for the very late answer!! Seems I lost the response mail...
Just had a look at your script, maybe you should include QUOTENAME or REPLACE to avoid SQL injection by "'". For smaller tables cursors should be okay.
July 11, 2009 at 5:10 am
dipetersen (7/10/2009)
When I used it, there was an Error if the @column_names = 0. The word VALUES would concatenate at the end of the table name without a space(i.e. INSERT INTO dbo.FolderLevelLookupVALUES (0, 'None')) . I just added a space before the word VALUES to fix it in the script.
...
PRINT ' '' VALUES ('' +'
...
Great script. Thanks
Thanks for the feedback! 🙂
Thanks also for the bug report, I will fix this. Usually it takes some days until it becomes updated by admins.
August 10, 2009 at 5:30 am
Hi,
Excellent Script.
I m not sure whether you have updated it or not.
But it gives error in some cases where datatype is used as DbStamp of in case of Datetime.
Thanks,
Chirag.
August 26, 2009 at 2:12 am
Hi Craig
Chirag Prajapati (8/10/2009)
But it gives error in some cases where datatype is used as DbStamp of in case of Datetime.
Thanks for the feedback!
Could you explain the error and how it happens? What do you mean with DbStamp?
Greets
Flo
August 27, 2009 at 3:51 pm
Hi,
Love the script.
I had a small problem when I tried running it due to the collation being wrong. I was getting the error
Cannot resolve collation conflict for column 1 in SELECT statement.
To fix this I changed the following at the end of the script
-- Script the end of the statement
PRINT ' '') COLLATE Latin1_General_CI_AS'''
PRINT ' FROM ' + @table_name
This then worked a treat.
Thanks again
October 12, 2009 at 2:56 pm
Nice post.
Here's a script to just update data in a particular column in a table
select
'update @tablename set @columnname = ',
'''' + @columnname + '''',
'where @primarykeycolumn = ',
@primarykeycolumn
from @tablename
It generates a script which when run, updates that particular column in that table.
October 22, 2009 at 10:48 pm
I missed this before, Flo... it's written well enough that it probably should have been an article. Well done.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 26, 2009 at 2:57 am
Thanks, Jeff!
I intend to update the script to add some missing data types like HIERARCHYID, UDTs, GEOMETRY and GEOGRAPHY.
Wish you best!
Flo
PS: Sorry for being out of the forums since a long time. I'm quiet busy with new projects. I'll be back as soon as possible!
November 6, 2009 at 6:15 am
Hi,
I tried this on SQL Server 2000 but getting error on VARCHAR(MAX) line.
Will it not work on SQL Server 2000?
Thanks,
Vivek
November 6, 2009 at 6:22 am
Hi Vivek
The script was made for SQL Server 2005. However, if you change VARCHAR(MAX) to VARCHAR(8000) it might work, if your tables are not too wide.
In addition change:
SELECT @object_id = object_id, @schema_id = schema_id
FROM sys.tables
WHERE object_id = OBJECT_ID(@table_name)
... to something like this:
SELECT @object_id = id, @schema_id = schema_id
FROM systables
WHERE id = OBJECT_ID(@table_name)
Unfortunately I cannot test it on 2000 at the moment.
Hope this helps
Flo
November 7, 2009 at 3:21 am
Hi Florian,
Still getting few errors -
WHERE TABLE_SCHEMA = SCHEMA_NAME(@schema_id)
'SCHEMA_NAME' is not a recognized function name.
DECLARE @select VARCHAR(MAX)
Line 82: Incorrect syntax near 'MAX'.
Please suggest on this.
Thanks,
Vivek
November 7, 2009 at 4:18 am
Hi Florian,
Resolve the issue replacing -
DECLARE @select VARCHAR(MAX)
With
DECLARE @select VARCHAR(8000)
&
changing this query
SELECT @object_id = object_id, @schema_id = schema_id
FROM sys.tables
WHERE object_id = OBJECT_ID(@table_name)
to
SELECT @object_id = id, @schema_id = schema_id
FROM sysobjects
WHERE id = OBJECT_ID(@table_name) and type = 'U'
But still getting error at schema_id
Please help on this.
Thanks
Vivek
Viewing 15 posts - 1 through 15 (of 37 total)
You must be logged in to reply to this topic. Login to reply