|
What do you mean by "not working"? If it generates a link that looks like:
<a href="https://www.google.com/search?q=123219843">Search</a> then it should work: Search
Depending on the tracking code, it might not find the results you want. But it will open a Google search for the tracking code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
well i tried inserting this code
$output += "<br><a href="https:
into
$output = "Tracking Number: $tracking_number<br />Order Number: $sales_order_number<br />Parts: $parts";
and it keeps crashing my search box.
|
|
|
|
|
I don't know what "crashing my search box" means.
I notice you're overwriting the $output variable for each record. Does your search only ever return a single result?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
correct.
i tried doing this
$output = "Tracking Number: $tracking_number<br />$output += "<br><a href="https://google.com/search?q=$tracking_number">Search</a>";Order Number: $sales_order_number<br />Parts: $parts";
but it did not work
|
|
|
|
|
How about:
$output = "Tracking Number: $tracking_number<br /><a href=\"https://google.com/search?q=$tracking_number\">Search</a><br />Order Number: $sales_order_number<br />Parts: $parts"; NB: You need to escape the quotes inside the string.
PHP: Strings - Manual[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
that did it thanks so much
|
|
|
|
|
Hi,
I am trying to copy just the Headers of a result set of a select statement, normally I am able to do by select only one row, but I want to get it even if the Resultset has empty rows. Please need some help. - Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
For SQL Server Management Studio (SSMS) you can go to Tools | Options
Within Options: Query Results | SQL Server | Results to Grid
When you can select a row, copy it and you get the headers (plus the selected rows).
Unless, you only have one column or you have an empty result set - then it doesn't work.
You can either (1) change your result to text [CTRL]+"D" and see the headings
(also Tools | Options | Query Results | SQL Server | General, select Results to Grid)
or (2) you can select the "Include the query in the result set" (though presumably you already have the query).
Hope that helps,
-Chris C.
|
|
|
|
|
Try
Select * from Table where 1=1
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Actually its not a problem of where condition, because where 1=1 is nothing but not having where clause itself like
Select * from Employee is same as Select * from Employee where 1=1
The table itself doesn't have any data but still I want to copy the Header names as there are 45 Columns in that table for example and i don't want to expand the Columns of the table in Management studio in that way I can do, but just want get it from select resultset.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
You want to explore the Information_Schema views
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Country'
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yeah that makes sense - thanks a lot
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
My original question was, "What should I name the clustered index column which isn't the primary key?" but then I started putting in why I was doing it, and changed the subject to include 'is this a good idea?'
I have a table and the primary key is a GUID, which is generated from vendor code so I cannot do what I would normally do: create an int for the clustered index and use that as the pk.
My idea is to create the table like this:
CREATE TABLE [dbo].[table_name](
[need_a_good_name_here] [int] IDENTITY(-1,-1) NOT NULL, -- Adding this field
[guid] [char](36) NOT NULL PRIMARY KEY NONCLUSTERED,
...
) ON [PRIMARY]
CREATE CLUSTERED INDEX Ix_Table_Name ON [dbo].[table_name] ([need_a_good_name_here] ASC) Feel free to comment on the following:
1. I don't want the guid to be the clustered index because there will be inserts.
There were 3,000 inserts the first month, and I'm expanding from one category to four five. No way to know the distribution of inserts (except 1st shift / business days) and I don't know the frequency of the other categories.
Fill factor == 100, not sure I can get it changed.
2. I have the identity starting at -1 and decreasing by 1 to make it obvious that it isn't the pk.
Don't know how much this will help, but I do what I can.
3. I don't like the names ix_need_a_good_name_here, need_a_good_name_here_ix, need_a_good_name_here_id, because if I saw them I would assume that was the primary key. Suggestions?
4. Should I just not worry about splits?
5. Remember my mention of vendor code... I can't use SQL Server NEWSEQUENTIALID() which would make #1 a non-issue.
All feedback appreciated!
modified 24-Apr-18 17:23pm.
|
|
|
|
|
JChrisCompton wrote:
CREATE TABLE [dbo].[table_name](
[need_a_good_name_here] [int] IDENTITY(-1,-1) NOT NULL,
[guid] [char](36) NOT NULL PRIMARY KEY NONCLUSTERED,
...
) ON [PRIMARY]
May I ask why you are using char rather than uniqueidentifier type?
|
|
|
|
|
Good question... 3rd party software is the reason.
|
|
|
|
|
JChrisCompton wrote: 2. I have the identity starting at -1 and decreasing by 1 to make it obvious that it isn't the pk.
Don't know how much this will help, but I do what I can. If it is your table, you decide what the PK is. The vendors ID should simply be a unique constraint with an index and be treated as an "alternative primary key".
JChrisCompton wrote: 3. I don't like the names ix_need_a_good_name_here, need_a_good_name_here_ix, need_a_good_name_here_id, because if I saw them I would assume that was the primary key. Suggestions? The name should be identifying enough for you to know which constraint has been broken once the exception is thrown. To make searching easier, I use the tablename as the beginning of that name, and postfix the columname on which the constraint lies, as well as the letters "IX" for an index, or "C" for a constraint.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
JChrisCompton wrote: 1. I don't want the guid to be the clustered index because there will be inserts.
There were 3,000 inserts the first month, and I'm expanding from one category to four. No way to know the distribution of inserts (except 1st shift / business days) and I don't know the frequency of the other categories.
Fill factor == 100, not sure I can get it changed. 3000 inserts is really not much.
JChrisCompton wrote: 2. I have the identity starting at -1 and decreasing by 1 to make it obvious that it isn't the pk.
Don't know how much this will help, but I do what I can. The best identifier is a proper name, see Eddys response I agree fully with him. And so does ISO 11179.
JChrisCompton wrote: 3. I don't like the names ix_need_a_good_name_here, need_a_good_name_here_ix, need_a_good_name_here_id, because if I saw them I would assume that was the primary key. Suggestions? I believe you're mixing up indexes with keys.
The purpose of an index is to speed up the searching of a table, an index does not need to be unique.
The purpose of a key is to ensure the integrity of the database. A key needs an index for the function, but not the other way around.
If you create a clustered table, you should not use a guid as the key as you really should avoid random inserts on them. so either you use the identity column as the primary key and simply put a unique key on the guid column, or you use a nonclustered table.
|
|
|
|
|
> I believe you're mixing up indexes with keys.
Perhaps - let me try again; maybe I didn't convey this well.
The index isn't just for lookup speed, it is a unique index (same functionality as a unique constraint unless I'm missing something... I'm more of an 'app dba' than a 'real DBA') to enforce referential integrity because... referential integrity.
The addition of the Identity field was due to my concern about page splits. The guid will remain the primary key for the table. The guid is generated within a vendor's application so there isn't much I can do about that at the moment.
I know (or at least 'think') that fill factor is only applied at rebuild or creation. This troubled me since guids are random (in the sense that where a newly generated guid falls numerically in relation to an existing list of guids is a random position). Inserts will fill up any fill factor <100 and then splits start (and the splits are equivalent to fill factor = 100 as the table grows).
So I came up with the idea of a Clustered Identity as the 'physical sorting field' (numerically increasing won't generate page split) because it seems a better idea than (1) guid inserts causing page splits, and (2) better than making the table a heap (without a clustered index).
Someone mentioned the volume being low. Yes, last month was 3,000 but this will be expanded from 1 to 5 categories. This could cause 3,100 entries next month or 31,000 entries. I don't have the time of day of the inserts but it is all first shift and (I think) mostly at the start of the month. If I can cause less work for the db, it feels like I should.
One new piece of information that I'll share: testing this I don't see as much of a negative impact from a pk clustered guid as I expected.
|
|
|
|
|
JChrisCompton wrote: I know (or at least 'think') Specify Fill Factor for an Index | Microsoft Docs[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Yes, it says "The fill-factor option is provided for... [when] an index is created or rebuilt..."
"I think" was intended to mean "I think fill-factor has no influence except during create/rebuild".
The issue that concerns me is page splits.
From memory of a MSFT SQL Server Performance Tuning class I took five years ago, I think tables with a clustered index are a B+ tree with doubly linked leaf nodes. (class and school were long ago :–)
When an insert happens, and the bottom node of the tree is full, then a split happens.
When SSvr splits a node, my understanding is that it just makes a new node - the fill-factor doesn't enter in to it. If I specify my fill factor to be "only fill 1/3" it doesn't matter - a new node is created (instead of 2 extra nodes being created then each adjusted to 1/3 full). This is done without rebalancing, because it is the fastest solution.
Is my mental model right, or are there things in newer versions that makes 'real life' different?
(maybe some auto tuning feature I've missed)
|
|
|
|
|
I never did trees in school.
JChrisCompton wrote: The issue that concerns me is page splits. From the page I linked; "When an index is created or rebuilt, the fill-factor value determines the percentage of space on each leaf-level page to be filled with data, reserving the remainder on each page as free space for future growth."
"How do you avoid them? There are strategies for doing this, one such strategy is to use a low fill factor when you create and index, but that will be at the expense of read operations and because you usually have more reads to writes then that’s bad."
What is a page split? What happens? Why does it happen? Why worry? - Tony Rogerson's ramblings on SQL Server[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks for the article reference, it is good reading.
It is great background and wonderfully answers "what is a page split."
I do wonder, however, how much of that has changed in SSrv 2008+. I thought, for example, that VarChar columns in SQL Server can be moved off to different storage location to prevent splits due a column changing its size. (row overflow? or is that just for blobs?)
I didn't find something to corroborate my thought when I did a quick search, so if someone could let me know whether I'm on/off base in the previous paragraph it would be great. Just specifically about VarChar (not text/blob; that's a different world I'm rarely in).
|
|
|
|
|
JChrisCompton wrote: It is great background and wonderfully answers "what is a page split." Better than I could in a single post, and it is nice to have an actual example that you can copy/paste to try for yourself and see
JChrisCompton wrote: I didn't find Let me share more bookmarks
How are varchar values stored in a SQL Server database? - Stack Overflow[^] - first answer. I had already forgotten about the option to compress those fields.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks again. I believe the term I was looking for is "offrow pages".
Here's a recent (Feb 2018) link that talks about it briefly then takes the undocumented DBCC IND command really deep into the RowID and beyond SQL Server Row Data Linking to Off Row Data[^] in case you're interested.
I enjoyed it but was a little got lost 
|
|
|
|
|
Cool, thanks for the link
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|