Number Table Builder Question
Mar 13, 2008
Why doesSELECT
Identity(int, 0, 1) AS n
INTO Numbers
WHERE Coalesce(Scope_Identity(), 0) < 65535generate one surprise, whileCREATE TABLE dbo.Numbers
(
nINTIDENTITY(0, 1)
PRIMARY KEY CLUSTERED
)
WHILE Coalesce(Scope_Identity(), 0) <= 65535
INSERT dbo.Numbers DEFAULT VALUESgenerates a different surprise?
-PatP
View 13 Replies
ADVERTISEMENT
Oct 31, 2014
I have a query which returns number of columns using pivot ( rows into columns -- dynamic sql pivot columns). Since it is dynamic pivot, how can I bind this returned values into report builder matrix reports.
Look at this example :
First time query returns
StudentId | Col1 | Col2 | Col3
Second time query returns
StudentId | Col1 | Col2 | Col3 | Col4 | Col5 | Col6 ...
How to bind this query into report builder 3.0 reports?
View 13 Replies
View Related
Oct 1, 2015
In report builder 2.0, I cannot determine how to display the number of times a field has been filled out when a one to many relationship is involved. I get an error every time I use two aggregates.
ID, Symptom_ID
1, 111
2, NULL
3, 222
3, 333
3, 444
4, NULL
5, 666
The result should be 3 out of 5 records... Or even better displayed as a percentage of the total 60%
View 2 Replies
View Related
Feb 6, 2008
Hi,
When i select datasource in Report Builder, i am able to see all the available DataSources.
Eg: I have selected one datasource from the list and which has 3 tables(table1, table2, table3) associated to that datasource.
when i drag and drop table1 fields to report, i am not able to see the other 2 tables(table2 & table3)
Is there any property or relationship do i need to maintain?
Thanks,
SR.
View 5 Replies
View Related
Sep 24, 2007
Hi
I want to enter rows into a table having more number of columns
For example : I have one employee table having columns (name ,address,salary etc )
then, how can i enter 100 employees data at a time ?
Suppose i am having my data in .txt file (or ) in .xls
( SQL Server 2005)
View 1 Replies
View Related
Jun 6, 2006
Hi
i have a database with several tables and i want to create a Insert query. and i do this by adding the tables to a dataset and create the relations between them and now i click on the table i want to create a query for and select Add Query. and then the TableAdapter Query configuration Wizard pops-up. but the problem is that in the query builder i can add ONLY ONE table, why? i need to add more than one table in order to make my query.
This is how this problem accured: At first i had to two databases, the first database i created myself and there i had all my tables and the second database was the one that contained all the membership info(this database is the one that visual studio creates automaticly for you when u are using the membership thing ASPNETDB.MDF). so i decided to only have one database and i re-created all my tables in the aspnetdb.mfd database, that is where this problem accured, that i can add only one table in the query builder.
appreciate any help :) tnx
View 2 Replies
View Related
Jun 6, 2005
Hello,
I am receiving the following error:
Column name or number of supplied values does not match table definition
I am trying to insert values into a temp table, using values from the table I copied the structure from, like this:
SELECT TOP 1 * INTO #tbl_User_Temp FROM tbl_User
TRUNCATE TABLE #tbl_User_Temp
INSERT INTO #tbl_User_Temp EXECUTE UserPersist_GetUserByCriteria @Gender = 'Male', @Culture = 'en-GB'
The SP UserPersist_GetByCriteria does a
"SELECT * FROM tbl_User WHERE gender = @Gender AND culture = @Culture",
so why am I receiving this error when both tables have the same
structure?
The error is being reported as coming from UserPersist_GetByCriteria on the "SELECT * FROM tbl_User" line.
Thanks,
Greg.
View 2 Replies
View Related
Apr 28, 2008
need help
how to archiv table to another table with unique number for all rows once + date time (not the second only day time +minute)
i need whan i insert to the another table add 2 more fields (unique number , date_time )
this is the table 1 i select from
ID fname new_date val_holiday
----------------------------------------------------
111 aaaa 15/03/2008 1
111 aaaa 16/03/2008 1
111 aaaa 18/03/2008 1
111 aaaa 19/03/2008 1
111 aaaa 20/03/2008 1
111 aaaa 21/03/2008 1
222 bbb 02/05/2008 3
222 bbb 03/05/2008 3
222 bbb 04/05/2008 3
222 bbb 05/05/2008 3
222 bbb 06/05/2008 3
222 bbb 07/05/2008 3
222 bbb 08/05/2008 3
222 bbb 09/05/2008 3
333 ccc 03/04/2008 4
333 ccc 04/04/2008 4
this is the table 2 i insert into
----------------------------------
ID fname new_date val_holiday unique number date_time
--------------------------------------------------------------------------------------------------------------------
111 aaaa 15/03/2008 1 666 15/04/2008 17:03
111 aaaa 16/03/2008 1 666 15/04/2008 17:03
111 aaaa 18/03/2008 1
111 aaaa 19/03/2008 1 666 15/04/2008 17:03
111 aaaa 20/03/2008 1 666 15/04/2008 17:03
111 aaaa 21/03/2008 1 666 15/04/2008 17:03
222 bbb 02/05/2008 3 666 15/04/2008 17:03
222 bbb 03/05/2008 3
222 bbb 04/05/2008 3 666 15/04/2008 17:03
222 bbb 05/05/2008 3 666 15/04/2008 17:03
222 bbb 06/05/2008 3 666 15/04/2008 17:03
222 bbb 07/05/2008 3 666 15/04/2008 17:03
222 bbb 08/05/2008 3 666 15/04/2008 17:03
222 bbb 09/05/2008 3 666 15/04/2008 17:03
333 ccc 03/04/2008 4 666 15/04/2008 17:03
333 ccc 04/04/2008 4 666 15/04/2008 17:03
for evry archiv table to another table (insert) i need to get a unique number + date time (not the second only day time +minute)
next insert ......
ID fname new_date val_holiday unique number date_time
--------------------------------------------------------------------------------------------------------------------
111 aaaa 15/03/2008 1 667 15/04/2008 17:15
111 aaaa 16/03/2008 1 667 15/04/2008 17:15
111 aaaa 18/03/2008 1
111 aaaa 19/03/2008 1 667 15/04/2008 17:15
.........................
.....................................................................667 15/04/2008 17:15
next insert ......
ID fname new_date val_holiday unique number date_time
--------------------------------------------------------------------------------------------------------------------
111 aaaa 15/03/2008 1 668 15/04/2008 08:15
111 aaaa 16/03/2008 1 668 15/04/2008 08:15
111 aaaa 18/03/2008 1
111 aaaa 19/03/2008 1 668 15/04/2008 08:15
.........................
.....................................................................668 15/04/2008 08:15
TNX
View 3 Replies
View Related
Apr 9, 2007
Hi
Table name.. Emp
col- Name Salary
a 500
b 700
c 800
there must the the row no which is maintain by sql server.
So I want to retrive the row number of a given name.
How can i do this..
thanks
ASM
View 2 Replies
View Related
Jan 4, 2004
My users login from the tbl_users table.
I would like to store all information on them in this table but that amounts to quite a lot of fields (about 50) and some of these will store a lot of HTML text in them.
Is it best to split the table up for performance reasons or will it make little difference?
Thanks,
JB
View 4 Replies
View Related
Feb 2, 2006
is there a limit in number of coloumns in a table?
is there a size limit of a row?
View 2 Replies
View Related
Mar 6, 2000
I'm new to SQL Server 7. Is there a limit to the number of fields that a table can have?
View 1 Replies
View Related
Jan 11, 2006
How can I determine the number of columns in a table?
View 3 Replies
View Related
Mar 29, 2005
This script is for an in-line table function, F_TABLE_NUMBER_RANGE, that generates a number table. The input parameters are the @START_NUMBER and @END_NUMBER. It returns a sorted result set containing all intergers from @START_NUMBER to @END_NUMBER inclusive.
This is an improved version of a script that I posted on a topic a few weeks ago. I modified it to cross join fewer tables based on powers of 16, instead of powers of 2, because I found that this compiled and ran much faster for small result sets (less than 10,000 rows).
This is the link to the other post:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=46252&whichpage=5
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
if exists
(select * from dbo.sysobjects
where id = object_id(N'[dbo].[F_TABLE_NUMBER_RANGE]')
and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[F_TABLE_NUMBER_RANGE]
GO
create function dbo.F_TABLE_NUMBER_RANGE
(
@START_NUMBERint,
@END_NUMBERint
)
/*
This function returns an integer table containing all integers
in the range of@START_NUMBER through @END_NUMBER, inclusive.
The maximum number of rows that this function can return
is 16777216.
*/
returns table
as
return
(
selecttop 100 percent
NUMBER = (a.NUMBER+b.NUMBER)+
-- Add the starting number for the final result set
-- The case is needed, because the start and end
-- numbers can be passed in any order
case
when @START_NUMBER <= @END_NUMBER
then @START_NUMBER
else @END_NUMBER
end
from
(
Selecttop 100 percent
NUMBER = convert(int,N01+N02+N03)
From
-- Cross rows from 3 tables based on powers of 16
-- Maximum number of rows from cross join is 4096, 0 to 4095
( select N01 = 0 union all select 1 union all select 2 union all
select 3 union all select 4 union all select 5 union all
select 6 union all select 7 union all select 8 union all
select 9 union all select 10 union all select 11 union all
select 12 union all select 13 union all select 14 union all
select 15 ) n01
cross join
( select N02 = 0 union all select 16 union all select 32 union all
select 48 union all select 64 union all select 80 union all
select 96 union all select 112 union all select 128 union all
select 144 union all select 160 union all select 176 union all
select 192 union all select 208 union all select 224 union all
select 240 ) n02
cross join
( select N03 = 0 union all select 256 union all select 512 union all
select 768 union all select 1024 union all select 1280 union all
select 1536 union all select 1792 union all select 2048 union all
select 2304 union all select 2560 union all select 2816 union all
select 3072 union all select 3328 union all select 3584 union all
select 3840 ) n03
where
-- Minimize the number of rows crossed by selecting only rows
-- with a value less the the square root of rows needed.
N01+N02+N03 <
-- Square root of total rows rounded up to next whole number
convert(int,ceiling(sqrt(abs(@START_NUMBER-@END_NUMBER)+1)))
order by
1
) a
cross join
(
Selecttop 100 percent
NUMBER =
convert(int,
(N01+N02+N03) *
-- Square root of total rows rounded up to next whole number
convert(int,ceiling(sqrt(abs(@START_NUMBER-@END_NUMBER)+1)))
)
From
-- Cross rows from 3 tables based on powers of 16
-- Maximum number of rows from cross join is 4096, 0 to 4095
( select N01 = 0 union all select 1 union all select 2 union all
select 3 union all select 4 union all select 5 union all
select 6 union all select 7 union all select 8 union all
select 9 union all select 10 union all select 11 union all
select 12 union all select 13 union all select 14 union all
select 15 ) n01
cross join
( select N02 = 0 union all select 16 union all select 32 union all
select 48 union all select 64 union all select 80 union all
select 96 union all select 112 union all select 128 union all
select 144 union all select 160 union all select 176 union all
select 192 union all select 208 union all select 224 union all
select 240 ) n02
cross join
( select N03 = 0 union all select 256 union all select 512 union all
select 768 union all select 1024 union all select 1280 union all
select 1536 union all select 1792 union all select 2048 union all
select 2304 union all select 2560 union all select 2816 union all
select 3072 union all select 3328 union all select 3584 union all
select 3840 ) n03
where
-- Minimize the number of rows crossed by selecting only rows
-- with a value less the the square root of rows needed.
N01+N02+N03 <
-- Square root of total rows rounded up to next whole number
convert(int,ceiling(sqrt(abs(@START_NUMBER-@END_NUMBER)+1)))
order by
1
) b
where
a.NUMBER+b.NUMBER <
-- Total number of rows
abs(@START_NUMBER-@END_NUMBER)+1and
-- Check that the number of rows to be returned
-- is less than or equal to the maximum of 16777216
case
when abs(@START_NUMBER-@END_NUMBER)+1 <= 16777216
then 1
else 0
end = 1
order by
1
)
GO
GRANT SELECT ON [dbo].[F_TABLE_NUMBER_RANGE] TO [public]
GO
-- Demo using the function to ruturn numbers 1 to 2000
select NUMBER from dbo.F_TABLE_NUMBER_RANGE(1,2000)
-- Demo using the function to ruturn numbers -1500 to 2000
select NUMBER from dbo.F_TABLE_NUMBER_RANGE(-1500,2000)
CODO ERGO SUM
View 13 Replies
View Related
Nov 18, 2007
HI!
1.select count(*) from sales
2.select rows from sysindexes where id=object_id('sales') and indid<2
both queries return number of rows.
can anyone tell me which one is better?
View 2 Replies
View Related
Jun 1, 2015
I have a table that has an Associate id for each agent. The id is 8 digits sometimes starting with 0 (06956461) and sometimes not 0 (98039585). How would I format this?
View 2 Replies
View Related
Mar 19, 2007
I am working on a project which requires having a form that must be filled by the user. The number of the fields on this form is arround 150. Is it a good idea to have a database table with 150 fields (columns)? If its not what would be a better approach for this case? Handling this many fields on a windows form is another issue but first I would like to know about how to deal with the data storage.
Any help is appreciated.
Thanks
View 9 Replies
View Related
Jul 24, 2007
With classic asp I would do something like this:
set conn = server.createobject("ADODB.Connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=sqlservername;UID=username;PWD=password;DATABASE=databasename "set rs = conn.execute("select count(*) from myTable")response.write rs(0)How can I do this with asp.net in the fewest number of lines?
View 3 Replies
View Related
Dec 9, 2007
Im am trying to return the number of rows in a table and i only can get a response of true thanks for any help
View 3 Replies
View Related
Dec 28, 2007
Hi,
I have a denormalized table (done so with reason) with around 40 columns. I would never have to retrieve data for all of those columns together.
I haven't done any performance measurements yet but just wondering if anyone has ready answer to this: Will there be a performance degradation if I retrieve data from a table with many columns, even if not all columns are referred in the query? (for making it simple, lets assume that all or varchar type of columns, I just want to find out if performance degrades if there are too many columns in table)
Thanks in advance,
Sandeep
View 1 Replies
View Related
May 18, 2005
Here is my problem:
I have a table with following columns:
PersonID FirstName LastName
102 John Ben
103 Josh Parker
104 Mark Ben
Now if I type SELECT * FROM Person WHERE LastName = 'Ben' these two records will be displayed
PersonID FirstName LastName
102 John Ben
104 Mark Ben
But I want this to return with one additional Sequence column like this:
New Column PersonID FirstName LastName
1
102 John
Ben
2
104 Mark
Ben
How can I add this so called "New Column" ?
View 2 Replies
View Related
May 12, 2006
I try to find the number of rows in a table with this commands:
CountRec = New SqlParameterCountRec.ParameterName = "@countrec"CountRec.SqlDbType = SqlDbType.IntCountRec.Value = 0MyCommand = New Data.SqlClient.SqlCommand()MyCommand.CommandText = "select count(*) as @countrec from Customer;"MyCommand.CommandType = Data.CommandType.TextMyCommand.Connection = MyConnectionMyCommand.Parameters.Add(CountRec)MyCommand.Connection.Open()MyReader = MyCommand.ExecuteReaderiRecordCount = CountRec.Value
This is the result:
Incorrect syntax near '@countrec'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '@countrec'.Source Error:
Line 39:
Line 40: MyCommand.Connection.Open()
Line 41: MyReader = MyCommand.ExecuteReader
Line 42: iRecordCount = CountRec.Value
Line 43:
Source File: E:DevelopWebASPwebAccessTimberSalesUserEntry.aspx.vb Line: 41
What to do? I need a complete example to see how it works.
Thanks...
View 3 Replies
View Related
Jul 16, 2001
We are looking at developing a new app with a SQL Server db. As such, we're all newbies.
What is the maximum number of columns I can put in a SQL Server table?
Thanks in advance.
Bob Anderson
View 5 Replies
View Related
Apr 17, 2008
Hello,
I have a table with 3 columns: Item# | Date | ItemAmount.
Everyday there is a number of transactions entered. An Item# can only be entered once par day (if it has occurred that day).
What I want to do is to :
retrieve the number of total days where an Item has been entered for more than 2 consecutive days (for the month).
Example: if item I022 has been entered Monday and wed, then ignore, but if it's been entered Mon, Tues then return 2, if Mon, Tues, Wed then return 3 because the days are consecutive.
Does anyone have an idea.
thanks in advance,
View 7 Replies
View Related
May 23, 2008
Hello,
I am using SQL Server 2005 and am having trouble with making a history table like mentioned in my earlier thread:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=102811
This is the table "People" I have created:
|PersonId (PK)|DateFrom (PK)|DateTo|PersonName|Other Attributes....
Each change to a person's attributes results in a new row formed with the same PersonId as in the row with old attributes and the Date these new attributes are valid (DateFrom). So as shown above the Primary Key is a combination of the PersonId and DateFrom as a change to a person's attributes should never happen at the same time twice.
My problem is when I want to create a new person, how do I get a new unique id? Ideally I want the a new incremented id, so that all peoples' ids are in a sequential order.
As always, thanks for the help!
View 4 Replies
View Related
Nov 14, 2013
I have a table with no sequence column. I created a new column, but I need a way to add sequence number. This is not going to be a Primary key or indexed. I assume I will use update, but how do I do this?
Example
Before
Name | Seq
Paul | NULL
Tom | NULL
Grant | NULL
After
Name | Seq
Paul | 1
Tom | 2
Grant | 3
View 1 Replies
View Related
Jul 26, 2006
Creates a table of prime numbers, starting at 2 up to a maximum number.
Makes use of dbo.F_TABLE_NUMBER_RANGE, which is found here:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47685
create function dbo.F_TABLE_PRIME(@MaxNumber bigint)
returns @t table (i bigint primary key) as
begin
insert @t select NUMBER from dbo.F_TABLE_NUMBER_RANGE(2, @MaxNumber)
declare @i bigint
set @i = 1
while 1 = 1
begin
select @i = min(i) from @t where i > @i
if @i is null or @i * @i > @MaxNumber break
delete @t where i > @i and i % @i = 0
end
return
end
go
select * from dbo.F_TABLE_PRIME(100000) order by iCan we improve on the speed?
Ryan Randall
www.monsoonmalabar.com London-based IT consultancy
Solutions are easy. Understanding the problem, now, that's the hard part.
View 20 Replies
View Related
Mar 19, 2007
Dear Friends!
i have one table namely details
empid type qty
emp1 bucket 5
emp2 bucket 5
emp4 Book 5
emp5 Lux 5
.. .. ..
.. .. ..
nenp n n
Every end of the day i need select total no of type and qty.i have milions of records in the table
ex bucket 100
book 300
How it is possible
Regards
Umapathy
View 2 Replies
View Related
Mar 11, 2008
Hi,
What catalog table has the number of rows of a table ?
View 11 Replies
View Related
Feb 13, 2008
How can I restrict the number of records in a table in SQL Server 2005, please?
Thanks
View 5 Replies
View Related
Apr 7, 2008
I have a database hosted by GoDaddy. Recently they made some changes to the interface and upgraded to SQL Server 2008. One or the other has made it impossible to access my data in one table.
The table is quite large in terms of the numbers of elements. Each row describes a dog and all the elements are components of the description. There are (I would guess) more than 50 elements all together.
When I try to search the database, the query form goes beyond the top and bottom of the page. I can scroll the database but the search tool (which lies atop the data) does not scroll. The result is that I can't activate the search.
I've tried about 10 machines. All with IE6 display this fault. Machines with IE7 do not. I've tried various screen resolutions on the machines with IE6. That doesn't help.
I've checked other tables in the database. No problem.
In short, there's nothing I can do. I can't edit my data and GoDaddy says, "Tough."
Is there a limit on the number of columns (elements) in a table in SQL Server 2008?
Eric
View 7 Replies
View Related
Oct 15, 2015
I am currently working on an app and have an issue with a table in the database. The table has 10,000 records in it and a column is added that is to use a 4 digit in sequence. The datatype for the new column is varchar since no math will ever be done on the added column. If necessary, I can change the datatype but would prefer not to. The 4 digit would start with 0000 at ID 1 and go to 9999 at ID 10000. I'm thinking some type of update statement since it is updating each record but how would it be done sequentially?
View 9 Replies
View Related
Jun 28, 2007
Is there a limit of how many rows a table can have in SQL compact Edition? I didn't find anything in the documentation, but I get regularly a funny error message "Expression evaluation caused an overflow. [ Name of function (if known) = ]" when I try to create record number 32768 (is equal to 2 to the power of 15).
Where is this limit documented ?
Code Snippet
const string connectionString = "Data Source='" + dbFileName + "'; Max Database Size = 4091; temp file max size = 4091";
using (SqlCeEngine testEngine = new SqlCeEngine(connectionString)) {
testEngine.CreateDatabase();
}
using (SqlCeCommand addMValuesTableComand = testDbConnection.CreateCommand()) {
addMValuesTableComand.CommandText = "CREATE TABLE MValues (MSerieId int, TimeStamp smallint, Value real, PRIMARY KEY(MSerieId, TimeStamp))";
addMValuesTableComand.ExecuteNonQuery();
}
//fill table
StatusLabel.Text = "fill MValues Table";
using (SqlCeCommand fillTableComand = testDbConnection.CreateCommand()) {
int i = 0;
try {
int iterationCount = (int)RecordsCountNumericUpDown.Value;
ProgressBar.Value = 0;
ProgressBar.Maximum = iterationCount;
for (i = 0;i < iterationCount;i++) {
fillTableComand.CommandText = "INSERT MValues VALUES (1, " + i.ToString() + ", " + (i/100.0).ToString() + ")";
fillTableComand.ExecuteNonQuery();
ProgressBar.Value = i+1;
}
} catch (Exception ex) {
ErrorTextBox.Text = "Error occured" + Environment.NewLine +
"Iterations: " + i.ToString() + Environment.NewLine +
"Error Message: " + ex.ToString();
}
}
View 4 Replies
View Related