Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Tuesday, March 27, 2012

Cant get list of servers

I can't get my server to show with the DMO function ListAvailableSQLServers or with the osql -L flag. The OS is windows 2000, but the drive is fat32 and doesn't have Directory Service.
Do you need NTFS to have Directory Service, and does SQL Server need Directory Service to broadcast its available servers?
I've got Visual Studio .Net and had no luck when I searched for an answer.I meant Active Directory.|||no neither ADS nor NTFS is essential for server listing. r u able to connect to other servers using EM or QA? is EM showing the complete list? of not there could be issues with the broadcasting server. check if 1433 port is not blocked by any firewall programa at server end. also check that the server is not hidden by server network utility >> TCPIP >> hide server.|||It is actually MSDE, so I don't have EM or QA. But I have Visual Studio .Net and it has Server Explorer which functions much like EM and QA. The databases and programs I use to connect are on the same machine. I use this to learn/practice SQL Server. I don't have a machine with a server OS, so I can't check "proper" server operation.
But yes, Server Explorer connects and shows my SS instance. I can use osql, programs I create in VB.net, or even web pages scripted with ADO or DMO objects to connect and modify the SS databases, as long as I specify the server. The only thing I can't seem to do is get a list of the servers (I only have one server).
I have a software firewall, but only have it running while my dial-up is online.
Not sure what you mean by "server network utility >> TCPIP >> hide server". I have the server/client tools that were included (in the tools\binn folder); the program cnfgsvr.exe sounds like a good place to start. I'll check it out.
Thanks|||the server network utility i am referring to uses ...\bin\svrnetcn.exe (non-msde version). the exe u have identified may work as well, not sure. for same machine sql server uses shared-memory net lib. if TCPIP or Named Pipe is not enabled, i have seen that OSQL -L fails to identify local server...|||Yeah, that's the one,SVRNETCN.EXE, the Sql Server Network Utility. Both Tcp/Ip and Named Pipes protocols are enabled, the default port 1433 is set, and the Hide Server option is unchecked.
I forgot to mention that my MSDE was included free with my VS.Net. When I installed it, I chose all the defaults which gave my sql server an instance name of VSDOTNET. I don't know why it didn't just install with the default computername. Maybe that has something to do with it?
So I used the Sql Server Client Network Utility, CLICONFG.EXE, and created aliases, one for tcp/ip and one for named pipes. The aliases were listed properly with OSQL -L and using the DMO App.ListAvailableSQLServers() function. I don't know why computername\vsdotnet won't list without the aliases.

Can't get fn_get_sql to work

I can't seem to get the fn_get_sql function to work. Here's the script
I'm using:
declare @.spid int
DECLARE @.Handle binary(20)
declare active_spids cursor for select spid, sql_handle from
master..sysprocesses where status not in ('background', 'sleeping')
--and spid <> @.@.spid
open active_spids
fetch next from active_spids into @.spid, @.handle
while @.@.fetch_status = 0
begin
select @.spid as spid,@.handle as sql_handle
SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
@.spid
SELECT * FROM ::fn_get_sql(@.Handle)
fetch next from active_spids into @.spid, @.handle
end
close active_spids
deallocate active_spids
I never get any result set back from the function:
spid sql_handle
-- ---
166 0x01000600D8753C019840E79300000000000000
00
(1 row(s) affected)
dbid objectid number encrypted text






-- -- -- -- --
(0 row(s) affected)
spid sql_handle
-- ---
280 0x0100060099BF3103984033BA00000000000000
00
(1 row(s) affected)
dbid objectid number encrypted text






-- -- -- -- --
(0 row(s) affected)
Any help would be appreciated!I just tried it and verified your code.
It does not work for me either.
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
It was introduced in 8.00.652, and was publicly available in SP3. Are you
also using SP4?
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
<pshroads@.gmail.com> wrote in message
news:1118444562.461080.161880@.g47g2000cwa.googlegroups.com...
>I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E79300000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA00000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
>|||pshroads@.gmail.com wrote:
> I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E79300000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA00000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>

> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
Works for me with SP3a:
dbid objectid number encrypted text
NULL NULL NULL 0 declare @.spid int
DECLARE @.Handle binary(20)
David Gugick
Quest Software
www.imceda.com
www.quest.com|||It works on SP4.
Try enabling trace flag 2861. It will force SQL to keep zero-cost plans in
the cache. It may also grow your procedure cache and cause a whole lot of
other performance problems. See Q325607 for details.
If you are looking for ways to audit activity on your SQL Server you may
want to consider using dbcc inputbuffer instead of fn_get_sql.
Adrian
<pshroads@.gmail.com> wrote in message
news:1118444562.461080.161880@.g47g2000cwa.googlegroups.com...
>I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E79300000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA00000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
>

Can't get fn_get_sql to work

I can't seem to get the fn_get_sql function to work. Here's the script
I'm using:
declare @.spid int
DECLARE @.Handle binary(20)
declare active_spids cursor for select spid, sql_handle from
master..sysprocesses where status not in ('background', 'sleeping')
--and spid <> @.@.spid
open active_spids
fetch next from active_spids into @.spid, @.handle
while @.@.fetch_status = 0
begin
select @.spid as spid,@.handle as sql_handle
SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid = @.spid
SELECT * FROM ::fn_get_sql(@.Handle)
fetch next from active_spids into @.spid, @.handle
end
close active_spids
deallocate active_spids
I never get any result set back from the function:
spid sql_handle
-- ---
166 0x01000600D8753C019840E7930000000000000000
(1 row(s) affected)
dbid objectid number encrypted text
-- -- -- -- --
(0 row(s) affected)
spid sql_handle
-- ---
280 0x0100060099BF3103984033BA0000000000000000
(1 row(s) affected)
dbid objectid number encrypted text
-- -- -- -- --
(0 row(s) affected)
Any help would be appreciated!I just tried it and verified your code.
It does not work for me either.
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
It was introduced in 8.00.652, and was publicly available in SP3. Are you
also using SP4?
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
<pshroads@.gmail.com> wrote in message
news:1118444562.461080.161880@.g47g2000cwa.googlegroups.com...
>I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid => @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E7930000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA0000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
>|||pshroads@.gmail.com wrote:
> I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid => @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E7930000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA0000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
Works for me with SP3a:
dbid objectid number encrypted text
NULL NULL NULL 0 declare @.spid int
DECLARE @.Handle binary(20)
David Gugick
Quest Software
www.imceda.com
www.quest.com|||It works on SP4.
Try enabling trace flag 2861. It will force SQL to keep zero-cost plans in
the cache. It may also grow your procedure cache and cause a whole lot of
other performance problems. See Q325607 for details.
If you are looking for ways to audit activity on your SQL Server you may
want to consider using dbcc inputbuffer instead of fn_get_sql.
Adrian
<pshroads@.gmail.com> wrote in message
news:1118444562.461080.161880@.g47g2000cwa.googlegroups.com...
>I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid => @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E7930000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA0000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
>

Can't get fn_get_sql to work

I can't seem to get the fn_get_sql function to work. Here's the script
I'm using:
declare @.spid int
DECLARE @.Handle binary(20)
declare active_spids cursor for select spid, sql_handle from
master..sysprocesses where status not in ('background', 'sleeping')
--and spid <> @.@.spid
open active_spids
fetch next from active_spids into @.spid, @.handle
while @.@.fetch_status = 0
begin
select @.spid as spid,@.handle as sql_handle
SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
@.spid
SELECT * FROM ::fn_get_sql(@.Handle)
fetch next from active_spids into @.spid, @.handle
end
close active_spids
deallocate active_spids
I never get any result set back from the function:
spid sql_handle
-- ---
166 0x01000600D8753C019840E7930000000000000000
(1 row(s) affected)
dbid objectid number encrypted text


-- -- -- -- --
(0 row(s) affected)
spid sql_handle
-- ---
280 0x0100060099BF3103984033BA0000000000000000
(1 row(s) affected)
dbid objectid number encrypted text


-- -- -- -- --
(0 row(s) affected)
Any help would be appreciated!
I just tried it and verified your code.
It does not work for me either.
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
It was introduced in 8.00.652, and was publicly available in SP3. Are you
also using SP4?
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
<pshroads@.gmail.com> wrote in message
news:1118444562.461080.161880@.g47g2000cwa.googlegr oups.com...
>I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E7930000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA0000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
>
|||pshroads@.gmail.com wrote:
> I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E7930000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA0000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>

> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
Works for me with SP3a:
dbid objectid number encrypted text
NULL NULL NULL 0 declare @.spid int
DECLARE @.Handle binary(20)
David Gugick
Quest Software
www.imceda.com
www.quest.com
|||It works on SP4.
Try enabling trace flag 2861. It will force SQL to keep zero-cost plans in
the cache. It may also grow your procedure cache and cause a whole lot of
other performance problems. See Q325607 for details.
If you are looking for ways to audit activity on your SQL Server you may
want to consider using dbcc inputbuffer instead of fn_get_sql.
Adrian
<pshroads@.gmail.com> wrote in message
news:1118444562.461080.161880@.g47g2000cwa.googlegr oups.com...
>I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E7930000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA0000000000000000
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
>

Can't get fn_get_sql to work

I can't seem to get the fn_get_sql function to work. Here's the script
I'm using:
declare @.spid int
DECLARE @.Handle binary(20)
declare active_spids cursor for select spid, sql_handle from
master..sysprocesses where status not in ('background', 'sleeping')
--and spid <> @.@.spid
open active_spids
fetch next from active_spids into @.spid, @.handle
while @.@.fetch_status = 0
begin
select @.spid as spid,@.handle as sql_handle
SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
@.spid
SELECT * FROM ::fn_get_sql(@.Handle)
fetch next from active_spids into @.spid, @.handle
end
close active_spids
deallocate active_spids
I never get any result set back from the function:
spid sql_handle
-- ---
166 0x01000600D8753C019840E79300000000000000
00
(1 row(s) affected)
dbid objectid number encrypted text






-- -- -- -- --
(0 row(s) affected)
spid sql_handle
-- ---
280 0x0100060099BF3103984033BA00000000000000
00
(1 row(s) affected)
dbid objectid number encrypted text






-- -- -- -- --
(0 row(s) affected)
Any help would be appreciated!I just tried it and verified your code.
It does not work for me either.
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
It was introduced in 8.00.652, and was publicly available in SP3. Are you
also using SP4?
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
<pshroads@.gmail.com> wrote in message
news:1118444562.461080.161880@.g47g2000cwa.googlegroups.com...
>I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E79300000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA00000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
>|||pshroads@.gmail.com wrote:
> I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E79300000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA00000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>

> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
Works for me with SP3a:
dbid objectid number encrypted text
NULL NULL NULL 0 declare @.spid int
DECLARE @.Handle binary(20)
David Gugick
Quest Software
www.imceda.com
www.quest.com|||It works on SP4.
Try enabling trace flag 2861. It will force SQL to keep zero-cost plans in
the cache. It may also grow your procedure cache and cause a whole lot of
other performance problems. See Q325607 for details.
If you are looking for ways to audit activity on your SQL Server you may
want to consider using dbcc inputbuffer instead of fn_get_sql.
Adrian
<pshroads@.gmail.com> wrote in message
news:1118444562.461080.161880@.g47g2000cwa.googlegroups.com...
>I can't seem to get the fn_get_sql function to work. Here's the script
> I'm using:
> declare @.spid int
> DECLARE @.Handle binary(20)
> declare active_spids cursor for select spid, sql_handle from
> master..sysprocesses where status not in ('background', 'sleeping')
> --and spid <> @.@.spid
> open active_spids
> fetch next from active_spids into @.spid, @.handle
> while @.@.fetch_status = 0
> begin
> select @.spid as spid,@.handle as sql_handle
> SELECT @.Handle = sql_handle FROM master..sysprocesses WHERE spid =
> @.spid
> SELECT * FROM ::fn_get_sql(@.Handle)
> fetch next from active_spids into @.spid, @.handle
> end
> close active_spids
> deallocate active_spids
>
>
> I never get any result set back from the function:
>
> spid sql_handle
> -- ---
> 166 0x01000600D8753C019840E79300000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
> spid sql_handle
> -- ---
> 280 0x0100060099BF3103984033BA00000000000000
00
> (1 row(s) affected)
> dbid objectid number encrypted text
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> -- -- -- -- --
> (0 row(s) affected)
>
> Any help would be appreciated!
>sql

Cant get CAST function to work in ASP.NET

I'm trying to do something like this SQL statement. I have a table with a field of date/times.

i.e - 2/27/06 9:55:95 PM Basically there are multiple entries in the table per day.

I want to count the records for particular (hence the CAST) and output the count.

Here it was I had just to see if SQL would work in ASP.NET :

SELECT COUNT(*) AS Expr1
FROM dbo.tblActiveDrums
WHERE [CAST](FLOOR([CAST](NCTimeStamp AS [float])) AS datetime) = '0' OR
NCTimeStamp - [CAST](FLOOR([CAST](NCTimeStamp AS [float])) AS datetime) = '0'

It didn't like the AS references?

Any help would be appreciated.

Remove all the brackets and post if there are any error messages. Shouldn't be.|||You want to count the records for a particular what?

Monday, March 19, 2012

Can't Divide a count function?

I am trying to divide 2 funcitons by each other and I am coming back with 0 as my result in one of them while I am getting the correct answer in another. The two columns I am trying to pull with functions are:

SELECT

sum(D.PrincipalBal)/sum(L.PrincipalBal)*100 as DelqRatioByBal
, count(D.LoanID)/count(L.LoanID)*100 as DelqRatioByCnt

FROM Loan L

INNER JOIN DelqINFO D on D.LoanID = L.LoanID

I get the correct result back for 'DelqRatioByBal' but I get 0 back for 'DelqRatioByCnt'

Any suggestons?

that because you are doing an integer division

take a look at this

select 1/2 --int division
select (1.00*1)/2

go
--
SELECT

sum(D.PrincipalBal)/sum(L.PrincipalBal)*100 as DelqRatioByBal
, (1.00*count(D.LoanID))/count(L.LoanID)*100 as DelqRatioByCnt

--

any number multiplied by 1 = the number

|||Thanks Joey, worked well. I appreciate it.

Thursday, March 8, 2012

Can''t Create Recursive Function

Greetings.

I'm having trouble creating a recursive function in T-SQL (SQL Server 2000).

I've got a table that has an ID column and a ParentID column. Each row can have a value in the ParentID column that references the ID column of another record - I'll call such rows "child records". I'll cal the row referenced by the ParentID the "parent record".

Each child record can itself have another child record.

I need a function that will take an ID column value as a parameter, and walk up the chain of parent records until I get the first record in the series and return that record's ID value. I'll call that record the "UrParent record".

I'm trygin to create a recursive function called ufunc_ST_GetUrParentCertNum. In the function, there is of course a recursive call to itself - GetUrParentCertNum. However, when I try to run the CREATE FUNCTION script, I get the error:

Server: Msg 195, Level 15, State 10, Procedure ufunc_ST_GetUrParentCertNum, Line 26
'ufunc_ST_GetUrParentCertNum' is not a recognized function name.

I tried the same thing with a Stored Procedure, and that worked fine. However, I really want this to work as a function.

Does anyone have advice on how I can achieve this?

Thanks in advance.

- will f

Did you forget to put the schema name before the function name,

try to call your function like dbo.ufunc_ST_GetUrParentCertNum

|||

That did the trick exactly. Thank you very much Smile

- will f