Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Monday, March 19, 2012

Active Directory select

Hi all,
I 'm sorry my wrong english, please.
So i have a problem. I make in a linked server which represent my server 's active directory. I would like to write a sql query what show the users and when expire their password.
How can i write this query?
Thank you in anticipation!

Diccsy

Quote:

Originally Posted by diccsy

Hi all,
I 'm sorry my wrong english, please.
So i have a problem. I make in a linked server which represent my server 's active directory. I would like to write a sql query what show the users and when expire their password.
How can i write this query?
Thank you in anticipation!

Diccsy



Trying to translate this for you to a more readable question.

Quote:

Originally Posted by

I would like to know how to create a SQL Query that shows the users in my servers active directory and when their passwords expire.



Thanks in advance.


-- I think this is what he wants --|||in my reply
http://www.msdner.com/forum/thread626320.html

this was a discussion at that link.

Sunday, March 11, 2012

Active Directory 1000 rows limitation

we are using

select distinguishedname, employeeid, sn, middlename, givenname, displayname, samaccountname, mail, cn, telephonenumber
from OpenQuery( ADSI, 'SELECT telephonenumber, distinguishedname, employeeid, sn, middlename, givenname, displayname, samaccountname, mail, cn, telephonenumber
FROM ''LDAP://DC=domain,DC=xxx,DC=xxx''
WHERE objectCategory = ''Person'' AND objectClass= ''user''

But it only returns 1000 rows which i read all around that is the default.

How do you set this to be higher.

Thanks

Try adding the connection attribute "Page Size" to your connection string and specify higher value. By default, the ADSI search API restricts the first result set size to 1000 rows and the rest of the rows have to be paged one by one. There are probably other connection string attributes that needs to be specified for the search result to be expanded. I do not know the exact details so you will have to check the ADSI OLEDB provider documentation.

Saturday, February 25, 2012

AccessViolationException from SQLDataSource

I'n getting a randomAccessViolationException during the select operation of an SqlDataSource (ASP.NET 2.x), after I have modified the CommandText from it'sSelecting event.

I know it's considered a bad idea to dynamically modify the SQL rather than use parameters, but in this instance, I'm more concerned as to why this exception is occurring. It *only* happens if I modify the CommandText and even then I'd say it only occurs 10% of the time. More annoying than anything is that it is returning the correct results. I can catch the exception from theSelected event and the stack trace reveals that the failing method isSQLExecDirectW.

There is nothing wrong with the CommandText syntax and MS documentation states that it can be changed from the Selecting event, so I'm at odds as to why this is happening.

For completeness, the reason I can't use parameters is that I'm using the ODBC Datasource with a Paradox database (Intersolv drivers). I need an optional predicate and IsNull() is not supported, and I cannot get the {fn IFNULL(?, Table.`Field`)} escape sequence to work with an SQL input parameter.

Can anyone put me out of my misery?

This is an exception throwned from unmanaged code because something is trying to access protected memory so it sounds like the database drivers.

Have you checked for updated drivers ? You should probably report the bug to the people providing these drivers.

Friday, February 24, 2012

accessing to an oracle 10 linked server

Hello,
i try to make some select queries using a linked oracle 10 server but for a
few tables, only the first row is returned...
i haved used "Microsoft OLE provider for OCBC driver" when declaring my
linked server and my odbc link is using the lastest Oracle odbc driver
(10.1.3.1).
Using another odbc driver (microsoft odbc for oracle) instead of oracle one
make it works great on query analyser but when using it on my programs (who
are connecting to SQLSERVER 2000 using odbc SQLSERVER), linked request fail
returning me "Impossible to start other transactions for this session".
Any clue?
Thx
Not sure but you'd definitely want to try using the OLE DB
provider instead. You add extra overhead when using the OLE
DB provider for ODBC. The OLE DB providers generally provide
more functionality as well.
-Sue
On Tue, 15 Mar 2005 07:23:03 -0800, Cdric Prin-Derre
<Cdric Prin-Derre@.discussions.microsoft.com> wrote:

>Hello,
>i try to make some select queries using a linked oracle 10 server but for a
>few tables, only the first row is returned...
>i haved used "Microsoft OLE provider for OCBC driver" when declaring my
>linked server and my odbc link is using the lastest Oracle odbc driver
>(10.1.3.1).
>Using another odbc driver (microsoft odbc for oracle) instead of oracle one
>make it works great on query analyser but when using it on my programs (who
>are connecting to SQLSERVER 2000 using odbc SQLSERVER), linked request fail
>returning me "Impossible to start other transactions for this session".
>
>Any clue?
>Thx

accessing to an oracle 10 linked server

Hello,
i try to make some select queries using a linked oracle 10 server but for a
few tables, only the first row is returned...
i haved used "Microsoft OLE provider for OCBC driver" when declaring my
linked server and my odbc link is using the lastest Oracle odbc driver
(10.1.3.1).
Using another odbc driver (microsoft odbc for oracle) instead of oracle one
make it works great on query analyser but when using it on my programs (who
are connecting to SQLSERVER 2000 using odbc SQLSERVER), linked request fail
returning me "Impossible to start other transactions for this session".
Any clue?
ThxNot sure but you'd definitely want to try using the OLE DB
provider instead. You add extra overhead when using the OLE
DB provider for ODBC. The OLE DB providers generally provide
more functionality as well.
-Sue
On Tue, 15 Mar 2005 07:23:03 -0800, Cdric Prin-Derre
<Cdric Prin-Derre@.discussions.microsoft.com> wrote:

>Hello,
>i try to make some select queries using a linked oracle 10 server but for a
>few tables, only the first row is returned...
>i haved used "Microsoft OLE provider for OCBC driver" when declaring my
>linked server and my odbc link is using the lastest Oracle odbc driver
>(10.1.3.1).
>Using another odbc driver (microsoft odbc for oracle) instead of oracle one
>make it works great on query analyser but when using it on my programs (who
>are connecting to SQLSERVER 2000 using odbc SQLSERVER), linked request fail
>returning me "Impossible to start other transactions for this session".
>
>Any clue?
>Thx

Sunday, February 19, 2012

accessing the database remotely from non-microsoft platform

I have a query of the kind brains of this group.

Is it possible to access a microsoft sqlserver database (for select, insert,
update, delete, and for miscellaneous administrative actions such as table
and index creation and deletion) remotely from a compiled C program (and/or,
from Perl) running on a NON microsoft platform, such as Sun's Solaris and/or
Linux?

What toolset(s) could be used (on the UNIX/Linux end) for such a purpose?
Would it require a corresponding special toolset to be installed on the
Windows server end as well? (I'd prefer not to have to do that if
possible.)

If you are not now rolling on the floor laughing at the "heresy" of such a
notion, thanks in advance.

Dan
drlevy@.glowing.com (replace 'glowing' with 'lucent')Some suggestions here:

http://www.sommarskog.se/mssqlperl/unix.html

Simon

Accessing table in Server A while in Server B

How would I select data from a table in a server called A while I am in a server called B? I am trying to capture the data in server A in a stored procedure within server B. I attempted using syntax similar to
A.database.dbo.tablename but it gave me an error. Please let me know. Thanks.What about linked server?|||As mentioned using linked server and OPENQUERY you can be able to select/update data between 2 servers.

Refer to books online for linked servers topic.

Monday, February 13, 2012

Accessing SELECT results within a stored procedure

Hi,
Can anyone tell me how to access the results from a select statement within the stored procedure?

This is to implement auditting functionality, before updating a record i want select the original record and compare the contents of each field with the varibles that are passed in, if the fields contents has changed i want to write an audit entry.

So i'd like to store the results of the select statement in a variable and access it like a dataset. e.g

declare selectResult

set selectResult = Select field1,field2,field3 from table1

if selectResult.field1 <> @.field1
begin
exec writeAudit @.var1,@.var2,var3
end

Many thanks.Cursors are the answer.|||Cursors are NEVER the answer...|||You can use the dreaded temp tables or move your inner proc to a function.


insert into #temp
exec mylovelyProc

I'd love to suggest tables vars but they don't work in this situation...grrr.|||Well if you are updating one record you can do something like so:


CREATE PROC DoSomething
@.UniqueID INT,
@.Value1 VARCHAR(10),
@.Value2 INT,
@.Value3 VARCHAR(100)
AS
DECLARE @.OldValue1 VARCHAR(10)
DECLARE @.OldValue2 INT
DECLARE @.OldValue3 VARCHAR(100)

SELECT @.OldValue1 = Table1.Value1, @.OldValue2 = Table1.Value2, @.OldValue3 = Table1.Value3 FROM Table1 WHERE Table1.IDField = @.UniqueID

IF @.OldValue1 <> @.Value1 OR @.OldValue2 <> @.Value2 OR @.OldValue3 <> @.Value3
EXEC writeAudit @.OldValue1, @.OldValue2, @.OldValue3


Tha's *one* way to do it. :)

Sunday, February 12, 2012

Accessing Oracle Stored procedures from SQL2K

I have created a linked Oracle server in my SQL2000 environment. I can execute queries just fine. eg select * from DEVX..SCHEMA.TABLE where DEVX is the name of the linked server. However, I cannot seem to execute a stored procedure that is resident on th
e Oracle server
The procedure is called XOKHOUS and the method is UPDADR. It takes a number of parameters and returns a 0 or 1 as a scalar value.
I've tried:
declare @.result int
set @.result=DEVX..XOKHOUS.UPDADR(@.param1,@.param2)
with no luck. Suggestions? Thanks.
> I have created a linked Oracle server in my SQL2000 environment.
> I can execute queries just fine. eg select * from DEVX..SCHEMA.TABLE
> where DEVX is the name of the linked server. However, I cannot seem
> to execute a stored procedure that is resident on the Oracle server
> The procedure is called XOKHOUS and the method is UPDADR. It
> takes a number of parameters and returns a 0 or 1 as a scalar value.
> I've tried:
> declare @.result int
> set @.result=DEVX..XOKHOUS.UPDADR(@.param1,@.param2)
>
> with no luck. Suggestions? Thanks.
>
You can use the OPENQUERY() command to call remote stored procedures. For
more information, please consult your SQL Server Books Online.
Hope this helps,
Eric Crdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.

Accessing Oracle Stored procedures from SQL2K

I have created a linked Oracle server in my SQL2000 environment. I can execu
te queries just fine. eg select * from DEVX..SCHEMA.TABLE where DEVX is the
name of the linked server. However, I cannot seem to execute a stored proce
dure that is resident on th
e Oracle server
The procedure is called XOKHOUS and the method is UPDADR. It takes a numbe
r of parameters and returns a 0 or 1 as a scalar value.
I've tried:
declare @.result int
set @.result=DEVX..XOKHOUS.UPDADR(@.param1,@.param2)
with no luck. Suggestions? Thanks.> I have created a linked Oracle server in my SQL2000 environment.
> I can execute queries just fine. eg select * from DEVX..SCHEMA.TABLE
> where DEVX is the name of the linked server. However, I cannot seem
> to execute a stored procedure that is resident on the Oracle server
> The procedure is called XOKHOUS and the method is UPDADR. It
> takes a number of parameters and returns a 0 or 1 as a scalar value.
> I've tried:
> declare @.result int
> set @.result=DEVX..XOKHOUS.UPDADR(@.param1,@.param2)
>
> with no luck. Suggestions? Thanks.
>
--
You can use the OPENQUERY() command to call remote stored procedures. For
more information, please consult your SQL Server Books Online.
Hope this helps,
Eric Crdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.

Accessing Oracle Stored procedures from SQL2K

I have created a linked Oracle server in my SQL2000 environment. I can execute queries just fine. eg select * from DEVX..SCHEMA.TABLE where DEVX is the name of the linked server. However, I cannot seem to execute a stored procedure that is resident on the Oracle serve
The procedure is called XOKHOUS and the method is UPDADR. It takes a number of parameters and returns a 0 or 1 as a scalar value
I've tried
declare @.result in
set @.result=DEVX..XOKHOUS.UPDADR(@.param1,@.param2
with no luck. Suggestions? Thanks> I have created a linked Oracle server in my SQL2000 environment.
> I can execute queries just fine. eg select * from DEVX..SCHEMA.TABLE
> where DEVX is the name of the linked server. However, I cannot seem
> to execute a stored procedure that is resident on the Oracle server
> The procedure is called XOKHOUS and the method is UPDADR. It
> takes a number of parameters and returns a 0 or 1 as a scalar value.
> I've tried:
> declare @.result int
> set @.result=DEVX..XOKHOUS.UPDADR(@.param1,@.param2)
>
> with no luck. Suggestions? Thanks.
>
--
You can use the OPENQUERY() command to call remote stored procedures. For
more information, please consult your SQL Server Books Online.
Hope this helps,
--
Eric Cárdenas
Senior support professional
This posting is provided "AS IS" with no warranties, and confers no rights.

Thursday, February 9, 2012

Accessing Null UDT's from TSQL

I created a UDT in C# that is working fine except when I request rows where the type is null.

If I use SELECT Film.ToString() FROM ImageData it works fine, or any property they return Null as expected

but if I use SELECT Film FROM ImageData it produces the error below

An error occurred while executing batch. Error message is: Data is Null. This method or property cannot be called on Null values.

I looked through all the examples in C# and my code matches the pattern for nulls exactly. Can anyone shead some light on what attribute I may have to add or method I should override which is not documented.

Could you please check the following topics in BOL?

http://msdn2.microsoft.com/es-es/library/ms131069.aspx

http://msdn2.microsoft.com/en-us/library/a8s4s5dz.aspx

When you query the column directly you should get either NULL for the NULL values or the binary representation of the UDT.

Can you check your code against the examples shown in the links above? There is a separate forum for SQL Server CLR that you can follow up also.

|||

This was a bugPlease see http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=125552

Cheers,