Dear gurus,
select 'insert into cargafrecuencias([id],tipo,horas) values(' +
convert(char(2),[id]) + ',
''' + rtrim(ltrim(tipo)) + ''',
' + convert(char(5), horas) + ')'
from cargafrecuencias
That query returns fine INSERTS and ready for be executed:
insert into cargafrecuencias([id],tipo,horas) values(1 , 'Semanal',
168 )
insert into cargafrecuencias([id],tipo,horas) values(2 , 'Mensual',
720 )
insert into cargafrecuencias([id],tipo,horas) values(3 , 'Diaria',
24 )
insert into cargafrecuencias([id],tipo,horas) values(4 , 'Cuando llegue
el fichero', 8640 )
It's easy and useful without a doubt. But can you imagine do the same with a
table with 80 columns?
I would like do something like that (it would be gorgeous):
select 'insert into table(f1,f2,f3... fn) values (sp_help table)'
from table
On the other hand is very annonying.
Does anyone have any ideas or thoughts?
Thanks in advance and regards,CREATE PROCEDURE SPInserttest
(
@.Test varchar(50)
)
AS
BEGIN
PRINT 'Do something with the test varchar(50)'
Select 'Jens'
UNION
SELECT 'BOB'
END
CREATE TABLE #Tabname
(
Names varchar(50)
)
INSERT INTo #Tabname
EXEC('SPInserttest ''Test''')
Select * from #Tabname
DROP Procedure SPInserttest
DROP Table #Tabname
--
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Enric" wrote:
> Dear gurus,
> select 'insert into cargafrecuencias([id],tipo,horas) values(' +
> convert(char(2),[id]) + ',
> ''' + rtrim(ltrim(tipo)) + ''',
> ' + convert(char(5), horas) + ')'
> from cargafrecuencias
>
> That query returns fine INSERTS and ready for be executed:
> insert into cargafrecuencias([id],tipo,horas) values(1 , 'Semanal',
> 168 )
> insert into cargafrecuencias([id],tipo,horas) values(2 , 'Mensual',
> 720 )
> insert into cargafrecuencias([id],tipo,horas) values(3 , 'Diaria',
> 24 )
> insert into cargafrecuencias([id],tipo,horas) values(4 , 'Cuando llegue
> el fichero', 8640 )
>
> It's easy and useful without a doubt. But can you imagine do the same with
a
> table with 80 columns?
> I would like do something like that (it would be gorgeous):
> select 'insert into table(f1,f2,f3... fn) values (sp_help table)'
> from table
> On the other hand is very annonying.
> Does anyone have any ideas or thoughts?
> Thanks in advance and regards,
>|||Try this one.
http://vyaskn.tripod.com/code/generate_inserts.txt
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
"Enric" <Enric@.discussions.microsoft.com> wrote in message
news:1BD06558-758F-490C-B228-7090641DA685@.microsoft.com...
> Dear gurus,
> select 'insert into cargafrecuencias([id],tipo,horas) values(' +
> convert(char(2),[id]) + ',
> ''' + rtrim(ltrim(tipo)) + ''',
> ' + convert(char(5), horas) + ')'
> from cargafrecuencias
>
> That query returns fine INSERTS and ready for be executed:
> insert into cargafrecuencias([id],tipo,horas) values(1 , 'Semanal',
> 168 )
> insert into cargafrecuencias([id],tipo,horas) values(2 , 'Mensual',
> 720 )
> insert into cargafrecuencias([id],tipo,horas) values(3 , 'Diaria',
> 24 )
> insert into cargafrecuencias([id],tipo,horas) values(4 , 'Cuando
> llegue
> el fichero', 8640 )
>
> It's easy and useful without a doubt. But can you imagine do the same with
> a
> table with 80 columns?
> I would like do something like that (it would be gorgeous):
> select 'insert into table(f1,f2,f3... fn) values (sp_help table)'
> from table
> On the other hand is very annonying.
> Does anyone have any ideas or thoughts?
> Thanks in advance and regards,
>|||Great, thanks a lot, it works very well
"Roji. P. Thomas" wrote:
> Try this one.
> http://vyaskn.tripod.com/code/generate_inserts.txt
>
> --
> Roji. P. Thomas
> Net Asset Management
> http://toponewithties.blogspot.com
>
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:1BD06558-758F-490C-B228-7090641DA685@.microsoft.com...
>
>|||XXXXing life. That doesn't works with my table, it is too large in terms of
columns.
"Roji. P. Thomas" wrote:
> Try this one.
> http://vyaskn.tripod.com/code/generate_inserts.txt
>
> --
> Roji. P. Thomas
> Net Asset Management
> http://toponewithties.blogspot.com
>
> "Enric" <Enric@.discussions.microsoft.com> wrote in message
> news:1BD06558-758F-490C-B228-7090641DA685@.microsoft.com...
>
>
Showing posts with label gurus. Show all posts
Showing posts with label gurus. Show all posts
Friday, February 24, 2012
Sunday, February 12, 2012
Auto increment data field
Hi gurus,
Does anyone know how to reset the counter of an auto increment field without
deleting the table?
Thanx in advance..
Boristry
dbbc checkident with the reseed option... It is doc'd in books on line.
--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Boris Condarco" <bcondarco@.hotmail.com> wrote in message
news:uiGBrAU0DHA.2360@.TK2MSFTNGP10.phx.gbl...
> Hi gurus,
> Does anyone know how to reset the counter of an auto increment field
without
> deleting the table?
> Thanx in advance..
> Boris
>|||If there is no data to keep, TRUNCATE TABLE tablename
"Boris Condarco" <bcondarco@.hotmail.com> wrote in message
news:uiGBrAU0DHA.2360@.TK2MSFTNGP10.phx.gbl...
> Hi gurus,
> Does anyone know how to reset the counter of an auto increment field
without
> deleting the table?
> Thanx in advance..
> Boris
>|||DBCC CHECKIDENT (TestTable, RESEED, 1)
Rohtash Kapoor
http://www.sqlmantra.com
"Boris Condarco" <bcondarco@.hotmail.com> wrote in message
news:uiGBrAU0DHA.2360@.TK2MSFTNGP10.phx.gbl...
> Hi gurus,
> Does anyone know how to reset the counter of an auto increment field
without
> deleting the table?
> Thanx in advance..
> Boris
>
Does anyone know how to reset the counter of an auto increment field without
deleting the table?
Thanx in advance..
Boristry
dbbc checkident with the reseed option... It is doc'd in books on line.
--
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Boris Condarco" <bcondarco@.hotmail.com> wrote in message
news:uiGBrAU0DHA.2360@.TK2MSFTNGP10.phx.gbl...
> Hi gurus,
> Does anyone know how to reset the counter of an auto increment field
without
> deleting the table?
> Thanx in advance..
> Boris
>|||If there is no data to keep, TRUNCATE TABLE tablename
"Boris Condarco" <bcondarco@.hotmail.com> wrote in message
news:uiGBrAU0DHA.2360@.TK2MSFTNGP10.phx.gbl...
> Hi gurus,
> Does anyone know how to reset the counter of an auto increment field
without
> deleting the table?
> Thanx in advance..
> Boris
>|||DBCC CHECKIDENT (TestTable, RESEED, 1)
Rohtash Kapoor
http://www.sqlmantra.com
"Boris Condarco" <bcondarco@.hotmail.com> wrote in message
news:uiGBrAU0DHA.2360@.TK2MSFTNGP10.phx.gbl...
> Hi gurus,
> Does anyone know how to reset the counter of an auto increment field
without
> deleting the table?
> Thanx in advance..
> Boris
>
Subscribe to:
Posts (Atom)