Retreive Records From Sqlserver

Oct 16, 2006

hey guys, i getting a minor problem here. Hope u guys may help me =)
 
I would like to count all the records from a table ' member ' and store the value inside a variable ' iCnt '
 i wrote like tis:
cmd.commandtext = " select count(*) as total from member" 
dim iCnt = cmd.ExecuteScalar
 
Hmm.. I am wondering whether my code is correct, it seem like cant work =(
Any help is appreciated, thanks u guys. 

View 1 Replies


ADVERTISEMENT

How To Retreive Data From Excel Into SQLSERVER Database Table

Oct 6, 2007

Hi friends,
I need to retreive data from Excel into SQLSERVER database table
give me reply asap.
Thanks in advance...

View 4 Replies View Related

How To Retreive Data From Nvarchar(max) Column, Using Com.microsoft.sqlserver.jdbc.SQLServerDriver?

Dec 31, 2007

I've looked through msdn and found an example, but it doesn't work. The problem is that when i use such construction

ResultSet rs1 = stmt.executeQuery("SELECT TOP 1 * FROM sys.check_constraints");
rs1.next();
Reader reader = rs1.getCharacterStream(17);

reader is set to null,but it mustn't be null cause i see some data through management studio in 17th column of sys.check_constraints table.

View 3 Replies View Related

Save Excel Records Into SQlserver

Aug 30, 2006

anybody give example code for save Excel records into sqlserver in asp.net1.1 Thanks

View 1 Replies View Related

Auto Deletion Of Records Sqlserver

Aug 18, 2007

 Hi I am not sure if I am at right place, anyhow I hope I am :) Now the question: I am using an ASP.net Application with SQL-Server. I want to make a page so that it set the expiration time (date)  for certain record and once that time reaches, it deletes those records, or make any updates to the record (what ever applicable). I also want to control this auto deletion from my application, means that turn this On/Off whenever needed. I am not sure how to start this. I was told by a friend that I need to use triggers from SQL-server but I need some help. Can anyone help me out on this? RegardsMykhan 

View 1 Replies View Related

How To Retrieve The Last 5 Records From A SqlServer Table ?

Nov 28, 2007

I want to write a sql Query which retrieves the last (some number ) records form a Table ,
the table specification is like :

Table1
==================================
ID int , <----- is identity And identity seed =1
Title char(50) ,
News nvarchar(100)


its like I want to get the last 5 news form DB ...

View 5 Replies View Related

How To Update Or Delete Records With A SqlServer Destination

Jan 11, 2006

I'm a novice to SSIS (and we've never used DTS).

Writing a Control flow that inserts records worked fine, using lookups and all, but i can't find somewhere an example on how to update records of even delete records.

Any suggestions ....

Thx

Harry Leboeuf

View 8 Replies View Related

Maximum Number Of Records Per Second That Can Be Inserted Into SQLServer 2000.

Apr 7, 2006

Summary: Maximum number of records per second that can be inserted intoSQLServer 2000.I am trying to insert hundreds (preferably even thousands) of recordsper second in to SQLServer table (see below) but I am getting thefollowing error in the Windows Event Viewer Application log file:"Insufficent Memory......"And very few records were inserted and no errors where sent back viathe JDBC.By removing the indexes on the table we have stopped getting the errormessage and have managed to load the table at 300 records per second.However I have couple of questions:1) Are the indexes definitely to blame for this error and is thereanyway of getting around this problem i.e. keeping the indexes in placewhen inserting?2) How should I configure SQLServer to maximise the speed ofinserts?3) What is the limiting factor for inserting into SQLServer?4) Does anyone know of any metrics for inserting records? At wantpoint should we consider load balancing across DBs.I currently populate 1.6 million records into this table. Once againthanks for the help!!CREATE TABLE [result] ([id] numeric(20,0) NOT NULL,[iid] numeric(20,0) NOT NULL,[sid] numeric(20,0) NOT NULL,[pn] varchar(30) NOT NULL,[tid] numeric(20,0) NOT NULL,[stid] numeric(6,0) NOT NULL,[cid] numeric(20,0) NOT NULL,[start] datetime NOT NULL,[ec] numeric(5,0) NOT NULL,)GOCREATE INDEX [ix_resultstart]ON [dbo].[result]([start])GOCREATE INDEX [indx_result_1]ON [dbo].[result]([id], [sid], [start], [ec])GOCREATE INDEX [indx_result_3]ON [dbo].[result]([id], [sid], [stid], [start])GOCREATE INDEX [indx_result_2]ON [dbo].[result]([id], [sid], [start])GO

View 5 Replies View Related

How Do I Retreive Id Of Just Inserted Row?

Nov 3, 2007

I'm creating a web application that has user input on 3 seperate pages. Each page prompts the user for specific information and at the bottom of the page the user will click on the "Submit" button to post the info from the form to the database table.
Once the user has submitted the first page of information how do I retrieve the ID from the CustID column of that row so I can use the Update function to add additional info to that row when the user clicks on the submit button on page 2 & 3. I don't want to hold all the information in variables until the end in case they bail out of the form.
TIA
Steve

View 7 Replies View Related

Update Field Without Retreive

Jan 24, 2007

if a db field "mynum" of type int contains for example the number 543.Is there a way I can update this field without first selecting the value?so for example set the the current value to +1
 

View 1 Replies View Related

Retreive Only Part Of The Query?

Sep 16, 2004

Is there a chance to retreive let's say rows positioned from 30-70 if a query produced result that contains 100 rows?

View 3 Replies View Related

Retreive A Table-Urgent

Mar 30, 2001

Hi,Is it possible to retrieve a single table from a backup in SQL 7.0?
TIA
Jay

View 1 Replies View Related

How Do I Retreive 0 For Null Value In A Query

Nov 22, 2005

How do i retrieve 0 for null value in the following query

select customerid, count(*) from calls_new_today c, customerdnis cd where c.cpn=cd.dnis and cd.enddate is null
group by customerid
order by customerid


what i mean is when count(*) = 0 no value is returned i want a Zero in the output how do i get it?

View 7 Replies View Related

Retreive The Middle Of A String

Apr 5, 2007

Im having a dumb moment... what is the easiest way to get the third and fourth character of a string???

Thanks :)

View 7 Replies View Related

Any Alternative Way To Retreive Data

May 19, 2004

Hi: Guys
Given the table below I want a select query that returns the AccountRepID with the largest single sale for each RegionID. In the event of a tie choose any single top AccountRepID to return.

CREATE TABLE [Sales] (
[SalesID] [int] IDENTITY (1, 1) NOT NULL ,
RegionID] [int],
[AccountRepID] [int],
[SalesAmount] [money]
)

If the data were
salesid,regionid,accountrepid,salesamount
1,101,31,$50
2,101,32,$25
3,102,31,$25
4,102,32,$25
5,102,31,$15

The query should return
regionid,accountrepid
101,31
102,31 or 102,32


Is there another way to get the data other than the following query:

select regionID,accountrepid FROM Sales
where salesamount in
(select max(salesamount) FROM Sales group by regionid)

Thanks

View 2 Replies View Related

Want To Retreive Update Row In Table

May 10, 2007

i want to insert a row from t1 to t2 if any of the row is updated in the t1. say if Nth row is updated then the values of the row should be inserted into t2. inside the trigger i need to retrieve the row which is updated, how to do it? any specific global variable like @@identity is there for updation?

View 6 Replies View Related

Pb To Retreive Max Value With Aggregate Subquery

Jul 20, 2005

I would like to know which products are my best sells by sellers, but iwould like to retreive this info by product id, seller id and the totalamount of sells for this product.My Sells table is :Seller_idProduct_idTotaldate_s1 2 1020/05/042 4 1512/05/043 5 2206/06/041 5 1807/06/044 8 1213/05/047 2 1119/05/043 4 1421/05/042 4 1418/05/041 5 1817/06/042 5 5008/05/04etc....I know how to retreive the total sells by product id and seller idSELECT Seller_id, Product_id, SUM(Total) AS totalFROM SellsWHERE date_s > '01/05/04'GROUP BY Seller_id,Product_id order by Seller_idSeller_idProduct_idTotal1 5 361 2 102 5 502 4 293 5 223 4 14I would like retreive only the max of total, and the Seller id andproduct id, like this :Seller_idProduct_idTotal1 5 362 5 503 5 22How can i do without using a temp table ?Thanks for your help.

View 3 Replies View Related

Retreive Password From Application

Apr 15, 2008



Hello Everyody,

Some background: I have a SQL server 2000 server that I just restored from backup after complete OS reinstallation. I have retored all databases (except the master) and I still have the mdf and ldf file from before reinstallation (master.mdf as well).

Now my problem is that I have 1 application that use a specific SQL user with a password that the application choose itself and of course this application doesn't work anymore because I didn't restore the sql users (I use windows authentification as much as possible). I cannot do anything to the application to use another password but I know the login used.

My questions is "How to I recover the password?". Is there a way to log the password that this application send to sql or from the old master.mdf file?

Any help would be greatly appreciated.

Bruno.

View 7 Replies View Related

How To Retreive A Row From A Datatable Based On Row Id

Mar 14, 2008



hi,
can anyone tell me how to retreive a row from a table using rowid (For example i want to retreive fifth row from a table)

View 3 Replies View Related

How To Upload Images To SQL2005 (using C#) And Retreive Them

Sep 13, 2007

Hi guys,    I'm creating a webSite and i'd like to save images to my db. I've been using fileUpload to get the image i want to store, but i can't get it right! After "mastering" the storage of my images , i'd like to be able to retrieve them. I allready have SPs created for both storage & retrieval of images!Can anyone help me please? Thanks,superJB

View 3 Replies View Related

Query To Retreive User Tables In Sql Db

Jan 2, 2004

Is there a way to create a query that will return all user tables inside a sql db

Thanx

View 4 Replies View Related

Send Mail Can Retreive Log File

Apr 1, 2008

I have developed a SSIS package on my local box and everything worked fine until I moved it to the production server. I have a Send Mail Task that is triggered by any of the other processes when they fail. It sends an email to the Admin with the current log file. My issue is that when it attempts to grab the log file (as an attachment) it fails with the following error message:

OnError,BILBO,UMIALIKJamesT,Email George,{a73bfc5c-d68e-426a-98ad-55e701670470},{677B8238-8697-454F-8F8A-DD6378E93455},4/1/2008 10:25:28 AM,4/1/2008 10:25:28 AM,-1073573429,0x,Either the file "D:SQL200590DTSPackagesPPROutputoutput.txt" does not exist or you do not have permissions to access the file.


It certainly exists and I've open all permissions up on the folder. What I find even more interesting is that the Package is just a single directory up from the Output file. The Package resides at D:SQL200590DTSPackagesPPR and is run via a batch file. It seems to me that it should have no issue grabbing this file and sending it, and when I don't attach the file it sends just fine.

Thank you in advance. If you need anymore information just let me know and I'll dig it up.

Peace,
James

View 6 Replies View Related

Way To Retreive Database Role Permissions

Mar 13, 2008



I want to allow administrators of the program to change the permissions of the database roles. Is there a way to retreive the the specific permissions granted an denyed to a user and a database role. For instance, a store procedure that you call, pass it the database role and you get whether SELECT is allowed on table1, or if UPDATE is denied on table2, etc.

View 3 Replies View Related

Retreive @@Identity From Stored Proc Call

May 3, 2007

Hi all, I've been struggling with this one for a while, but am still doing something wrong: I have three tables which need to be updated. I have a stored proc which accomplishes the first writes the data in for the first 2 tables. The last table is a one to many, so needs a seperate stored proc which will be called multiple times depending on the number of items in the order.  My only question I am trying to get to here is: How do I get the first stored proc to return me the primary key value from the 1st insert (NOT the second)? I've tried a few different methods: the current one shown below returns me  "2", as in the number of inserts performed.   Dim InsertCmd As New SqlCommand("WriteOrder", oSQLConn)
InsertCmd.CommandType = CommandType.StoredProcedure
InsertCmd.Parameters.AddWithValue("@CartTotal", Session("CartTotal"))
InsertCmd.Parameters.AddWithValue("@CARDFNAME", BillingInfo("CARDFNAME"))
InsertCmd.Parameters.AddWithValue("@CARDLNAME", BillingInfo("CARDLNAME"))
...
InsertCmd.Parameters.AddWithValue("@CONTACTEMAIL", BillingInfo("CONTACTEMAIL"))
InsertCmd.Parameters.AddWithValue("@COMPANYMATCH", 0)
InsertCmd.Parameters.AddWithValue("@RECNUM", 0)
Response.Write("---" & InsertCmd.ExecuteNonQuery().ToString() & "---")


---------------------STORED PROC---------------------

ALTER PROCEDURE [dbo].[WriteOrder]
@CartTotal float,
@CARDFNAME varchar(30),
...
@CONTACTEMAIL varchar(100),
@COMPANYMATCH bit,
@RecNum int = 0 OUTPUT
AS

INSERT INTO [dbo].[ORDER]
([OrderDate], [OrderTotal], [CARDFIRSTNAME], [CARDLASTNAME], [BILLINGADDR1], [BILLINGADDR2], [BILLINGADDR3], [BILLINGCITY], [BILLINGSTATE], [BILLINGPOSTALCODE], [BILLINGCOUNTRY], [BILLINGPHONE], [BILLINGEMAIL], [CCTYPE], [ACCOUNTNUMBER], [CARDEXPIREMONTH], [CARDEXPIREYEAR], [CVV2], [TransactionID], [TransDateStamp], [ProcessorAuthCode])

VALUES
(GetDate() ,@CartTotal , @CARDFNAME, @CARDLNAME, @BILLINGADDRESS1, @BILLINGADDRESS2, @BILLINGADDRESS3, @BILLINGCITY, @BILLINGSTATE, @BILLINGPOSTALCODE, @BILLINGCOUNTRY, @BILLINGPHONE, @BILLINGEMAIL, @CCTYPE, @ACCOUNTNUMBER, @EXPIRATIONMONTH, @EXPIRATIONYEAR, @CVV2,@TransactionID, @TransDateStamp,@ProcessorAuthCode)

SET @RecNum = @@IDENTITY

INSERT INTO [dbo].[CONTACT]
([ORDERID], [CONTACTFNAME], [CONTACTLNAME], [CONTACTADDRESS1], [CONTACTADDRESS2], [CONTACTADDRESS3],
[CONTACTCITY], [CONTACTSTATE], [CONTACTPOSTALCODE], [CONTACTCOUNTRY], [CONTACTPHONE], [CONTACTEMAIL], [COMPANYMATCH])
VALUES
(@@IDENTITY , @CONTACTFNAME, @CONTACTLNAME, @CONTACTADDRESS1, @CONTACTADDRESS2, @CONTACTADDRESS3, @CONTACTCITY, @CONTACTSTATE, @CONTACTPOSTALCODE, @CONTACTCOUNTRY, @CONTACTPHONE, @CONTACTEMAIL, @COMPANYMATCH)
RETURN @RecNum
GO

 I've also tried returning parameters like this, with no luck:        InsertCmd.Parameters(32).SqlDbType = SqlDbType.Int        InsertCmd.Parameters(32).Direction = ParameterDirection.ReturnValue        Response.Write("---" & InsertCmd.Parameters(32).Value() & "---")Any help is greatly appreciated! 

View 4 Replies View Related

SQLDataSource - How To Retreive The New GUID Value Of A New Inserted Record?

Jan 28, 2008

I am using ASP.NET 3.5 with SQLDataSource, when a record is inserted is there a way to retreive the newly created GUID value in a field?
I am currently using SELECT @NewID = SCOPE_IDENTITY() to retreive the newly created record unique ID field, but I need the secondary field GUID field's value instead in this case.
Thank you.

View 7 Replies View Related

SQLDataSource - How To Retreive The SQL Select Statement With The Values Of The Parameters

May 1, 2007

Is there a way to retreive the SQL Statement with the values from the parameters merged together? I know how to retreive the SQL Select Statement and the parameters separately but I need to retreive the final SQL.
For example:
SELECT name FROM employee WHERE id = @id
I would like to retreive from SQLDataSource
SELECT name FROM employee WHERE id = 1
 
Thank you

View 4 Replies View Related

How To Retreive Data From Excel To SQL SERVER Database Table

Oct 6, 2007

Hi Friends,
I am Using SQL SERVER 2005
I need to retreive data from Excel file to SQLSERVER table..
Thanks in advance
Regards
Rajkumar.M 
 
 

View 1 Replies View Related

Retreive Html Code From Xmlfile, Insert Into Table

Nov 15, 2007

I use the following query to shred an xml and insert it into a table, but I want to have the whole html structure into the column to be able to present the formatted text in Cognos 8 BI.

WITH xmlnamespaces('http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-01-15T13:29:33' AS my)
INSERT INTO TMP_ATGFORSLAG (AtgForslagDesc)
SELECT
AtgForslagRad.value('(/my:AtgForslagRad/my:AtgForslagDesc)[1]', 'varchar(2000)') AS AtgForslagDesc
FROM dbo.DeklAtgForslagXml

The structure of the source in the xmlfile I want to import is:
<my:AtgForslagDesc>
<html xmlns="http://www.w3.org/1999/xhtml">
<ol>
<li>Text1...</li>
<li>Text2...</li>
<li>Text3...</li>
</ol>
</html>
</my:AtgForslagDesc>

How do I shred not only the text but the whole starting <html> to finishing </html> and insert it into a table I would be very happy.

View 1 Replies View Related

SQL 2012 :: Query To Make Single Records From Multiple Records Based On Different Fields Of Different Records?

Mar 20, 2014

writing the query for the following, I need to collapse the continuity. If the termdate for an ID is one day less than the effdate of the next id (for the same ID) i need to collapse the records. See below example .....how should i write the query which will give me the desired output. i.e., get min(effdate) and max(termdate) if termdate is one day less than the effdate of next record.

ID effdate termdate
556868 1999-01-01 1999-06-30
556868 1999-07-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-01-31
556872 2004-02-01 2004-02-29

output should be ......

ID effdate termdate
556868 1999-01-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-02-29

View 0 Replies View Related

Class Method Is Smoking Fast When Executed Outside Of SQLServer, Dog Slow As A CLR Function Is SQLServer - Anyone?

May 10, 2007

We 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.

View 1 Replies View Related

Problem Unicode Data 0x2300 In SQLServer 2000 SQLServer 2005 Express

Sep 20, 2006

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

View 1 Replies View Related

Trying To 'load' A Copy Of A SQLServer 2000 Database To SQLServer 2005 Express

Apr 18, 2008



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!!

View 1 Replies View Related

MIcrosft SQLServer Best Practices Document On Securing SQLServer

Jul 29, 2005

I'm chasing after a documetn that was available on one of the Microsoftwebsites that was titled somethign like "MS SQL Server Best Practices"and detailed a nyumber of best practices about securing the server.Included in this was revoking public access to the system tableobjects.Can someone post the URL where I can pick this up, or drop me a note oncontacting them for a copy of the document?

View 2 Replies View Related







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