Showing posts with label populate. Show all posts
Showing posts with label populate. Show all posts

Monday, February 13, 2012

Auto populating the fields box.

After I hook up a datasource with a stored procedure, I
run the query and expect the fields box to populate with
the retun query columns. This does not happen. Are there
certain conditions that the query has to meet for SQL RS
to do this, for example, does the query have to return a
permanent table?
Thanks,Yes.
For your query, in order to update the fields list, you will need to click
on the "Refresh Fields" button in the Data Set toolbar in Data View.
The report designer has two methods available to update the fields list.
1. Automatic (fast, low-cost): The Schema is queried by calling
IDbCommand.ExecuteReader(SchemaOnly), which returns schema information
without executing the query (parameter values are not needed). This method
is automatically invoked when you switch from Data to Layout View. It is
fast because the query doesn't have to be executed. However, there are
queries whose schemas can only be discovered by running the query. The
queries which don't return a schema include stored procedures that either
use dynamic SQL or use temporary tables. Most SQL command text and stored
procedure calls with a fixed schema work fine here.
2. Manual (slow, higher-cost): The schema is queried by calling
IDbCommand.ExecuteReader(SingleResult), which executes the query returning
the 1st row and also schema information. This method is invoked when you
click on the "Refresh Fields" button in the Data View (query designer). For
stored procedures, this method requires asking the user for sample parameter
values and then running the query with those values.
--
Jerry Povse
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"stevec" <anonymous@.discussions.microsoft.com> wrote in message
news:27dae01c4635a$b1d41810$a301280a@.phx.gbl...
> After I hook up a datasource with a stored procedure, I
> run the query and expect the fields box to populate with
> the retun query columns. This does not happen. Are there
> certain conditions that the query has to meet for SQL RS
> to do this, for example, does the query have to return a
> permanent table?
> Thanks,

Sunday, February 12, 2012

Auto Increment on a Filed in a Table

I have a table with two primary key fileds. I will be running a process to populate the data into the table.For each process the first field is constant and second field is auto increment one.

My statements are insert into select ** from ** type one.

How do I auto increment second filed per run. Any delivered function available or any suggestion Pl.............It would help us answer you question a lot faster if you supplied DDL, sample Data, and the expected result...|||DDL:
Table1-

id: PK
lin_nbr: PK
filed1
field2

Table2-

filed1
filed2
filed3

Data:

insert into table1 (id, lin_nbr, filed1, filed2) (select 'a001', auto incr , field1,filed2 from table2 )

Result in table2 should be

a001 1 abc def
a001 2 ghi jkl
a001 3 xyz gfg|||Make your lin_nbr an identity column and when you insert, insert all but the lin_nbr column. SQL Server will auto-increment that column for you!

Table1-

id_col int not null,
lin_nbr int identity not null,
filed1 varchar(52) null, -- (or not null, whichever suits your purposes)
field2 varchar(52) null -- (same applies)|||I want that increament is based on the another pk. pl have a look at the data below

a001 1 abc def
a001 2 ghi jkl
a001 3 xyz gfg
a002 1 abc def
a002 2 ghi jkl
a002 3 xyz gfg

Auto increment from 1 to ......7million

Friends,
I have created a new column called ID on my table. I need
to populate it with numbers from 1 to 7 million plus. so
like 1,2,3,4,5,6,.... Increments of one. Can you please
tell me what script can do an auto increment insert into
this column? Thank you.
Mary.In EM, right click on table and table design, choose the new column and set
identity with seed =1, increament = 1. It will be auto filled with integers
starting from 1.
You can also try this:
declare @.int int
set @.int = 1
while @.int <= 7000000
begin
insert into tablename (id) values (@.int)
set @.int = @.int + 1
end
"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote in message
news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.|||I like this one.
use tempdb
go
set nocount on
create table test (col1 int, col2 int)
insert test values (0,1)
insert test values (0,5)
insert test values (0,5)
insert test values (0,5)
insert test values (0,5)
insert test values (0,6)
insert test values (0,6)
insert test values (0,6)
declare @.x int
set @.x = 0
update test
set @.x = col1 = @.x + 1
select * from test
drop table test
Mary Jassy wrote:
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.|||Thank you very very much.
Imma
>--Original Message--
>In EM, right click on table and table design, choose the
new column and set
>identity with seed =1, increament = 1. It will be auto
filled with integers
>starting from 1.
>You can also try this:
>declare @.int int
>set @.int = 1
>while @.int <= 7000000
>begin
>insert into tablename (id) values (@.int)
>set @.int = @.int + 1
>end
>
>"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote
in message
>news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
>> Friends,
>> I have created a new column called ID on my table. I
need
>> to populate it with numbers from 1 to 7 million plus.
so
>> like 1,2,3,4,5,6,.... Increments of one. Can you
please
>> tell me what script can do an auto increment insert into
>> this column? Thank you.
>> Mary.
>
>.
>|||Mary,
Just curious but of what use would a table such as this be?
--
Andrew J. Kelly SQL MVP
"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote in message
news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.

Auto increment from 1 to ......7million

Friends,
I have created a new column called ID on my table. I need
to populate it with numbers from 1 to 7 million plus. so
like 1,2,3,4,5,6,.... Increments of one. Can you please
tell me what script can do an auto increment insert into
this column? Thank you.
Mary.
In EM, right click on table and table design, choose the new column and set
identity with seed =1, increament = 1. It will be auto filled with integers
starting from 1.
You can also try this:
declare @.int int
set @.int = 1
while @.int <= 7000000
begin
insert into tablename (id) values (@.int)
set @.int = @.int + 1
end
"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote in message
news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.
|||I like this one.
use tempdb
go
set nocount on
create table test (col1 int, col2 int)
insert test values (0,1)
insert test values (0,5)
insert test values (0,5)
insert test values (0,5)
insert test values (0,5)
insert test values (0,6)
insert test values (0,6)
insert test values (0,6)
declare @.x int
set @.x = 0
update test
set @.x = col1 = @.x + 1
select * from test
drop table test
Mary Jassy wrote:
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.
|||Thank you very very much.
Imma

>--Original Message--
>In EM, right click on table and table design, choose the
new column and set
>identity with seed =1, increament = 1. It will be auto
filled with integers
>starting from 1.
>You can also try this:
>declare @.int int
>set @.int = 1
>while @.int <= 7000000
>begin
>insert into tablename (id) values (@.int)
>set @.int = @.int + 1
>end
>
>"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote
in message[vbcol=seagreen]
>news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
need[vbcol=seagreen]
so[vbcol=seagreen]
please
>
>.
>
|||Mary,
Just curious but of what use would a table such as this be?
Andrew J. Kelly SQL MVP
"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote in message
news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.

Auto increment from 1 to ......7million

Friends,
I have created a new column called ID on my table. I need
to populate it with numbers from 1 to 7 million plus. so
like 1,2,3,4,5,6,.... Increments of one. Can you please
tell me what script can do an auto increment insert into
this column? Thank you.
Mary.In EM, right click on table and table design, choose the new column and set
identity with seed =1, increament = 1. It will be auto filled with integers
starting from 1.
You can also try this:
declare @.int int
set @.int = 1
while @.int <= 7000000
begin
insert into tablename (id) values (@.int)
set @.int = @.int + 1
end
"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote in message
news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.|||I like this one.
use tempdb
go
set nocount on
create table test (col1 int, col2 int)
insert test values (0,1)
insert test values (0,5)
insert test values (0,5)
insert test values (0,5)
insert test values (0,5)
insert test values (0,6)
insert test values (0,6)
insert test values (0,6)
declare @.x int
set @.x = 0
update test
set @.x = col1 = @.x + 1
select * from test
drop table test
Mary Jassy wrote:
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.|||Thank you very very much.
Imma

>--Original Message--
>In EM, right click on table and table design, choose the
new column and set
>identity with seed =1, increament = 1. It will be auto
filled with integers
>starting from 1.
>You can also try this:
>declare @.int int
>set @.int = 1
>while @.int <= 7000000
>begin
>insert into tablename (id) values (@.int)
>set @.int = @.int + 1
>end
>
>"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote
in message
>news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
need[vbcol=seagreen]
so[vbcol=seagreen]
please[vbcol=seagreen]
>
>.
>|||Mary,
Just curious but of what use would a table such as this be?
Andrew J. Kelly SQL MVP
"Mary Jassy" <anonymous@.discussions.microsoft.com> wrote in message
news:25dc01c4702c$e993b560$a301280a@.phx.gbl...
> Friends,
> I have created a new column called ID on my table. I need
> to populate it with numbers from 1 to 7 million plus. so
> like 1,2,3,4,5,6,.... Increments of one. Can you please
> tell me what script can do an auto increment insert into
> this column? Thank you.
> Mary.