Can Someone Explain The Precision Of An Integer In A Sql Db Pls

Nov 3, 2003

Hi I am in the process of creating a new db in sql. In my users table I wish to set the UserIds as Integer datatype. It defualts on precision 4. Does this mean that when the column auto increments as its my primary key with a seed of one, my highest number allowed in the table would be row 9999. ???





Also if you where to store a phone number in your db, what column type would you give it. I have used varChar but its all numbers i want to store. Would this suffice.





Thanks

View 1 Replies


ADVERTISEMENT

DB Design :: Convert Integer Date (MMDDYY) And Integer Time (HHMMSS) To DateTime Format?

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

Set Precision

Jan 9, 2006

Hi, I have a database field of type "money". But when I rerieve it to text box, it shows 5.0000, but I want only 5.00 to be shown. How do I format that?
Any reply will be much appreciated. :)

View 2 Replies View Related

Can Someone Please Explain This To Me...

Jun 26, 2007

why do the following return the same datasets?
 select * from myTable where myData = ''
 select * from myTable where myData = '     '
in the first I'm specifically searching empty strings, in the second a sequence of five spaces. Yet both return any and all white character matches? Is this a "feature" of SQL...
P.S. I'm using T-SQL

View 2 Replies View Related

How Do I Run 'explain' On A Sql??

Jun 27, 2001

Hi, does anyone know how to run an 'explain' on a sql query on SQL Server 2000?

Thanks.

View 1 Replies View Related

Could Someone Please Explain The Following...

Dec 1, 2005

As previous threads have indicated I've been trying to figure out what's slowing down our 3rd party ETL tool.

My research has figured out the culprit, but now I need some advice on the best way to handle it.

Here's what's going on...
SPID 1 = dynamic sql passed from Crystal
SPID 2 = ETL tool
SPID 3 = report in stored proc

Until a few days ago we didn't even know SPID 1 existed. These are different guys, using old version of Crystal passing crappy queries.

Here's the scenario
SPID 1 is running (inefficient select)
SPID 2 is waiting
30 minutes pass and SPID 2 is still waiting PAGEIOLATCH_SH
SPID 3 fires off

Now SPID 2 is blocking SPID 3, but SPID 2 is still waiting for SPID 1

Finally when SPID 1 finishes, everything catches up. But it appears that there is a period of at least 45 minutes when all SPID's are just sleeping.

My questions:
1. If SPID 1 is just running an inefficient select query, why is it holding up SPID 2 (Which reads and inserts). SPID 1 should have a shared lock on table, this would prevent SPID 2 from insert/update?
2. Is there any steps I can take to give SPID 2 precendence? or is it first come first serve?

Thanks in advance

View 10 Replies View Related

Explain

May 2, 2008

Any one explain me about this query exactly wat it will do

backup log iiswebappauditdb with truncate_only

View 3 Replies View Related

Explain Me

May 8, 2008

set @tb1='rptmain.Month01.DBO.LCDB' in

View 1 Replies View Related

Can U Just Explain....

Nov 3, 2007

Query:
insert into aaaa values(',Â?'&',',Â?'&');

BUJJI.

View 6 Replies View Related

Can Some Explain This To Me?

Oct 25, 2007

Hello,I run the following query on a database (SQL 2005):delete from person where pers_companyid in (select pers_companyid fromcompany where comp_expiry is not null)I wanted to delete all people associated with a company which had anexpiry date. The mistake I made was that the column pers_companyiddoes not exist. It should have been comp_companyid.However, the query ran anyway and deleted all records from my persontable? If I run the subquery on its own then it doesn't run as thecolumn is missing.Shouldn't I have got an error running this query?Thanks,David

View 2 Replies View Related

How To Set Float Precision

Feb 20, 2000

Hi!
I'm quite new to SQL Server. I need to set a float datatype to display something like 3.55. However, all values that are stored in the float column are truncated to 4 or some other single digit. How can this be prevented?

Regards,
Sam

View 1 Replies View Related

Float Precision

Sep 5, 2002

Hello everyone,

I am sure this is a newbie question as I am new to Microsoft SQL server but any help is greatly appreciated. I am populating a SQL database from an AS400. The decimal numbers from the AS400 are coming accross with extra decimals. (ie. 63.02 is coming accross as 63.0200001)

Is there a way to limit the number of decimals in a float or real field - or a SQL command I can put in a script to truncate each field to 2 decimal places after they are populated.

Thanks,
Randy

View 1 Replies View Related

Precision And Scale?

Nov 8, 2004

Hello,

I have been trying to develop an automatic way of programmatically accessing datasources and performing some predefined(-supported) processing on them.

The question I would like to ask you people has to do with numeric fields. What exactly is precision? Is it the maximum length in digits of a field, or is there more to it? What about a "field's scale", what is it and how does it affect a field's value handling?

Thank you very much,

Dave

View 1 Replies View Related

Formulas & Precision

Sep 21, 2006

I have a table with a 'quantity' column (decimal 9:3) and a 'price' column (9:3). I have a third column 'amount' with a formula of (price * quantity). The formula gives the correct answer, but the precision is automatically set to 5. Is there any way to set the precision of the result to 2?

Thanks.

View 4 Replies View Related

Timestamp Precision

Jan 21, 2008

I am using ASP and SQL 2005 Express.I am inserting a timestamp from an ASP page using <%=now%into asmalldatetime field. All of my timestamps are appearing without anyseconds (e.g., 1/21/2008 4:02:00 PM or 1/18/2008 11:32:00 AM).When I view the source for my page is shows the date/time as 1/21/20084:27:31 PM, but for some reason the seconds will be converted to1/21/2008 4:27:00 PMHow do i get more a more precise timestamp?Please help.

View 1 Replies View Related

Error:The Precision Must Be Between 1 And 38.

Apr 18, 2007

Hi All

I am trying to pull data from Oracle to SQL Server but if I use Oledb Source than I get this error



Error at Data Flow Task [DTS.Pipeline]: The "output column "CUST_ID" (590)" has a precision that is not valid. The precision must be between 1 and 38.



------------------------------
ADDITIONAL INFORMATION:

Exception from HRESULT: 0xC0204018 (Microsoft.SqlServer.DTSPipelineWrap)


The only solution I found is use DataReader Source,

But if I use DataReader Source everything works fine , I mean I am able to see the records and convert it desired data type (using Data Convertion component).

My question is what component should I use as Destination, coz if I use OLEDB Desination I get a red cross on the components although I can map all the columns.....

View 9 Replies View Related

Please Explain Transaction For Me

Sep 29, 2007

 I found this on http://msdn2.microsoft.com/en-us/library/86773566.aspx which i am hoping may be able to resolve my problem but I am not sure I actually understand it. Where it shows // Start a local transaction. transaction = connection.BeginTransaction("SampleTransaction");
is the "SampleTransaction" nothing more then just a name of the transaction that is being created through this code or is it actually pointing to something?I believe that I understand the rest. Oh and in case you have a better way of doing what I am needing here is the SQL Query that is pulling info for me to display on a pageSELECT     p.product_ID, p.class_ID, p.category_ID, p.product_name, p.product_desc, p.product_image, p.product_dimension, p.product_o1, p.product_o2,                       p.product_o3, p.product_ac, p.product_ph, p.product_photo, pcl.class_name, pca.category_nameFROM         products AS p INNER JOIN                      productClass AS pcl ON p.class_ID = pcl.class_ID INNER JOIN                      productCategories AS pca ON p.category_ID = pca.category_IDBasically I am using the transaction to perform multiple updates seeing as how I will need to update multiple tables.  private static void ExecuteSqlTransaction(string connectionString){ using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = connection.CreateCommand(); SqlTransaction transaction; // Start a local transaction. transaction = connection.BeginTransaction("SampleTransaction"); // Must assign both transaction object and connection // to Command object for a pending local transaction command.Connection = connection; command.Transaction = transaction; try { command.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"; command.ExecuteNonQuery(); command.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"; command.ExecuteNonQuery(); // Attempt to commit the transaction. transaction.Commit(); Console.WriteLine("Both records are written to database."); } catch (Exception ex) { Console.WriteLine("Commit Exception Type: {0}", ex.GetType()); Console.WriteLine(" Message: {0}", ex.Message); // Attempt to roll back the transaction. try { transaction.Rollback(); } catch (Exception ex2) { // This catch block will handle any errors that may have occurred // on the server that would cause the rollback to fail, such as // a closed connection. Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType()); Console.WriteLine(" Message: {0}", ex2.Message); } } }} 

View 1 Replies View Related

Please Explain This SQL Trigger

Sep 25, 2005

I am new to triggers.I am unsure why on the SELECT statement the ROLLBACK is enforced. I thought this would be only for when an attempt is made to insert the data. Also what is the pupose of IF @counter = 1 When does this counter change value? USE Northwind GO CREATE TRIGGER PriceCheck     ON [Order Details]     FOR INSERT     AS DECLARE @counter int     SET @counter= @@ROWCOUNT     DECLARE @unitprice money     DECLARE order_details_insert_cursor CURSOR FOR         SELECT Unitprice             FROM inserted     IF @counter = 1         BEGIN             IF(SELECT UnitPrice FROM inserted) > 300             -- If the price entered is greater than 300             BEGIN                 --print a warning                 PRINT 'Cannot enter price greater than 300'                 --Take back the command                 ROLLBACK TRANSACTION             END         END     ELSE         BEGIN             OPEN order_details_insert_cursor             FETCH NEXT FROM order_details_insert_cursor INTO @unitprice             WHILE @@FETCH_STATUS = 0                 BEGIN                     if @unitprice > 300                     -- If the price entered is greater than 300                     BEGIN                     --print a warning                         PRINT 'Cannot enter price greater than 300'                         --Take back the command                         ROLLBACK TRANSACTION                         RETURN                         --Exit trigger immediately                     END                     FETCH NEXT FROM order_details_insert_cursor INTO @unitprice                 END                                  CLOSE order_details_insert_cursor             END                          DEALLOCATE order_details_insert_cursor

View 3 Replies View Related

Explain Xp_cmdshell

Feb 2, 2006

I've got some questions about xp_cmdshell and was hoping someone could explain some things to me.  I've written a trigger for a table that uses 'xp_cmdshell' to launch a VB.Net application.  The syntax is correct and it "seems" to work but in the way I intended.  When the app launches there is no GUI present but when I check the task list I see that the exe has been launched.  This intrigued me so I started playing with it in Query Analyzer.  When I run the commandexec master.dbo.xp_cmdshell 'C:WINDOWSsystem32otepad.exe'I seen a process for notepad show up on my processes list started by 'system' as opposed to myself and notepad still doesn't open up for me to see.  I also noticed that the query executes until I kill that particular process.  I'm guessing cause it's waiting on the tranaction to complete.  What I want to know though is why can't I see the program when I open like this?  Is it because 'system' is the user behind it or is there some extra parameter to throw in the xp_cmdshell?  

View 3 Replies View Related

EXPLAIN Function

May 19, 2008

Is there some equivalent to MySQL's EXPLAIN function? (or some utility that does the same thing?)

Basically the function takes a query and will return a list of the tables in the query and the number of rows that would need to be checked. It's used to check how well the indexes are set. (If a table returns a very high number, that could be a bottleneck for the query).

Any help is appreciated. Thanks.

-D. Israel

View 1 Replies View Related

Explain Plan

Mar 17, 2008

Dear All,
what exactly is ExplainPlan and maintenance plan? and where would we use these?


i've found some artilce in the NET, but i'm not satisfied


please provide me good articles and your words for me

Vinod
Even you learn 1%, Learn it with 100% confidence.

View 1 Replies View Related

Can Someone Explain This Behaviour?

Jul 23, 2005

Hello All,The following script is reproducing the problem assuming you haveNorthwind database on the server.Please note it gives you the error message on line 12.USE tempdbGOsp_addlinkedserver 'Test17'GOsp_setnetname 'Test17', @@SERVERNAMEGOIF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE id =object_id(N'[dbo].[This_works]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)DROP PROCEDURE [dbo].[This_works]GOCREATE PROCEDURE This_works@UseLinkedServer bit = 0-- WITH RECOMPILE -- Does not helpASSET NOCOUNT ONIF @UseLinkedServer = 1 -- Linked ServerBEGINIF EXISTS (SELECT 1 FROM dbo.sysobjects where id =object_id(N'[dbo].[Orders_TMP]') and OBJECTPROPERTY(id, N'IsUserTable')= 1)DROP TABLE dbo.Orders_TMPSELECT * INTO dbo.Orders_TMP FROM Test17.Northwind.dbo.OrdersENDELSE -- LocalBEGINIF EXISTS (SELECT 1 FROM dbo.sysobjects where id =object_id(N'[dbo].[Orders_TMP]') and OBJECTPROPERTY(id, N'IsUserTable')= 1)DROP TABLE dbo.Orders_TMPSELECT * INTO dbo.Orders_TMP FROM Northwind.dbo.OrdersSELECT 1 FROM dbo.Orders_TMP WHERE 1 = 2 -- Why do I need this line?ENDBEGIN TRANSACTIONSelect 'Line 25'SELECT COUNT(*) FROM dbo.Orders_TMPCOMMITgoIF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE id =object_id(N'[dbo].[This_does_not]') and OBJECTPROPERTY(id,N'IsProcedure') = 1)DROP PROCEDURE [dbo].[This_does_not]GOCREATE PROCEDURE This_does_not@UseLinkedServer bit = 0-- WITH RECOMPILE -- Does not helpASSET NOCOUNT ONIF @UseLinkedServer = 1 -- Linked ServerBEGINIF EXISTS (SELECT 1 FROM dbo.sysobjects where id =object_id(N'[dbo].[Orders_TMP]') and OBJECTPROPERTY(id, N'IsUserTable')= 1)DROP TABLE dbo.Orders_TMPSELECT * INTO dbo.Orders_TMP FROM Test17.Northwind.dbo.OrdersENDELSE -- LocalBEGINIF EXISTS (SELECT 1 FROM dbo.sysobjects where id =object_id(N'[dbo].[Orders_TMP]') and OBJECTPROPERTY(id, N'IsUserTable')= 1)DROP TABLE dbo.Orders_TMPSELECT * INTO dbo.Orders_TMP FROM Northwind.dbo.Orders--SELECT 1 FROM dbo.Orders_TMP WHERE 1 = 2 -- Why do I need this line?ENDBEGIN TRANSACTIONSelect 'Line 25'SELECT COUNT(*) FROM dbo.Orders_TMPCOMMITGOPRINT 'This_works'EXECUTE This_works 0PRINT ' 'PRINT 'This_does_not'EXECUTE This_does_not 0Thanks for any help or hint,Igor Raytsin

View 8 Replies View Related

Explain Plan

Jul 20, 2005

Hello.Does someone of you know if is there a 'explain plan' like function in SQLServer (similar to explain plan in Oracle or DB2)If so then how it works, where stores data and how it can be retrieved?Best regardsBagieta=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=dbDeveloper - Multiple databases editorhttp://prominentus.com=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

View 5 Replies View Related

Could Someone Explain This Script To Me

Jan 29, 2008

Hi,

Could someone help me understand this script:

DECLARE @TempValue tinyint

SELECT @TempValue = 1
FROM dbo.TABLE_NAME (tablockx updlock holdlock)
WHERE 1 = 2

To my understanding, it would lock all the row in the table at once.

View 14 Replies View Related

Can Someone Explain This Error Please

Oct 9, 2007



Upon executing the following:


create function test()

returns @tmp table

(

somevalue varchar(max)

)

as

begin

select '' as ttt

into tmp


insert into @tmp(somevalue)

select ttt

from tmp


return

end



I get this error:

Msg 443, Level 16, State 15, Procedure test, Line 8

Invalid use of side-effecting or time-dependent operator in 'SELECT INTO' within a function.



I've searched around and honestly cannot find a definitive description of what this means. Can anyone explain in simple terms for a simpleton like me?

Thanks
Jamie

View 18 Replies View Related

Subtraction Of Different Precision Values

Sep 24, 2007

We have a field which is decimal (9,2) and another which is decimal(9,3). Is there anyway to subtract the two and get a precision 3value without changing the first field to 9,3?For instance, retail value is 9,2, but our costs are at 9,3 due tobeing averaged. To calculate margin (retail-cost), we want that alsoto be 9,3, but a basic subtraction comes out 9,2. You can see wedon't want to increase retail to be 9,3 (that would look funny), andit seems wasteful to store retail twice (one 9,2 for users and one 9,3for margin calc)...is there any other way?

View 2 Replies View Related

Help Required For Right Precision And Scale

Dec 7, 2007



Hi , i am receiving data froma flat file it is

These are amount fields

123456.89

i am selecting numeric (8,2) as datatype is this valid please let me know.

View 3 Replies View Related

How To Set Precision Of A Decimal Number

Oct 8, 2006

there is a column which type is float in a table, i want to set the precision of its value, for example if its value is 10.333888, i want to get its value as 10.33, how to complete it in a select Sql?

thks

View 3 Replies View Related

Data Type's And Precision

Jan 31, 2008

I receive patient demographic files from hospitals that are in several different formats. I have written translations for each format. I need to upload the files into our accounting software. I have the file layout to upload data and it looks like this.







From To Length
Record Type Code 1 2 2A
Account Number 3 17 15A
Guarantor Name 18 47 30A
Guarantor Zip 125 129 5N
Guarantor Area Code 134 136 3N

In SQL Server I have not found a way to set precision on an int. I have to have the correct length, and data type (A for alfa which is left justified and N for numeric which is right justified) field for a succsessfull upload. Suggestions on what data types to use would be very helpful, and then suggestions on how to output the data in a text file described example above would be a life saver.

View 1 Replies View Related

Could Anybody Explain To Me Why Sqldatadpater Does Not Allow Subqueries?

Aug 17, 2007

Dear experts,
Recently i got an error msg looks like this: you cannot use subqueries within a sqldatadpter except the subquery is introduced with EXISTS.
Well, actually i was using IN.
I know I can revise my query sting to use INNER JOIN or such stuff just to remove the nested queries. But i'm realllllly curious why it's not allowed??
Really appreciate it if some expert can tell me.
Thanks in advance

View 1 Replies View Related

You Can't Explain This! ARRRRG! SQL Ghost!

Dec 23, 2007

Hello all,
Where do I start?  My son and I wrote a small ASP.net 2.0 website on XP IIS 5.  Works ok with the standard login controls.
I FTP'ed the files up to a Windows server2003.  I installed the SQL publishing wizard.  I created a .sql file of the data base.
I ran the file in SQL2005 manager to build the data base on SQL express running on the Windows 2003 server.  It installed,  no errors.  great!
The website would not run with Data base connection errors ,  like files or data base was read only,  duplicate database ,  can not run mydatabase.create.  something like that.
I created a new app pool and made sure network service was the account.  Gave network server permissions to the folders,  it started working great.
Now sit down.  I created a few accounts using the website  ok,  no errors, Great!   Then check the database to see if the passwords were encrypted.  The new accounts were not there. 
But the accounts went somewhere????   Must be two databases????  One hidden?
I detached the database I created with the .sql script file....  to see if I would get an error on the browser.  nope still worked. Hmmmm other hidden database still working.... I stopped database server
in the management tool,    It still worked....Ok, I'll get the house check for poltergiests.
I went to SERVICES.  The service was stopped(SQLEXPRESS)..  I changed auto start to manual.  Browsed back to the site again,  finally an error.
I restarted the service,  website worked again,  but the database,  the only user database,  is still detached.  Created more user accounts with no error....
Seached the hard drives for .MDF files.  Found the file I detached and also the ASPNETDB.MDF that I orginally FTP'ed to the server earlier in the APP_DATA folder of the website.  I renamed the  
MDF file to see if then I would get an error,  yep I did.    It then automatcly re-created the MDF file exactly the same size.  Two files in the directory now and now a new error in the browser
about a database mismatch.  Ok  that makes sense.   But it will not allow me to rename the new file so I can rename the original. 
Question is how does SQLEXPRESS run the ASPNETDB.MDF file in the web folder which is not attached to the database engine? 
Why use a SQL pub wizard if ASP.NET creates the database automaticly? Or just "Runs" it?    AM I HIGH?
Thanks in advance,  before I take drugs and sit in a dark closet.
-Wade
 
 
 
 

View 4 Replies View Related

Can Anyone Explain To Me Why This Is Not A Good Idea

Jan 28, 2008

I have a complex select statement that is used in several stored procedures. I decided that instead of having x number of T-SQL scripts with the same exact select statement that I would to put this query into a view and then do a select * from View.  Recently an instructor told me that this was a bad idea and that anyone who uses a select * from anything should be fired.  When I asked for his reasoning his response was to say the least abnoxious.  I can understand why a Select * from Table might be a bad idea as the table definition can change, but the chances of a view changing seems much less likely.
Is a view a good idea in this case?  Is the Select * from View really a bad idea?
 Thanks
 
 

View 6 Replies View Related

Explain Exists() Function

Apr 8, 2008

Can any one explain to me how to use the exists() function and what exactly it is used for?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved