Which query should i use...
Asked By George
06-Sep-10 02:08 AM
i have two text boxes, a button and two columns in my access database..... i want whenever i click my button the data in the text boxes should update data in top1 row of the database....
plz suggest which query should i use...
re: Which query should i use...
harsh shah replied to George
06-Sep-10 02:47 AM
Hi,
below i have given a sp check it. it is a sqlserver sp.
so if need then make similar to Access S.P
CREATE PROCEDURE dbo.[update_first_row]
@filed1 VARCHAR(20),
@field2 VARCHAR(20)
AS
BEGIN
DECLARE @id int
SELECT @id = 'your TABLE UNIQUE id Field' FROM Table_Name ORDER BY 'your TABLE UNIQUE id Field' desc
UPDATE Table_Name SET
field1=@field1,field2=@field2
WHERE your TABLE UNIQUE id Field=@id
end
let me know
Regards,
Harsh Shah
re: Which query should i use...
Anand Malli replied to George
06-Sep-10 02:55 AM
Hi George,
Its simple see the below query,here i am writting query later on you can make SP out of it
UPDATE <table name>
SET <col1>='textbox1 value',<col2>='textbox2 value'
WHERE <col1>=(select top 1 <col1> from <table name>)
just try this and let me know
thxs
re: Which query should i use...
Priyanka replied to Anand Malli
06-Sep-10 03:24 AM
hey dude i tried like this but it is giving error in code ...
the error is Data type mismatch in criteria expression.....
plz make me correct i want to update top1 row...
re: Which query should i use...
Priyanka replied to Priyanka
06-Sep-10 03:46 AM
no need to reply , i have done this query successfully....
re: Which query should i use...
Anand Malli replied to Priyanka
06-Sep-10 04:29 AM
thats gud...what were the changes that you made?? must have converted to verchar or something with convert...isnt it
if end is well everything is well..gr8 if its solved
thxs :)
click my button the data in the text boxes should update data in top1 row of the database. . . . plz suggest which so if need then make similar to Access S.P CREATE PROCEDURE dbo.[update_first_row] @filed1 VARCHAR(20), @field2 VARCHAR(20) AS BEGIN DECLARE @id int SELECT @id = 'your TABLE UNIQUE id Field' FROM Table_Name ORDER BY 'your TABLE UNIQUE id Field' desc UPDATE Table_Name SET field1 = @field1, field2 = @field2 WHERE your TABLE
two queries(Insert and update) in one stored procedure HI. . . I am using C# and sqlserver 2005 i would like to write two queries(Insert and update) in one stored procedure. . i have a registration page in this when i entered be successfully insert at the same time i have to update the email address which i entered in the new record this email address field will be update in the last 10 records simantanesly. . .pls help me. . . If generated system date column in your table? If so your Procedure would do some thing like, INSERT INTO <table> . . . and then, UPDATE <table> SET <email column> = <email value> WHERE <auto-incremented column TOP 10 <auto-incremented column> FROM <table> ORDER BY 1 DESC) Is this making any sense? Thanks for your reply. . not
filed names(not the values) in this fomat. (fieldname)field1 = @field(fieldname) (fieldname)field2 = @field(fieldname) and @fieldname1, @fieldname2, . . . . . . Please help me out. Thank you Keerthi.Cheluvaraj. This way: See the example: CREATE PROCEDURE blockdet6(@pid char(20)) AS select * from blockdet where projid name, length = syscolumns.length FROM sysobjects JOIN syscolumns ON sysobjects.id = syscolumns.id JOIN systypes ON syscolumns.xtype = systypes.xtype WHERE sysobjects.xtype syscolumns . name AS FieldsInTable FROM sysobjects JOIN syscolumns ON sysobjects . id = syscolumns . id WHERE sysobjects . name = 'spt_values' / / Put your table name here Hello NULL' end NUllStatus from syscolumns inner join sysobjects on sysobjects . id = syscolumns . id inner join systypes on systypes . xtype = syscolumns . xtype where - - If
Incorect sytax when creating a stored procedure When I add a file to a database I have and then use that value to populate the sort order field. I am getting an error message at my ELSE when I create this stored proc: CREATE PROCEDURE [dbo].oc_OnlineCaseFileAdd @CaseId int, @FileId int, @FileName nvarchar(100), @FileDescription CaseId INSERT INTO [dbo].oc_OnlineCaseFile / * Do I Insert the File Id here, it was not before) * / ( [CaseId], [FileId], [FileName], [FileDescription], [SortOrder FileId, @FileName, @FileDescription, @HighestSortOrder ) ELSE / * if the file does exist UPDATE the File Info * / <<<<<<<<<<<<THIS IS WHERE IT IS GVING ME CaseId INSERT INTO [dbo].oc_OnlineCaseFile / * Do I Insert the File Id here, it was not before) * / ( [CaseId], [FileId], [FileName], [FileDescription], [SortOrder ResultCount AS ResultCount END Your SP needs to look like CREATE PROCEDURE p_test AS BEGIn / / Statements go here END The only time
2 columns one is Timestamp and the other one is ID.Sir what i need is to check whether there is any particular timestamp , if present i need to get the Id immediatly before that Timestamp. can anybody tell me the respective queries Thanks&Regards Nami MySQL Stored Procedures A stored procedure is made up of one or more SQL statements or on, let’s take a look at creating a stored procedure. Launch MySQL Query Browser, connect to your versedb database, open new Script Tab, and execute the following script. DELIMITER $$ DROP PROCEDURE IF EXISTS `versedb`.`usp_Verse_GetList`$$ CREATE PROCEDURE `usp_Verse_GetList`() BEGIN SELECT verse_id, verse_text, verse_ref FROM verse ORDER BY verse_ref DESC; END$$ DELIMITER ; This simple stored procedure retrieves all the rows in the verse table ordered by verse reference in descending order. To see this stored procedure in action, open a new Query Tab and execute the
true" ShowCancelButton = "true" HeaderText = "Edit" / > <asp:TemplateField> <FooterTemplate> <asp:LinkButton ID = "lbInsert" runat = "server" OnClick = "lbInsert_Click"> Insert< / asp:LinkButton> <asp:LinkButton ID = "lbCancel" runat = "server" OnClick = "lbCancel_Click"> Cancel< / asp:LinkButton> < / FooterTemplate> < / asp TemplateField> < / Columns> I hav 2 tables. . Table_1 and Table_2 with (ID(PK), Name) and (ID, Table1_ID(FK), Name_1 and Name_2) respectively Plz help me out the rest tym it remains hidden. i am using stored procedure rather than query. Thnx in advance Hi, The below sample w3.org / 1999 / xhtml " xml:lang = "en" lang = "en" > < head id = "Head1" runat = "server" > < title > ASP.NET Insert data in Gridview < / title > < / head > < body > < form id = "form1" runat = "server" > < asp:Label ID = "Label1" runat = "server" Text = "Label" > < / asp:Label > < asp:GridView ID = "GridView1" ShowFooter = "true" runat = "server" OnRowCommand = "GridView1_RowCommand1" AutoGenerateColumns = "false" > < Columns asp:Button Text = "Edit" CommandName = "Edit" CausesValidation = "false" runat = "server" ID = "btEdit" / > < asp:Button Text = "Delete" CommandName = "Delete" CausesValidation = "false" runat
datetimepicker and a datagridview and 3 records in the dataset: ID = 1, 2, 3 LastName = 'X', 'Y', 'Z' and StartDate = '2010 1', '2010 / 2 / 2', '2010 / 3 / 3' order by StartDate desc. The data of the most recent one (ID = 3) is shown in the tbx / dtp to be modified a rowfilter making that only one record is withheld (.RowFilter = "ID = 3") and bound to the tbx and dtp, and the except the first one are shown in the grid (.RowFilter = "ID<> 3"). And now: - Modifying the first dataview trough the tbx Deleting the one record in the first dataview, getting the ID of the first record in the second dataview and adapting to shift the wole up works (thisID = dataview2.item(0)("ID") dataview1. . RowFilter = "ID = " & thisID and dataview2.RowFilter = "ID<> " & thisID), except that I can't get the binding with to add a record to dataview1 and sending the current ID of dataview1 to dataview2 not even having an ID for
Querry How we create index?can anyone give example of cluster and noncluster indexes can use for this. If not, you will want to create one for these examples. Create Table DummyTable1 ( EmpId Int, EmpName Varchar(8000) ) When you first create a new table, there is no index created by default database, tracks table and index information. “Indid” refers to Index ID, and is used to identify indexes. An indid of 0 command. DBCC page(dbid, fileno, pageno, option) Where: dbid = database id. Fileno = fileno of the page. Usually it will be 1 the query, and avoid scanning every row in the table. Create An Index Having a data connection in the Server Explorer view of Visual Studio.NET allows us to easily create new indexes: • Navigate to the Products table of the Northwind do so. The IDE will then issue the commands to create the new index. We can create the same index using the following SQL. The command specifies