Help With Integer Field
Oct 7, 2004
hi all,
i have an autonumber field (primary key) and another integer field as part of a table. What i want to do is when a record is created, the default value of the integer field should be the_autonumber+1000 for eg record with pk 82 will have an integer field that's automatically 1082. Would it be possible to do this ? Thanks in advance.
View 2 Replies
ADVERTISEMENT
Sep 14, 2006
I have a table with an integer field (contains test values like 2, 7,8,9,12,..) that I want to convert to an Identity field. How can this be done in t-sql?
TIA,
Barkingdog
View 1 Replies
View Related
Aug 27, 2004
If I have a field where 99.9% of the time the answer is going to be "No", would I be better, in terms of disk space, using:
A bit field
OR
A tiny int field, with a NULL for the 99.9% that are "NO", and a 1 for those that are "YES".
I'm using SQL Server 7.0.
My application developer has no preference.
Thanks.
View 4 Replies
View Related
May 29, 2006
Hi everybody,
Could someone help me ???
Iam starting with sql
My problem ..
Ihave a table Table_customer
In this table a column Table_customer.no
This column contain 8000 rows.
with customer numbers: like 30789
I would like to modify once all this row adding just before the number
a value to all these rows.This value will be a 60
So will have instaed of 30789 a 6030789
This column is an integer.
I have try a simple select wich give me this result
How i can do this with update ?
probably i have to convert fisrt to caracters
select kunr,nov_kunr=
'30'+ltrim(str(kunr))
from event
where kunr is not null
Thank
View 3 Replies
View Related
Feb 17, 2007
I have a field ID of type integer, I want to put two numbers in that field: 3 and 7, so what I do is just store the number 37.Now, is there a command in SQL server which checks if the ID field contains a number I look for, say 7.Something like a CONTAINS keyword...If there is, could someone please tell me what it is AND tell me a bit more about it :memory usage, (dis)advantages etc.
View 1 Replies
View Related
Apr 1, 2008
How do i get the result 'puzzle' from the SQL and assign it to Integer and use it to compare with Request.Form ?
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
Dim connString As String = _ ConfigurationManager.ConnectionStrings("Local_LAConnectionString1").ConnectionString
Dim strsql As String = _
"Select CustomerID,CustomerNo,dbo.LA_DEC(Passkey) as passcode,dbo.LA_DEC(PuzzleKey) As puzzle, PuzzleFlag, NickName from Customers Where CustomerNo = '" & myAccount & "'"
Using myConnection As New SqlConnection(connString) Dim myCommand As New SqlCommand(strsql, myConnection)
myConnection.Open()
Dim PuzzleDataSet As New DataSet
Dim PuzzleAdapter As New SqlDataAdapter(myCommand) // <---- Coding here
myConnection.Close()
End Using
End Sub
View 7 Replies
View Related
Feb 4, 2004
I have an integer field that ranges from 3 to 6 numbers and I need to left pad leading zeros so the field is always a char(7). What is the syntax to do this? Thanks in advance.
0001234
0012345
0123456
1234567
View 1 Replies
View Related
Jan 28, 2008
Hello,
I am trying to write an SQL command to set the default value of an integer column I have within a table.
ALTER TABLE TableName alter column ColumnName int default 0
Any suggetions?
View 3 Replies
View Related
Oct 9, 2007
We have account numbers that are string values, looking like: "01.02.02.00.0040.000.000".
We need to parse individual segments and pull out a range of values treating the segment like an integer. For example we would like all accounts that have the fifth segment ranging in values from .0040. through .0060. inclusive.
We've been trying to do something with the like clause: LIKE '__.__.__.__.[0-0][0-0][4-6][0-0]'.
We want 40 through 60 but we're getting 40, 50, and 60. If we change the last bracket to [0-9] we get 40 through 69.
Does anyone have any suggestions as to either fix our like clause or another approach?
Thanks.
John
View 4 Replies
View Related
Sep 3, 2007
Hello,
what's best for year resp. quarter Field, char(4) resp. char(1), integer or other?
Both are part of a composite index.
Thanks
Silas
View 6 Replies
View Related
Sep 22, 2014
I am facing problem with re numbering of field records in a table.I am having one table with below records.
sid(identity/primarykey) stickyId(Integer) UserId(integer)
102 0 171
103 1 171
104 2 171
105 3 171
here how to renumbering stickyId values when deleted particular stickyId from UI. Here stickyId field is Integer type only. not primarykey/identity field.
View 3 Replies
View Related
Jul 2, 2007
I have the folliwing two fields, want tp concatenate:
=Fields!sequenceno.Value & =Fields!LogType.Value
Thank you very much for the information.
View 3 Replies
View Related
Nov 27, 2006
Currently I have the following stored procedure which simply adds a new row in my SQL Express 2005. What I want is that -1). before inserting the record find out the new ID (primary key) value. (ID is automatically a sequential integer generated by SQL Server)2). and set COMPANY_ID = (new) ID Any thoughts? Thanks ALTER PROCEDURE usp_tbl_Company_Insert @Company_ID int, @Name varchar(200), AS<FIND THE NEW ID of the new row in the database> @Company_ID = (new ID) INSERT INTO tbl_Company (Company_ID, Name,)VALUES (@Company_ID, @Name)
View 1 Replies
View Related
Jul 20, 2015
Working on a new database where the Date and Time are stored in a Date Time Field.
Then working on an OLDER database file within the same SQL Database contains these 2 items as integers:
transDate = "71615" (July 16, 2015)
transTime = "12345" (01:23:45 AM)
How do we convert both of them into a single SQL DateTime field such as "2015-07-16 01:23:45.000" so that it can be used in a join restricting to a date time in a different SQL File that properly has the DateTime in it?
This works well for converting the transDate Part in the select statement:
dbo.IntegerToDate(at.transDate) as transDate
* That returns: "2015-07-16 00:00:00.000"
* The resulting data must work directly in a Microsoft SQL Server Management Studio Query using either using the "on" statement or part of the "where" clause. In other words, NOT as a stored procedure!
Also must be able to be used as a date difference calculation when comparing the 2 files Within say + or - 5 seconds.
View 3 Replies
View Related
Aug 25, 2015
I'm new to SQL and I'm trying to write a statement to satisfy the following:
If [Field1] contains text from [Field2] then return [Field3] as [Field4].
I had two tables where there were no matching keys. I did a cross apply and am now trying to parse out the description to build the key.
View 8 Replies
View Related
May 4, 2006
Good morning...
I begin with SQL, I would like to add a field that will be date like 21/01/2000.
Actually i find just "datetime" format but give me the format 21/01/2000 01:01:20.
How to do for having date and time in two different field.
Sorry for my english....
Cordially
A newbie
View 3 Replies
View Related
May 19, 2008
Hi All,
If I run "SELECT 610/100", query analyser returns 6! (wrong)
If I run "SELECT 610.0/100", query analyser returns 6.100000! (correct)
I know I can get the correct result by running "SELECT Cast(610.0 as Float)/100", but why doesn't the first example return 6.1?
Is there some setting on my server which says Integer / Integer = Integer ?
Regards
Xo
View 12 Replies
View Related
Feb 13, 2008
My question is, i guess, a simple one:
When is it more convenient to use a uniqueid Data Type instead of a smallint, tinyint, bigint, etc (any type of int) when the field is gonna be the primary key for the table?
View 1 Replies
View Related
May 19, 2005
Public Function insertReport(ByVal userID As String, ByVal taskID As Integer) As DataSet
Dim ds As New DataSet
Dim da As New SqlDataAdapter("INSERT INTO report(userID, taskID) VALUES ('" + userID + "', " + taskID + ")", cn)
cn.Open()
da.Fill(ds)
cn.Close()
Return ds
End Function
Above is my code I used to invoke when inserting a record. But i receive an error message when i try to insert the integer. I cannot see where the problem lies..my datatype in sql server is int. Can anyone see what is wrong with it. Thank you in advance.
View 2 Replies
View Related
Mar 16, 2006
I have an sql statmetn that counts all the votes in the table. i need this to calculate the quota. My problem is how to i get the value(i.e the count of the votes) into the area thats colored red below?
SqlCommand SqlCmd1 = new SqlCommand("SELECT count(vote)FROM PRTest", SqlCon1);
int quota = (count(Vote) + 1) / ((11) + 1);
Response.Write(quota);
View 1 Replies
View Related
Apr 17, 2006
I use MS SQL Server 2005...Is there a structural advantage/disadvantage with using GUID as oposed to an integer?(also I use the sqltableprofileprovider and it doesnt seem to work with uniqueidentifiers)
View 6 Replies
View Related
Dec 4, 2000
Hi all,
I have a situation where I will have to insert a value(whole number) into the table where the the value is more than what the Integer can hold , I was wondering is there any other datatype which i can use other than integer
Thanks in advance.
Sanjeev Kumar
View 1 Replies
View Related
Dec 3, 2004
I had a field called camp is integer data type. I just found it had a default value, but the value is " (0) ", not just " 0 ". It should be 0, right? why it use (0), are they same? thanks.
View 7 Replies
View Related
May 18, 2008
I have some integers I want to format prefixed with zeros, e.g. 1235 would become 001235 and 445 would become 000445,
View 2 Replies
View Related
Jan 25, 2004
In my database I have a table called "users" with a varchar-field that holds categori-id's commaseparated, collected from my other table "category". I do this to control access for my users, some users are only allowed access to some categories. I would like to run a statement sort of like this:select categoryname
from category
where catid in (select categories from user where userid = 12)Naturally, because catid and the field categories have different datatypes I get the error "Syntax error converting the varchar value '340, 344, 356' to a column of data type int."
Is there any way I can bypass this keeping the commaseparated values and without making a new normalized table instead?
(same question is also posted at sql-server-performance.com forums)
View 6 Replies
View Related
Feb 12, 2014
I am trying to select only values within a column are intergers.
My statement looks like this:
(I am using MSSQL querying into a Pervasive DB via a Linked Server)
SELECT Invoice, Invoice_Date, Description, INVOICE_Code_1
FROM API_PENDING__INVOICE
WHERE (API_PENDING__INVOICE.INVOICE_CODE_1) is integer???
Obviously, this is not working...
View 6 Replies
View Related
May 6, 2015
Can I put a constraint on an integer column that will only allow a certain range of numbers to be entered, or do I have to put that into the application layer only?
I'd like the range to be 0 to 30 as the only allowable values. The only thing that I could think of was to create another table and populate with 0,1,2...,30 and put a foreign key on the new column that wouldn't allow anything not in that list but I was wondering if there was a better way.
View 3 Replies
View Related
May 30, 2006
philippe writes "Hello ,
i am just starting with sql...
I have a table: Table_user
Inside a column user_no (integer)
with value like 35678 (about 8000 rows)
I would like to modifie all rows of this Table_user.user_no
with a value of 60 at the begining of each value.
For example : before 35678 will be 6035678
Its'a concatenation,but it's an integer value .
so do i need to convert tehm to varchar first
I will appreciate some tips...."
View 5 Replies
View Related
Jan 2, 2007
Hi there!
I am building an application that counnts clicks on an ad. I use the integer field to count them but someone told me there is a limit number this field can count - is that correct? if so, is there a solution for my problem?
Thanks and happy 2007!
R
View 3 Replies
View Related
May 22, 2007
for example which function can i use to convert the real number into the corresponding integers?
4.5 ->5
3.4->3
18.9->19
Thans
View 1 Replies
View Related
Oct 5, 2007
Trying to write the most effective UDF to convert INT to Datetime.
We have a column from a table on AS400 that is a INT type. Some are 4, 5, 6 ,7 digits. I have the 4 digits right. I need to fix it for 5 and 6 digits.
ALTER FUNCTION IntegerToDatetime (@int INT)
RETURNS DATETIME
AS
BEGIN
DECLARE @IntegerToDatetime int
DECLARE @time DATETIME
SET @time = '2001-01-01'
SET @IntegerToDatetime =
CASE
WHEN LEN(@int) = 7
THEN '20' + CAST(SUBSTRING(CAST(@int AS CHAR(7)),2,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(7)),4,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(7)),6,2) AS int)
WHEN LEN(@int) = 6
THEN '19' + CAST(SUBSTRING(CAST(@int AS CHAR(6)),1,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(6)),3,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(6)),5,2) AS int)
WHEN LEN(@int) = 5
THEN '200' + CAST(SUBSTRING(CAST(@int AS CHAR(5)),1,1) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(5)),2,2) AS int)
+ '-' + CAST(SUBSTRING(CAST(@int AS CHAR(5)),4,2) AS int)
WHEN LEN(@int) = 4 THEN cast(@time AS INT)
END
RETURN (@IntegerToDatetime )
END
GO
INPUT
-------------------------------
990831
981019
RESULT
-------------------------------
1900-01-02 00:00:00.000
1900-05-27 00:00:00.000
http://www.sqlserverstudy.com
View 17 Replies
View Related
Jul 23, 2005
How do I format an integer. Add commas.1234565 1,234,565TIA
View 3 Replies
View Related
May 30, 2006
Hello,
I wanted to hear from you - if you've used any unique integer generation technique in the context of a disconnected smart client/local data store and have been successful with it.
Any ideas/suggestions will be great.
Thanks,
Avinash
View 5 Replies
View Related