I've a table with an ID column, it is an auto increment id column that increases by 1.
ID -- 9724 9725
When my webhost restarts SQL, or some other random act of God, this ID jumps by 1000. Today it leapt from 9725 to 10725, which just doesn't work for me. It results in my having to upload the last known good copy of the database.
My host says they can't change the 1000 row buffer, MS apparently doesn't deem this an issue, and I'm quite frustrated. I used to be able to modify certain settings in SQL since I was using an SQL 2008 database under SQL Management Console but since my host upgraded to 2012, and I'm running XP, there is no forward compatibility and many options are no longer possible (eg. modifying a column, now it has to be done via clicking query and entering a SQL command rather than just right clicking on the column)
So long story made short... is there a way to modify my table (named "places") to turn OFF the autoincrement Id and perform a simple means to figure out the next possible value?
example: id, place, locstion, gps, v2, v3, v4, comment ================================================ 9720, Bill's House, Toronto, 43.4453, y, n, c, This was a good place to eat 9721, Dime a Dozen, Cambridge, 42.4453, n, e, d, A good place to take photos
I'd have to pull the highest value of ID (+1 to it) and then do a standard INSERT into places (id, place, location, gps, v2, v3, v4, comment) values (9722, etc...)I guess my concern is if the autoidentity is turned off, will SQL allow a new value to be entered via INSERT? I'm also using the @@identity to find the last known ID when I want to direct the user to the entry that they've just created and I don't know what that # is just yet. Would the @@identity still work?
I have set up a 'Parameters' table that solely stores all pre-assigned selection values for a webform. I customized a stored query to Select the values from the Parameters table. I set up the webform. The result is that the form1.apsx automatically populates each DropDownList task with the pre-assigned values from the 'Parameters' table (for example, the stored values in the 'Parameters' table 'Home', 'Business', and 'Other' populate the drop down list for 'Type'). The programming to move the selected data from form1.aspx to a new table in the SQL database perplexes me. If possible, I would like to use the form1.aspx to Postback (or Insert) the "selected" data to a *new* column in a *new* table (such as writing the data to the 'CustomerType' column in the 'Customers' table; I clearly do not want to write back to the 'Parameters' table). Any help to get over this hurdle would be deeply appreciated.
I need to update the AcquiredFrom table from source_office table. both the tables are from different database and server. we can match them on Code and source code. Initially if we can find out the discrepancies and then how can we fix them. Also there might be some dealerships that would have to be added to acquiredfrom table from the source_office table if they are not there already.
Table 1 (AcquiredFrom) database (Service) Server(FS3) Select Code, Name, ContactName, AddLine1, AddLine2, city, state, zip, PhoneNumber FROM [dbo].[AcquiredFrom] Order by Code Table 2 (source_office) database (DCP_PROD) Server (DPROSQL) Select source_code, name, addr1, addr2, city, state_id, zip, phone FROM [dbo].[source_office] order by source_code
Does anybody know of a way to determine the last date/time a table has been accessed (query/update)? I've done enough research to know that this isn't easy. However, perhaps somebody has figured out a way through some of the stats that SQL Server keeps to determine the last access of a table. I have recently been put on a team that had no DBA and has a number of databases out there. They would like to determine which databases are inactive and get rid of them. I am a developer and haven't had much SQL Server Administration experience. Any info will help greatly! Thanks!
I have a requirement based on 2 parts to determine a row of data in a table through SSIS :
a. Work out the LEG_SEQ_NBR of the VESSEL, VOYAGE and LEG already stored in table1.
To do this join table1 and join table2 through BL_ID column.
b. Work out the 2ndVESSEL, 2ndVOYAGE and 2ndLEG.
Once we have identified the LEG_SEQ_NBR of the VESSEL,VOYAGE, LEG already stored in table1 we need to add '1' to this value and then find that LEQ_SEQ_NBR in table2.
The DDL of table1 and table2 along with the test data are as below:
I would need to rewrite SQL code to determine that id is unique in the Customer table.
My two tables are:
CREATE TABLE CUSTOMER( [CUSTNO] varchar(5) NOT NULL, [ID] CHAR(9) NOT NULL, [NAME] VARCHAR(128) NOT NULL, [ADDRESS] VARCHAR(128) NOT NULL, [DATEOFBIRTH] DATE NOT NULL,
I need a SQL or TSQL command (not a stored procedure) that will determine if a table exists (TBL_PARAMETERS). The command needs to return a 1 if the table exists or 0 if it dose not exist.
I'm new to this whole trigger 'thing', so forgive me if this question has been asked and answered a few times already.
I'm in the process of writing a trigger that will send an e-mail to an application admin when any table within a given database is altered (IE, a column is added or deleted). I can get the e-mail to fire off when that happens without any issue, but I'd like to be able to let the admin know which table was tweaked and what new column was added.
Is this a relatively easy thing to do and I'm just not finding the right built-in variable name, or does something more need to be done?
Hello, My company Intranet has a form that agents can use to post their comments about the company to upper management, but our customer service department would like to modify the form so that the agent has to pick from a comment type. The dropdown options on the form will be as follows: ComplimentsComplaintsGeneral CommentsSuggestions Each dropdown option has a designated table in a SQL DB.Using postback on the same page, I need to change which fields of the form are visible based upon which dropdown selection the user chooses, and I need the fields to then be inserted into the table that corresponds with the dropdown selection item. For example: If the Compliments dropdown selection is picked, I need a text box to show for the user's location, the name of the customer, account number, and the message box. Once the submit button is clicked, the characters in these boxes need to be inserted into the Compliments table using its data adapter. However, if the user selects Suggestions, the name of the customer and the account number should not be visible, since these fields do not exist and when the submit button is pressed, the Suggestions table should be updated. If you need more information, I will provide whatever is needed. As always, thanks for everyone's assistance. Chris
Hi! I am new to SQL Server... looking for some veteran assistance.
"Data Integrity Report"
I need a Stored Procedure that takes a table name as a parameter and returns a cursor suitable as a data source for a pre-built Report Services report (I guess Report Services would call the SP?).
The cursor/report needs to have the following columns:
Ordinal_Position (I.E. Column number) Column_Name Number Of Blank Rows (how many missing values for this column in this table) Difference (Between total rowcount and population of this column)
Data_Type
Column_Length (either Character_Maximum_Length or the numeric widths rolled up with COALESCE?) Sample Data (The contents of the "first" row in the table, based on a TOP(1) and ORDER BY xxx) The report should look like this (for a table with 100 rows):
Col Num Col Name # Blanks Difference Data Type Col Length Sample Data 1 Name 12 88 varchar 30 Sally Smith 2 Address 34 66 varchar 45 123 Main St Apt 45 3 Acct_ID 0 100 varchar 4 AB12345
Using the "Information_Schema.Columns" I can get everything I need except for #3 (blanks count) and #7 (Sample data).
Is it possible to do this as 1 query, with a CTE or APPLY or something, or do I need to do a table variable based on the Information_Schema and then use dynamic SQL and row-by-row COUNT(*) for each column? And the same for the Sample Data.
Sorry for the long post, and thanks in advance! John
Making a form where a patient will fill out check boxes and after submission would like to present their submitted form back if they choose the option and be able to edit the data entered. What I am wanting to do is repopulate the form, but the checkboxes will need a database with this information that will then go to a php script and take the values entered into the various checkboxes and check those values from the database that were entered origionally. So lets say the database haspid - int(5) auto_increment primary keypatient_first - varchar(30) first namepatient_last - varchar(50) last namearthritis - bool or what?copd - bool or what?tin ear -bool or what?What would be the best to check against to repopulate does a true false make sense or should it either be NULL or the actual condition (just kidding about the tin ear)?
How to I make it so that a Authenticated User to a website can append a record to a SQL table. I have watched the video on the asp.net website about using database on a web, it shows how to allow a user to change a record in a database, but nothing I have seen so far shows how they can append a record.
What I am trying to do: I am building a website for a ATV club using Visual Studio 2005 and c#. I am setting up users or members on the site (club members will have a user account, while all others will be un-authenticated users. I am setting up a classifieds area where members can post items for sale, items they are looking for, etc.
I am planning to use roles to allow authenticated users access to a webpage located in a restricted directory. There I want to place a XHTML page which would allow the users to post their classified ads for free. I will have another page that will allow everyone to view the ads not just club members. I want to make this as easy to maintain as possible. I don’t plan on having all the postings come through me to be placed on the web, I want it all automated.
I have a Table which stores data from two different databases. To update it I made a Web Form that opens a single record where you can edit the data (using TextBox). Then there is an Update Button, which is supoused to Update that record in the SQL Database. However, for some reason it does not work. I get no error and every thing seems to work fine, but the data is not updated. When running the same UPDATE statment in the SQL Query Analyzer everything works just fine. Here is the code for the button click (For test purpose I've set a spesific record to update the Task cell to "Test" and I've adde a DataGrid to be able to see if something is happening): Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click Dim objConnection As SqlConnection Dim objDataAdapter As SqlDataAdapter Dim objDataSet As DataSet Dim objDataView As DataView Dim strConnect As String Dim strSQL As String Dim strUpdate As String strConnect = "Persist Security Info=False;Integrated Security=SSPI;server=SRV01;database=DB1" strSQL = "SELECT * FROM Users WHERE UserID ='" & Request.QueryString("UserID") & "'" strUpdate = "UPDATE Users SET Task = 'Test' WHERE UserID = 36" '" & Request.QueryString("UserID") & "'" objConnection = New SqlConnection(strConnect) objDataAdapter = New SqlDataAdapter(strSQL, objConnection) objDataAdapter.UpdateCommand = New SqlCommand(strUpdate) objDataSet = New DataSet objDataAdapter.Fill(objDataSet, "User") objDataView = New DataView(objDataSet.Tables("User")) dgrTest.DataSource = objDataView dgrTest.DataBind() objDataAdapter.ContinueUpdateOnError = True Try objDataAdapter.Update(objDataSet, "User") lblTest.Text = objDataAdapter.UpdateCommand.CommandText Catch ex As Exception lblTest.Text = "Error" End Try End Sub
I've a query wich with I select buildings form a table. I've a second table with a few building I don't want in my select (exclude form select). How can I make this?
I have a table called diagnosis_status in my TestdB environment and want to import the same table into my production (PROD) dB. This table also exist in PROD but I have update the one in Test dB and want to import the updated one into PROD?is there such copy/paste tools? I don't see it in my management studio?
Hello. As the subject heading says, I'm not able to insert data typed into the contact form on my page into a database table. I'm using an SqlDataSource object. Here's the code for this page:
i wanted to ask how to insert values from a single web form into two sql tables, i have been looking and the visual web developer i use doesnt seam to allow me to even atempt it i've tried selecting all the values from two different tables and then adding those two tables to an insert function but it doesnt work likewise the update functioni have values in a table currently a reference number and i want to use this reference number to update the address values in this table so update this field.table1 and thisfield.table2 when ref number = @ refnumber the reference number is present in both tables and is linked PK to FK <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Back End DataConnectionString %>" SelectCommand="SELECT StartDetails.StartDetailsID, StartDetails.ContractIDNo, StartDetails.ContractName, StartDetails.NINO, StartDetails.AnticipatedStartDate, StartDetails.StartDateTime, StartDetails.StartDateLetterSent, StartDetails.StartDate, StartDetails.AnticipatedEndDate, StartDetails.ActualEndDate, StartDetails.ReasonForLeaving, StartDetails.Provider, StartDetails.AdviserReferrer, StartDetails.ProvisionCat, StartDetails.Provision, ClientDetails.NINO AS Expr1, ClientDetails.CentreNo, ClientDetails.FirstName, ClientDetails.SecondName, ClientDetails.AddressLine1, ClientDetails.AddressLine2, ClientDetails.PostCode, ClientDetails.ContactTelephoneNumber, ClientDetails.MobileNo, ClientDetails.Email, ClientDetails.DateOfBirth, ClientDetails.Gender, ClientDetails.PWD, ClientDetails.Ethnicity, ClientDetails.ClientGroup, ClientDetails.RepeatStartDate, ClientDetails.CaseworkerName, ClientDetails.ClientStatus, ClientDetails.PlacementDates, ClientDetails.JobsearchDay, ClientDetails.AchievedILP, ClientDetails.JobDate, ClientDetails.JobDate2, ClientDetails.JobDate3, ClientDetails.EligibleForRolledUpWeeks, ClientDetails.NoOfWeeksClaimed, ClientDetails.MarketingWhere, ClientDetails.Notes, ClientDetails.JobCentre, ClientDetails.JobCentreRep FROM StartDetails INNER JOIN ClientDetails ON StartDetails.NINO = ClientDetails.NINO WHERE (StartDetails.StartDetailsID = @StartDetailsID) AND (StartDetails.NINO = @NINO)" InsertCommand="INSERT INTO [StartDetails] ([NINO], [StartDate], [AnticipatedEndDate]) VALUES (@NINO, @StartDate, @AnticipatedEndDate)"
Assume that if i have a product called Jacket that has the following descriptions, which written in bullet form
• 600 Denier Carbolex® coated 1000mm Polyurethane • Anatomically fitted for the riding position • Ballistic nylon in protective areas • FS Rainguard® 100% waterproof/breathable jet-liner • Polyester mesh non-allergenic liner • Removable CE armour equipped in the hips and knees • Padding at knees, shin, hips and kidney area • Removable zip-out satin quilted liner • Reflective Phoslite® • Stretch in the knees • Gusseted with Velcro front zip closure • Velcro adjustable waist • 2 front pockets • Storm flap system
How am i going to store in the Products table ? But not all products have these descriptions, other products may have no description at all.... If I store them in a text/memo DESCRIPTION field, then , I do not know how to format them into bullet form...
I would appreciate anyone knows the solution for me... Thanks in advance !
I'm grappling with this issue which I thought was basic VB programming; I'm trying to insert a random number (between 100 and 999) into a SQL table column (=Status_ID). This is input as part of a user submitting helpdesk requests via a APS.Net Web Form. The 'Status_ID' field is obviously not visible to the user but will help reference this Helpdesk request on the database.Here is the code:Protected Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click If Page.IsValid Then ' Define data objects Dim conn As SqlConnection Dim comm As SqlCommand ' Read the connection string from web.config Dim connectionString As String = _ ConfigurationManager.ConnectionStrings("ITNet_Students").ConnectionString ' Initialize connection conn = New SqlConnection(connectionString) ' Create command comm = New SqlCommand( _ "INSERT INTO HelpDesk (First_Name, Last_Name, StudentID, PersonalEmail," & _ "CategoryID, SubjectID, Description, StatusID) " & _ "VALUES (@First_Name, @Last_Name, @StudentID, @PersonalEmail, " & _ "@CategoryID, @SubjectID, @Description, @StatusID)", conn) ' Use randomize Randomize() Dim randomvalue As Integer ' Generate random value between 999 and 100. randomvalue = Int((900 * Rnd()) + 100) ' Add command parameters comm.Parameters.Add("@First_Name", System.Data.SqlDbType.NVarChar, 50) comm.Parameters("@First_Name").Value = fnameTextBox.Text . . . comm.Parameters.Add("@StatusID", System.Data.SqlDbType.Int) comm.Parameters("@StatusID").Value = randomvalue 'Enclose database code in Try-Catch-Finally Try ' Open connection conn.Open() ' Execute the command comm.ExecuteNonQuery() ' Reload page if the query executed successfully Response.Redirect("HelpDesk.aspx") Catch ' Display error message dbErrorMessage.Text = _ "Error submitting the help desk request! Please try again later, and/or change the entered data!" Finally 'close connection conn.Close() End Try End If End Sub----------------------------------------------------------------------------------------------------------------------I keep getting the error message under 'Catch' and the page 'HelpDesk.aspx' is not reloading; the 'comm.ExecuteNonQuery()' is not executing.Can anyone spot any inconsistencies in the declaration of the 'randomvalue' variable?P.S: this code works fine if you replace 'randomvalue' with any integer in 'comm.Parameters("@StatusID").Value = randomvalue'
Edited by SomeNewKid. Please post code between <code> and </code> tags.
// Pls copy the following HTML after that you generate the HTML page. Then you will know what I mean. I need to form "New Table" from Job Revence and Job Cost using SQL statement? thx