Obtain The Last NEWSEQUENTIALID()

Nov 14, 2006

I'm using sql server 2005, I created a customer table and set the customer_id as an uniqueidentifier that is a NEWSEQUENTIALID()...when a user is created I want to obtain the last customer_id so that I can insert it in another table that has a one to many relationship with the customer table. Please help...how do i do this?.
Thanx 

View 3 Replies


ADVERTISEMENT

Return NewSequentialID() From SP

Apr 24, 2008

Hi All
I am using SQL Server 2005 and creating a insert SP now. How could I return the newsequentialID() after the record inserted successfully?
 Regards
Alex

View 6 Replies View Related

GUIDs Using NEWSEQUENTIALID() On SQL Server Mobile

Feb 28, 2006

Hello,

I've been thinking about using GUIDs as primary keys within my application. One problem I have with this approach is that GUIDs generated with NEWID() are not sequential, and this can have a huge impact on insertion performance due to fragmented indexes. It would seem that NEWSEQUENTIALID() solves this issue, however it doesn't seem very practical to use this on SQL Server Mobile. With SQL Server, you can specify an OUTPUT clause for an INSERT statement, and using this, determine what the last inserted GUID was. There doesn't seem to be such an option in SQL Server Mobile, so how can I get the last generated GUID so that I can attach children records to my parent record? It's been suggested that you could use the MAX() function to get the latest GUID, but there is a problem with this approach - NEWSEQUENTIALID() guarantees that the GUIDs generated will be sequential for the machine generating them, but makes no guarantees about how this will fit in with GUIDs generated by other machines. It is entirely possible that GUIDs generated by a different machine will be larger than the latest one generated on the current machine, so using MAX() to determine the latest value doesn't seem like a valid option to me.

Does anybody have any ideas on tackling this problem? Any thoughts on the suitability of using GUIDs as the primary key for SQL Server Mobile devices in general?

Thanks,
Adrien.

View 1 Replies View Related

SQL 2012 :: NewSequentialID - Error Validating The Default For Column

Oct 8, 2014

Microsoft SQL Server 2012 - 11.0.2100.60 (X64) Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

we are using the default of newsequentialID() as the key on some tables and getting the error
Error validating the default for column xxx

When first saving the table if the value is entered as newsequentialid() the save works but on any subsequent design change I get the error.

If you click Yes to continue it works fine.

The value that is in there once its saved shows up as (newsequentialid()) if you change it back to not have the outer parenthesis it saves without issue.

View 3 Replies View Related

How Do I Obtain The Row Count

Mar 1, 2001

I'm working on a search engine right now, and I am querying out a set amount of information at one time. How can I grab the last row count of a query, and use that as a starting point, or index when a "Next 100" is pressed. For instance, a person searches through a user table, but only wants 25 users at a time. So the beginning index is 0 to 25. In my query, I have "SELECT TOP 25 from users", but now when the person searching want's to move to the next 25 users, so the index would be 26 to 50, how can I hold the last row displayed? It gets a little more complex also, if a user is searching by last name, the rows will be staggered. Is there a SQL function which will grab the number of the last row displayed? I've looked through the SQL Book, and was unable to find a function that does this, or anything close to it. I hope I made sense of this question, if you need more information, email me and I will try to clarify. Thank you for any information or hints.

View 1 Replies View Related

How Can I Obtain The Top 3 Of A Dataset

Feb 9, 2005

If I have say 20 records of sales employees, for example, how can I get the top 3 locations for $$$sales for EACH employee? Each employee can have multiple locations where they have sold(let's say up to 50). I only want the names of the top 3 locations. The closest I can get is filtering the dataset by a HAVING clause > a dollar amount but this still gives me between 3 - 12 records for each plus I have to literally enter each salesperson's number as it stands now. Is this a loop or a cursor? Thanks.

ddave

View 14 Replies View Related

How Can I Obtain Message_id?

Oct 3, 2006

Hi all!

How can I obtain message_id when I SEND the message, before I execute RECEIVE statement?

Thanks a lot for the help!

View 9 Replies View Related

How To Obtain Exclusive Access Via SQL

Feb 5, 2003

Hi,

i need to run a restore of a database overnight onto a different server using the live data .bak file. however the job failed on the first run (last night) with the error:

"Exclusive access could not be obtained because the database is in use. ...."

how do i gain this Exclusive use via an SQL statement please?

View 8 Replies View Related

Obtain Trusted Connection ?

Feb 2, 2006

Hi all!


I have a new computer, clean, I installed WinXP, and I want to connect a SQL Server (other computer in the same network)
For this I installed the client tools from SQL SERVER 2000 kit. Ok.
When I try to connect to the server, I can't connect through "trusted connection", only whit user name and password.
I mention that I set the sql server in mixed mode autentification.

When I try to connect from other computer (my laptop, or other computer from this network) I can connect both types of connection: trusted and with

sa (for example)

The question is:

How I can set up a "trusted connection" at SQL Server?



The computer is completely new, clean and has win xp with sp2.


Any opinion are considered.

Thanks in advance.


koci.

View 2 Replies View Related

Obtain Trusted Connection ?

Feb 2, 2006

Hi all!


I have a new computer, clean, I installed WinXP, and I want to connect a SQL Server (other computer in the same network)
For this I installed the client tools from SQL SERVER 2000 kit. Ok.
When I try to connect to the server, I can't connect through "trusted connection", only whit user name and password.
I mention that I set the sql server in mixed mode autentification.

When I try to connect from other computer (my laptop, or other computer from this network) I can connect both types of connection: trusted and with

sa (for example)

The question is:

How I can set up a "trusted connection" at SQL Server?



The computer is completely new, clean and has win xp with sp2.


Any opinion are considered.

Thanks in advance.


koci.

View 3 Replies View Related

Trying To Obtain Past Dates

Oct 5, 2006

Hi,

I have a date column and I am trying to build a query that will give me the dates > 48 hours ago (in the past).

For example using todays date 2006.10.05 and time 23:00 I would be looking for the dates prior to 2006.10.03 and time 23:00.

Your help is greatly appreciated!

Thanks!

View 2 Replies View Related

How To Obtain The Students'name With Highest GPA

Apr 12, 2006

I want to obtain the top 1 students' name in each grade,but this code
dosen't work:
select top 1 name
from student
group by grade
order by GPA desc

Can anyone tells me what to do?

View 6 Replies View Related

How To Obtain Constraint Info

Aug 7, 2005

i need to programmatically obtain and the process constraintinformation. the problem with the output from sp_helpconstraint isthat it outputs two resultsets. (the 2nd resultset is exactly what ineed though)as far as i know i can't stick this output into a temp table to thenprocess with cursors or anything like that. i'm trying to directlyaccess all kinds of sytem tables but not getting the complete info thatthe 2nd resultset that sp_helpconstraints offers.(E.g. sp_helpindex is more useful as it outputs only one resultset ofinformation so i could programmatically use that output to do what ineed to do)any suggestions? thanks.

View 1 Replies View Related

How To Obtain Constraint (key) Info

Aug 7, 2005

i need to programmatically obtain and process constraint keyinformation. the problem with the output from sp_helpconstraint isthat it outputs 2, and sometimes 3 resultsets. (the 2ndresultset/constraint_keys is exactly what i need however)because the resultsets vary in output format, i cannot programmaticallyuse the output to process in my DB proc. its essentially useless tome. i can only suppress the 1st resultset (with tablename info), andcannot suppress the occasional 3rd resultset (that has referencingforeign key info).i've tried to directly access all kinds of sytem tables but i'm notgetting the complete info that the 2nd resultset thatsp_helpconstraints offers.any suggestions? thanks.

View 3 Replies View Related

How To Obtain Just The Last Record Grouped By

Jul 20, 2005

Sorry for my englishI have a table that contains data of career about the person (staff)like this ...EMATREANIDEMEIDEGIIDecc. ..ecc. ..ecc. ..ecc. ..1199912312002123111200311000321999123120021231122003110003419991231200073115199912312001131161999123120021231162003110003719991231200212311whereEMATR is a not unique key (person ID)EANID, EMEID, EGIID (assembled) are the date of the last advance ofcareerI want extract from the table below only the actual position,therefore a view that return this rowsEMATREANIDEMEIDEGIIDecc. ..ecc. ..ecc. ..ecc. ..1200311000322003110003419991231200073115199912312001131162003110003719991231200212311I hope of to have been explainThank you from Maximiliano (italy)RE-Sorry for my english--Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

View 1 Replies View Related

Obtain Certificate Co Configure Ssl

Jan 25, 2007

i read from msdn that i need a certificate for me to be able to configure SSL which will allow me to replicate on my publication. it says that i can obtain a certificate from a certification authority (CA). do i have to pay for it?

there is a SelfSSL that i can dowload and use for 7 days have anyone of you tried this before?

thanks a lot:)

View 3 Replies View Related

How To Obtain SQL Server Software

Sep 26, 2007



I have license information about the SQL Server 2005 Standard Edition.

Is there any possibility for me to download the media or should I need to obtain DVD only?

Regards,

NithyaPriya

View 1 Replies View Related

How Do I Obtain The Log File For A DTSX?

Aug 16, 2006

Hi everyone,

I'm stuck with this silly thing but I haven't idea how to obtain the path for the log file specified in a SSIS package programatically.

This snippet of code works fine:

Dim pkg As New Microsoft.SqlServer.Dts.Runtime.Package

Dim app As New Microsoft.SqlServer.Dts.Runtime.Application

Dim pkgResults As DTSExecResult

pkgLocation = "C:Documents and Settings40990880Mis documentosVisual Studio 2005ProjectsProyecto de SSIS3Proyecto de SSIS3ProvaPrimera.dtsx"

pkg = app.LoadPackage(pkgLocation, Nothing)

pkgResults = pkg.Execute()



After execution I'd like to see the log file which is allocated in the same place than DTSX file. But how??

Using pkg.LogProviders.Item(0).Name appears description reference "SSIS log provider for Text files1" but no the name of the file or its path



Thanks in advance for any thought or advice,





View 6 Replies View Related

Obtain Version 7 Log File Space Used Using T-SQL

Mar 14, 2000

I need to be able to obtain the storage space used for database log files through T-SQL commands.
I can do this in version 6.5 but have been unable to accomplish this in version 7.0.
Does anyone have a suggestion?

View 2 Replies View Related

Need To Obtain Space Used On Database Log Files

Mar 10, 2000

I need to be able to obtain the storage space used for database log files.
I can do this in version 6.5 but have been unable to accomplish this in version 7.0.
Does anyone have a suggestion?

View 1 Replies View Related

Obtain Database & Transaction Log Size

Aug 3, 2001

Is there any system stored procedures or system tables/db that can tell the space use, total available, for a particular db & its transaction log ?

Thanks,
Ben

View 1 Replies View Related

Openrowset To Obtain CSV Data In SQL Server

Aug 2, 2007

I am trying to obtain data from CSV file (in Excel) to SQL Server table using Openrowset command. There is one issue I am facing – The columns which have blank values in the first 20 records and then only has a proper value in the 21st record are not getting imported correctly. For such columns, I get a NULL for the proper value as well. I need to proper value to come. Any suggestion?

Thanks in advance,

sajmera

View 2 Replies View Related

SQL 2012 :: Obtain Two Columns In A Query?

Aug 19, 2014

i want to obtain two columns in a query but i donÂīt know how to.ex.

col1 col2
1 A
1 B
2 A
1 C

I need something like this.

col1 col2
1 A, B, C
2 A
Col1 = Table Z
Col2 = Table Y

View 6 Replies View Related

Need One Query To Obtain Results I Can Only Get With Two Queries

Jul 23, 2005

I'm trying to devise a query for use on SQL Server 2000 that will dowhat was previously done with one query in MS Access. The MS Accessquery was like this:SELECT Count(*) as [Opened],Abs(Sum([Status] Like 'Cancel*')) As [Cancelled]FROM Detail_Dir_LocVWhere (Detail_Dir_LocV.DateOpened > '2004-8-01') andStatus not like 'Deleted'Group By Year(DateOpened), Month(DateOpened)Order By Year(DateOpened), Month(DateOpened)Here were I'm at with SQL Server, TSQLSelect Right(Convert(Char (11), Min(DateOpened), 106), 8) as [MonthOpened],Count(Status) as [Opened]FROM Detail_Dir_LocVWhere (Detail_Dir_LocV.DateOpened > '2004-8-01') andStatus not like 'Deleted'Group By Year(DateOpened), Month(DateOpened) Order ByYear(DateOpened), Month(DateOpened)Which yieldsMonthOpened======================Aug 2004503Sep 2004752Oct 2004828Nov 2004658Dec 2004533Jan 2005736Feb 2005707Mar 2005797Apr 2005412AndSelect Right(Convert(Char (11), Min(DateOpened), 106), 8) as [MonthOpened],Count(Status) as [Cancelled]FROM Detail_Dir_LocVWhere (Detail_Dir_LocV.DateOpened > '2004-8-01') andStatus like 'Cancelled%'Group By Year(DateOpened), Month(DateOpened) Order ByYear(DateOpened), Month(DateOpened)Which yields;MonthCancelled=========================Aug 200478Sep 2004105Oct 2004121Nov 2004106Dec 200475Jan 200582Feb 200571Mar 200594Apr 200533What is desired isMonthOpenedCancelled============================Aug 200450378Sep 2004752105Oct 2004828121Nov 2004658106Dec 200453375Jan 200573682Feb 200570771Mar 200579794Apr 200541233Any assistance would be appreciated.Cheers;Bill

View 3 Replies View Related

Obtain Contents Of Stored Procedures

Jul 20, 2005

Hi all,I need to be able to obtain the full contents, i.e. sql statementsinside, of all procedures in SQl Server 2000. I am using MS type 4JDBC driver. I know that from the database metadata, I could get thenames of all stored procedures and their column structures. However,I did not find any thing that will help me to obtain contents of thestored procedures. Any help would be very much appreciated. Thanks:-)) Vien Nguyen

View 1 Replies View Related

Recommended Method To Obtain SQLDataPath

Jul 20, 2005

I know the default data path on a SQL7 server is defined in theregistry key SQLDataPath. I want to be able to determine the defaultdata path in a VB.NET application on the local machine and remotemachines. Is using the Registry Class the best way to do that or isthere a SQL command that can tell me? I have read about xp_regread butI can't find it documented anywhere and I do not know what parameterlist it is expecting. I thought this path may be in an InformationSchema view, but I can't find it.Thanks for any help.

View 2 Replies View Related

Could Not Obtain A Required Interface Error

Apr 11, 2007



I have created a linked server that connects to "mpp" file, and it connects and opens successfuly returning a list of tables that exists in the linked server to the mpp file.



But the problem i am facing now that whne i write a select statment to get data from the tables in this linked server

select * from linktompp.testmpp.dbo.tasks

such that linktompp is the linked server name

testmpp is the catalog name

tasks is the table name i need to select data from

it shows an error that says

"Could not obtain a required interface from OLE DB provider 'Microsoft.Project.OleDB.11.0'."

"[OLE/DB Provider 'Microsoft.Project.OleDB.11.0' IUnknown::QueryInterface returned 0x80004002: IGetDataSource]"





could anyone tell me the reason of this error

thanks

View 1 Replies View Related

Cannot Obtain The Schema Rowset DBSCHEMA_TABLES_INFO

May 14, 2007

I see others having this problem when trying to run a query across a link from 2005 to a 2000 server. But we are already running SP4 on our 2000 server. What gives?





OLE DB provider "SQLNCLI" for linked server "s-1" returned message "Unspecified error".

OLE DB provider "SQLNCLI" for linked server "s-1" returned message "The stored procedure required to complete this operation could not be found on the server. Please contact your system administrator.".

Msg 7311, Level 16, State 2, Line 5

Cannot obtain the schema rowset "DBSCHEMA_TABLES_INFO" for OLE DB provider "SQLNCLI" for linked server "s-1". The provider supports the interface, but returns a failure code when it is used.

View 2 Replies View Related

Obtain The Query Plan Of A Running Process

Sep 21, 2006

Hi,Is there a way to findout the query plan of the executing process usingthe SPID/KPID information.Thanks in advance,Thyagu.D

View 1 Replies View Related

How To Obtain Query Execution Time As A Variable?

Feb 28, 2008

Hi guys,
I am looking for system procedure or system variable that will give the execution time of a SQL query.

I need to capture the execution time of a query in a variable and depending on the value do furthur processing.

Any help in this regard will be appreciated.

View 18 Replies View Related

SQL Jobs - Cannot Obtain A LOCK Resource At This Time

May 24, 2007

Hi All,



We recently bought a new (sql) database server with 8 gb ram. I started moving the databases from our older 2005-sql to the new one. Everything goes well, except...



Some steps in our jobs do a truncate table of a delete from... When the job is running and it reaches the step where the truncation/deleting starts, it stops its execution and gives the following error :




Code Snippet

The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions. [SQLSTATE HY000] (Error 1204). The step failed.




When I try to execute the procedure that does the truncation manually, it works perfect. Do you guys have an idea on what the cause of this error might be ?



Thanks a lot in advance !



(FYI: we use the enterprise edition of sql server 2005)



Grtz, Koen

View 9 Replies View Related

Obtain Sqlceresultset Table Schema With GetSchemaTable

May 4, 2006

I have a SqlCeResult pointing to a table :



Public conexion As Data.SqlServerCe.SqlCeConnection = New Data.SqlServerCe.SqlCeConnection("Data Source=iPAQ File StoreGestionAlmacenN.sdf")

Public ComandoCargaProductos As Data.SqlServerCe.SqlCeCommand = conexion.CreateCommand

Public ResultSetProductos As Data.SqlServerCe.SqlCeResultSet

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

conexion.Open()

'**********************************************************

'************Conexion con Tabla Productos******************

'ComandoCargaProductos.CommandText = "SELECT * from [Productos]"

ComandoCargaProductos.CommandType = Data.CommandType.TableDirect

ComandoCargaProductos.IndexName = "PK__Productos__0000000000000041"

ComandoCargaProductos.CommandText = "Productos"

ResultSetProductos = ComandoCargaProductos.ExecuteResultSet(Data.SqlServerCe.ResultSetOptions.Scrollable Or Data.SqlServerCe.ResultSetOptions.Updatable)

End Sub

And I want to obtain the schema of the table which my resultset is pointing

Dim tabla As Data.DataTable

tabla = Me.ResultSetProductos.GetSchemaTable

But the datatable that i obtain donīt seem to have the schema that i need, for example donīt have the primary keys i have define and also donīt have any constrains......



Does anybody know the problem?



Thanks for your help

View 1 Replies View Related

Obtain The Result Of Dynamic Query With Openrowset

Oct 5, 2006

im running a dynamic query with open rowset in it


pseudocode:

@CMD=declare @ RETURN SELECT @RETURN =SUM(X) FROM OPENROWSET(....) SELECT @RETURN

EXEC @CMD

This pseudocode dipplay the result of @return

the problem:

capture @return into @myvalue outside the dynamic sql scope

something like

Select @myvalue=exec(@cmd)



I don't wanna run on ditributed transaction like this

insert mytable

exec(@cmd)
thanks,

joey









View 7 Replies View Related







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