Calander In SQLSERVER 2000(Using Function)
Mar 1, 2005I had built a one calander in SQLSERVER
View 1 RepliesI had built a one calander in SQLSERVER
View 1 RepliesWe have a static class that makes an HTTPWebRequest to get XML data from one of our vendors. We use this as input to a stored proc in SQLServer2005. When I compile this class and call it from a console application in visual studio it executes in milliseconds, everytime. When I compile it, create the assembly and clr function and execute it in SQLServer, it takes around 14 seconds to execute the first time, then on subsequent requests it is again really fast, until I wait for 10 seconds and re-execute, once again it is slow the first time and then fast on subsequent requests. We do not see this behavior when executing outside SQLServer. Makes me think that some sort of authentication is perhaps taking place the first time the function is run in SQLServer? I have no idea how to debug this further. Anyone seen this before or have any ideas?
Here is the class:
Code Snippet
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace Predict.Services
{
public static class Foo
{
public static string GetIntradayQuote(string symbol)
{
string returnQuote = "";
HttpWebRequest request = (HttpWebRequest)(WebRequest.Create("http://data.predict.com/predictws/detailed_quote.html?syms=" + symbol + "&fields=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,28,30"));
request.Timeout = 1000;
HttpWebResponse response = (HttpWebResponse)(request.GetResponse());
StreamReader streamReader = new StreamReader(response.GetResponseStream());
returnQuote = streamReader.ReadToEnd();
streamReader.Close();
response.Close();
return returnQuote;
}
}
}
When I run call it from a console app it is fine.
I compile it into a dll and then create the assembly and function as follows:
Code Snippet
drop function fnTestGetIntradayQuoteXML_SJS
go
drop assembly TestGetIntradayQuoteXML_SJS
go
create ASSEMBLY TestGetIntradayQuoteXML_SJS from 'c:DataBackupsCLRLibrariesTestGetIntradayQuote_SJS.dll' WITH PERMISSION_SET = EXTERNAL_ACCESS
go
CREATE FUNCTION fnTestGetIntradayQuoteXML_SJS(@SymbolList nvarchar(max)) RETURNS nvarchar(max) AS EXTERNAL NAME TestGetIntradayQuoteXML_SJS.[Predict.Services.Foo].GetIntraDayQuote
go
declare @testing nvarchar(max)
set @testing = dbo.fnTestGetIntradayQuoteXML_SJS('goog')
print @testing
When I execute the function as above, again, really slow the first time, then fast on subsequent calls. Could there be something wrong with the code, or some headers that need to be set differently to operate from the CLR in SQLServer?
Regards,
Skipper.
Binu submitted "I had created one calander in SQLSERVER using Functions.Function shows below.
the function execute in this way
SELECT * FROM calander(2,2002)
The OutPut is
SUN MON TUE WED THU FRI SAT
---- ---- ---- ---- ---- ---- ----
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28
(5 row(s) affected)
Copying this function and execute in Query Analyser.
Any month and any year will be passing this function which to get the above output.
CREATE function calander(@month int,@year int)
returns @DAY1 table(SUN char(3),MON Char(3),TUE Char(3),WED Char(3),THU Char(3),FRI Char(3),SAT Char(3))
as
begin
declare @i int
declare @j int
declare @intchk int
declare @dnum int
declare @curdate int
declare @month1 char(2)
declare @year1 char(4)
declare @date char(2)
declare @dtchk int
declare @dtval int
set @date='01'
set @month1=@month
set @year1=@year
set @dtchk=1
set @i=1
set @j=1
declare @DAY2 table(SUN char(3) default '',MON Char(3)default '',TUE Char(3)default '',WED Char(3)default '',THU Char(3)default '',FRI Char(3)default '',SAT Char(3)default '')
SELECT @curdate=DATEPART(dw, CONVERT(DATETIME,@date+'-'+@month1+'-'+@year1,103))
select @dnum=datediff(dd,convert(datetime,@date+'-'+@month1+'-'+@year1,103),dateadd(mm,1,convert(datetime,@date+'-'+@month1+'-'+@year1,103)))
while @j<=7
begin
if @curdate=@j
begin
if @j=1
begin
INSERT INTO @DAY2(sun)VALUES(@i)
set @intchk=1
set @dtchk=1
end
else if @j=2
begin
INSERT INTO @DAY2(MON)VALUES(@i)
set @intchk=2
set @dtchk=1
end
else if @j=3
begin
INSERT INTO @DAY2(TUE)VALUES(@i)
set @intchk=3
set @dtchk=1
end
else if @j=4
begin
INSERT INTO @DAY2(WED)VALUES(@i)
set @intchk=4
set @dtchk=1
end
else if @j=5
begin
INSERT INTO @DAY2(THU)VALUES(@i)
set @intchk=5
set @dtchk=1
end
else if @j=6
begin
INSERT INTO @DAY2(FRI)VALUES(@i)
set @intchk=6
set @dtchk=1
end
else if @j=7
begin
INSERT INTO @DAY2(SAT)VALUES(@i)
set @intchk=7
set @dtchk=1
end
end
set @j=@j+1
end
if @intchk=1
begin
update @day2 set mon=@i+1,tue=@i+2,wed=@i+3,thu=@i+4,fri=@i+5,sat=@i+6 where sun=1
set @dtchk=@dtchk+6
end
else if @intchk=2
begin
update @day2 set tue=@i+1,wed=@i+2,thu=@i+3,fri=@i+4,sat=@i+5 where mon=1
set @dtchk=@dtchk+5
end
else if @intchk=3
begin
update @day2 set wed=@i+1,thu=@i+2,fri=@i+3,sat=@i+4 where tue=1
set @dtchk=@dtchk+4
end
else if @intchk=4
begin
update @day2 set thu=@i+1,fri=@i+2,sat=@i+3 where wed=1
set @dtchk=@dtchk+3
end
else if @intchk=5
begin
update @day2 set fri=@i+1,sat=@i+2 where thu=1
set @dtchk=@dtchk+2
end
else if @intchk=6
begin
update @day2 set sat=@i+1 where fri=1
set @dtchk=@dtchk+1
end
else if @intchk=7
begin
Set @dtchk=@dtchk
end
insert into @day2(sun)values(@dtchk+1)
set @dtchk=@dtchk+1
if @intchk=1
begin
update @day2 set mon=@i+8,tue=@i+9,wed=@i+10,thu=@i+11,fri=@i+12,sat=@i+13 where sun=@dtchk
set @dtchk=@dtchk+6
end
else if @intchk=2
begin
update @day2 set mon=@i+7,tue=@i+8,wed=@i+9,thu=@i+10,fri=@i+11,sat=@i+12 where sun=@dtchk
set @dtchk=@dtchk+6
end
else if @intchk=3
begin
update @day2 set mon=@i+6,tue=@i+7,wed=@i+8,thu=@i+9,fri=@i+10,sat=@i+11 where sun=@dtchk
set @dtchk=@dtchk+6
end
else if @intchk=4
begin
update @day2 set mon=@i+5,tue=@i+6,wed=@i+7,thu=@i+8,fri=@i+9,sat=@i+10 where sun=@dtchk
set @dtchk=@dtchk+6
end
else if @in
Hi experts;
I have a problem with unicode character 0x2300
I created this table
create table testunicode (Bez nchar(128))
Insert Data
insert into testunicode (Bez)values('Œ€„¢')
with 2 Unicode characters
Œ€ = 0x2300
„¢ = 0x2122
Selecting the data
select Bez from testunicode
I see
"?„¢"
„¢ = 0x2122 is ok but instead of 0x2300 there is 0x3f
When I modify the insert statement like that ( 8960 = 0x2300 )
insert into testunicode (Bez)values(NCHAR(8960)+'„¢')
and select again voila i see
"Œ€„¢"
Does anyone have an idea?
Thanks
I am trying to 'load' a copy of a SQLServer 2000 database to SQLServer 2005 Express (on another host). The copy was provided by someone else - it came to me as a MDF file only, no LDF file.
I have tried to Attach the database and it fails with a failure to load the LDF. Is there any way to bypass this issue without the LDF or do I have to have that?
The provider of the database says I can create a new database and just point to the MDF as the data source but I can't seem to find a way to do that? I am using SQL Server Management Studio Express.
Thanks!!
I have an app that uses a sqlserver 2000 jdbc driver to connect to a sqlserver 2000.
Is it possible to do a direct replacement of sqlserver 2000 with sqlserver 2005 express just by reconfiguring the app to point to the express? The app would still be using the sqlserver 2000 jdbc driver to try and make the connection.
If that is a possibility, what can be some differences in the configuration? Previously with 2000 the config information I entered is:
server name: "machinename"( or ip). I've also tried "machiname/SQLEXPRESS"
DB name: name of db instance
port: 1433(default)
user and pass.
My attempts so far results in
"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket."
and
"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL."
Hi Friends,
Can some please let me know the differences between sqlserver 2000 and sqlserver 7.0
Thanks in advance. What is maximum SQL Server database (*.mdf) file size with SQL Server 2000 as part of Microsoft Small Business Server 2000? (Database files were limited to 10 GB in SBS 4.5 with SQLServer 7.0... has this changed?).
View 1 Replies View RelatedHi, I wanted to see what are all the users in a windows nt group that has a group access to sql server 2000. I have a windows 2000 group access to sqlserver 2000 as "xxxsomegroup". How can I list all users that belongs to this windows 200 group? is there any stored procedure to find out this?
any information could be greatly appreciated.
thanks
I recently had to reinstall a new instance of SQLServer 2000, but was unable to use the previous server name. As a result, my Access2000 front end is not happy with it's linked tables. I can't seem to find anyplace within Access to universally change the address of the SQLServer used as the back-end for all linked tables.
When I do try to access the linked tables through Access, I get an error, and the option to change the server location. When I try to type-in the new SQLServer location, there is an attempt to reconnect to SQLServer, but a whole lot of errors are generated, and none of the data is transferred into the Access table.
I really don't want to have to re-do my Access front end, so it seems it would be easiest to somehow reinstall SQLServer to have the same server location it used to. Is there a good way to completely erase all traces of SQLServer so that I can have better luck reinstalling it to the same location it used to be in? Just using the uninstall program from SQLServer doesn't seem to be cutting it.
Thanks!
When I try to make a connection to an Access .mdb I get the following error:
"Unable to open application. The workgroup information file is missing or opened exclusively by another user"
Yet, I am able to open the file through Access and have necessary permissions and I know no one else has it opened. The mdb is password protected and I have provided the correct login information in the DTS connection.
Hi guys,
I have a performance related question about the DTS package in sqlserver 2000 which i have developed
We have developed a DTS package which will migrate a view 'ATTRITION' from Sqlserver 2000 to an Oracle database.The design of the package is as follows
First step: It checks for the existance of the table 'ATTRITION' in oracle database, if table 'ATTRITION' is not there it will create a table called 'ATTRITION' in the oracle db.If the table 'ATTRITION' is already present in the oracle db,then the table is truncated.
Second step: The view 'ATTRITION' is migrated to Oracle table 'ATTRITION'.
For the migration, i have used a connection object which connects to sqlserver 2000 and for oracle connection i have used another connection object 'Microsoft ODBC driver for oracle' and i have joined both the connection objects with 'Transform data task' task which maps one to one from sqlserver 2000 where view 'ATTRITION' exists with oracle database where Table 'ATTRITION' exists.
Roughly i have around 65000 rows in 'ATTRITION' view of sqlserver 2000 which needs to be migrated.When im running the package on my system it takes around 4 minutes to migrate all the rows but when im running it on the server it takes a lot lot of time more than 1 hour.
The view definition im using has more than 10 tables joined together.But if its a problem of query used in the view,and if i run the view seperately it quickly displays the data hardly takes 1 minute. and even if i run the package on my local pc it doenst take much time.Now my confusion is why its taking soo much time on server.If i create a indexed view then will it solve my problem.Please suggest...
Thanks in advance
REgards
Arvind L
Hi
My question is about the INSTR function of MSAccess
I want to know
Goodbye at every
I would you like to know if in TransactSQL of SQLServer7 exist a function that return the position of a string into an other string .
that is a Instr function MSAccess like
INSTR([Start,]expression1,expression2[,Comparison])
I'm sorry for my bad English
Thank you for everything
Emiliano
Hi I need a function which gets 3 parameters and input and returns 4 integers as output.
I don't know how to return 4 integers as output
any idea is appreciated.
Hi ,
I 'm working with visual studio 2005 and I have created an SQLServer Project.
I'm using the CLR functionality which comes with SQLserver 2005. This means that I can write VB.nEt code and use it inside Sqlserver 2005.So far so good.
I am now inside the .NET
I have created a Function(must remind you that I have created an SQLserver Project) which takes two string arguments. The date value in a string format and the string format.
In Our case the function returns a string.It will return a datetime although.
So we have
Dim Datetime_Val As DateTime = Nothing
Dim Date_Val As Date = Nothing
Dim StrTemp As String = ""
Dim StrDateTemp As String = Nothing
Dim StrTimeTemp As String = Nothing
Dim ls_return As String = Nothing
Dim lindexof As Integer
Dim Counter As Integer = 0
lindexof = 0
Select Case StrFormat
Case "DD-MM-YYYY HH24:MIS"
For Counter = 1 To 2
lindexof = StrDate.IndexOf("-", lindexof + 1)
Next
lindexof += 5
StrDateTemp = StrDate.Substring(0, lindexof).Trim
StrTimeTemp = StrDate.Substring(StrDateTemp.Length, StrDate.Length - StrDateTemp.Length).Trim
ls_return = StrDateTemp & " " & StrTimeTemp
End Select
The above is a simple code. As you can see I'm trying to convert the TO_DATE function ,which work with ORACLE, to make it work with SQLServer 2005.
I've been trying unsuccessfully to combine the variables StrDateTemp and StrTimeTemp into a datetime value. I used the following code but nothing
Datetime_Val = CDate(StrDateTemp & " " & StrTimeTemp)
Didn't work
Datetime_Val = Convert.ToDateTime(StrDateTemp & " " & StrTimeTemp)
Didn't work
Datetime_Val = DateTime.Parse(StrDateTemp & " " & StrTimeTemp)
Didn't work
Inside SQlServer I used this SQL statement
Select dbo.TO_DATE('31-12-1990 00:26:46','DD-MM-YYYY HH24:MIS')
But I am receiveing an error. I want to avoid changing all of my applications with a specific format.This sql statement without the dbo prefix I'm using in Oracle. I want to keep the format of the SQL and let VB.NET do the parsing for me. It is easier for me to put in my SQLs the dbo infront rather changing the complete SQL.
I have two questions . How am I going to create a TO_DATE function which Oracle uses and write something similar in SQLserver ?
And If I cannot do that how am I going to get the database 's datetime format and create with VB.NET the Datetime value from the two variables ?
My problem I believe is quite complex. I would be mostly appreciated if you could help me on this.
Thank you
i have a quite strange condition...when i add some value in database with getdate() function it only returns date and minute not the seconds...does somebody have an experience about this
View 3 Replies View RelatedI use a database that has user names stored in Encrypted format usingthe following API.Declare Sub Encrypt2 Lib "QPRO32.DLL" (ByVal Work As String, ByValPASSWORD As String)Every time i require the user name i have to again decrypt the nameusing the same function.My problem is that when i fetch a large number of records i have toloop through every record and call the encrypt function for eachrecord.Instead of binding the recordset to my control i need to loopthrough and fill my controlA MSHFlexGrid in Vb6.0.Is there a way out to this problem that will make my record populatiogfaster withoutout changing the current Encrypted users.Thanx in Advance
View 2 Replies View Relatedhi friends, i want to convert the Xml file
from D: emp est.xml to Master Database in sql server2000 using Coding
in c#. Please do needful-subashini
biju writes "hii...
i need 2 study sql server 2000 alone...4 that i need tutorials...pls proivide the required details
with regds"
hey ppl, if there is any1 that can help me here i would apreciateerror line(probably)Comando = New SqlCommand("INSERT INTO Table1(name) VALUES('a')", Conexao)on Table1 i have those fieldsid(int, identity) e name(text)but when i execute this code i get the following error:Error on the XML processing: no element found(ps. the error wasnt on english so i made a poor translation but i think u can have a general ideia)(the error message untranslated)Erro no processamento de XML: nenhum elemento encontradoPosição: http://localhost/teste.aspxNúmero da linha 1, Coluna 1:anyway, the wierd part is that on the sqlserver the data is insertted normally.. so.. what is that error??any1 pls help me! im going nuts (ps. im still noob on asp.net/sqlserver so please be gentle ^.^)(ps2. sorry for the crap english but it isnt my native language :) )
View 3 Replies View RelatedMy company has a site license with Microsoft to purchase software. For
SQLServer 2000 they receive a 'MASTER' CD of which they 'burn' copies
for the departments that request it. I requested the manuals that
come with the product and was told that the manuals are now on the 'CD'.
I want to purchase the 'microsoft' manuals that come with the product.
Has anyone ordered sqlserver 2000 and received manuals?
thanks in advance.
Transact-sql debugger comes with sqlserver 2000. I checked my server and
all the dll;s are loaded correctly, sqldbreg process is running. I also configured the client correctly.
How do I invoke this debugger? Which settings you change to get to the toolbar for the debugger in query anayl..
Running sqlserver 2000 on a w2k server with 1gb of memory. After a reboot the memory usage is around 500m but quickly climbs. At 1 point it was up to 1.5gb so it must have been swapping. Are there any good docs about this or any recommendations on how to limit sqlserver from using all the memory. It is the only application on the server so it isn't affecting anything else so maybe it isn't a problem. I just wanted to get people's inpit on this.
View 2 Replies View RelatedHello
If i have a select query and i need to get it result by paging(for example from row x to row y ) without using cursor .
Is there any way to do it ?
Nb : like ROW_NUMBER in SqlServer 2005 and ROWNUM oracle.
Hi all,
We do our development in SQLServer 2005. We want to backup and restore our database into the client's side who use SQLServer 2000. Backup and restore cannot work. We try to script the database in 2005 and change the option script to 2000. This fails also. What other option I can use?
Regards
I'm updating my local database installation using my netowrk login asthe id under which SQLServer is being update (Administrator on theoperating system and SA role on the database server itself).Has anyone encountered any problems and what is the work-around?
View 1 Replies View Relatedi installed the Visual Studio 2004+ Framework.NET 2
and SQLserver 2005
after those
i installed SQLserver 2000
and i got this :
http://img240.imageshack.us/img240/7392/sql2fk.jpg
thank you
One of our Server which is running SQLServer 2000 SP4 has blocking and when I checked several of spid were blocked by "-2" id and obviously I could not find any spid with -2.
Anyone has any idea about it?
Thanks
--
Farhan
Hello
After installing Sql server 2000 STD Sp1 on a server with Windows 2003 server, i have upgrade my Sql server to Sp4.
All the setup has been terminated without errors, but if i execute on Q.Analyser : "Select @@version" on the end of line of my query result , i have ....(Service Pack 1)
I don´t know , if effectively the upgrade has been terminated with sucess.I try to restart my server several time , but the result of my query is always the same "....(Service Pack 1)"
Also, on my firewall server , i ´am create an UDP port 1434, because my ODBC client machine was enable to connect to my server.
Could you give me an explanation about, this question, and if i really done the upgrade to my sqlserver.
Many Thanks
Luis
exec msdb.dbo.sp_help_job @job_name = 'job_name', @job_aspect='JOB'
I've been reading a lot of stuff about this lately, i've tried severals solutions but none worked.
The case is pretty much standard: from query analyzer/any other software it works if i execute it by hand. From my piece of software it fails miserably (managed code, .NET 2.0) with "A severe error occurred on the current command. The results, if any, should be discarded."
Here is the call stack:
Stack : at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.SetMetaData(_SqlMetaDataSet metaData, Boolean moreInfo)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at <my code which checks the status of the stored procedure is listed here>
The point is that if the SQL user is made sysadmin it works. As I understood from the "Books online" the SQL Server agent uses the account specified using xp_sqlagent_proxy_account when executing jobs or commands for users who are not members of the sysadmin fixed server role.
I tried that too, the xp_sqlagent_proxy_account didnt print out any error, and "exec master.dbo.xp_sqlagent_proxy_account N'GET' "returned no records. Obviously the execution of "sp_help_job" still fails with the above exception.
How can I run "sp_help_job" with an user which is not part of the sysadmin role?
Hello
If i have a select query and i need to get it result by paging(for example from row x to row y ) without using cursor .
Is there any way to do it ?
Nb : Maybe like ROW_NUMBER in SqlServer 2005 and ROWNUM in oracle.
Hi,
I want to know major functionalites differences between Sql server 2000 and 20005..Am expection ans as soon as possible
With Best Regards
C.Rajesh
Hello
i have one prob . i m using sql server 2000 . and i have write a store procedure to fetch data from multiple table using cursor . this query exculate in sql server . but i can't fetch this data from in our page . how to fetch data from using multiple table .plz help
thnx