I need to create a Stored Procedure that will search for usernames in my database. I need it to return usernames where the first characters is ANYTHING BUT alphabetic characters (example: numerics, #, !, & etc.).
I am trying to write a stored procedure that will return all records that don't start with an alphabetic character.
This is what I have so far but I can't figure out how to make it so that it will select if the first letter in a column is not a letter.
SELECT strArticleID, strTitle FROM dbo.tblArticles WHERE LEFT(strTitle,1) LIKE ? AND bitState = 1 ORDER BY strTitle
I thought about making a temp table and putting all the records in it if the starting character is not a letter by using a bunch of if statements but I am hoping there is a cleaner way.
I was hoping there would be an expression or something that could be written in place of the "?" similar to .net expressions.
I am having a hard time finding information on how to search a nvarchar for non-alpha characters (stuff that is no a-z, A-Z, 0-9). I was I could create a function that would go though each of the char in each nvarchar and check if it was "a-z,A-Z,0-9", and if it wasn't send back false, if it didn't find any, send back true. Then in my query, I would but where function = false to just bring up the list that had the non-alphnumeric characters. My problem with that, i am not sure how to loop though each of the characters in the nvarchar. Is there a better way? or should I continue with the function, if the function, how do I loop though each of the characters?
I'm looking for a way to search for return characters (CHAR (13) or CHAR(10)) in VARCHAR fields. More specifically, either a way to remove them from the result set or replace them throughout the database.
Bonus Question: Why can't users take a minute and fix their cut and paste into the address 1 field so that address 2 is in the right field (instead of on address 1 with returns in the middle of the data)?! Sheesh!
I create my database table with a text field of nvarchar(), added some japanese kanji characters and so on. Everything works great, I can insert kanji and retrieve kanji and display them just fine from my c# application, however if I try to search for kanji using a WHERE = '' or a WHERE like '' clause, it doesn't score a match. Not even a direct one.
I'm on XP using a japanese locale with IME installed. The kanji shows up in Enterprise Manager correctly, it even shows in the query for the table, yet the WHERE clause won't record a hit. Changing the collation on the field to "Japanese" or "Japanese UNICODE" doesn't seem to have any effect.
I have a table in an Access db that stores information about speech files. One of the fields in this table is called "Text" and it contains the phrase spoken in that particular speechfile.
These phrases often have characters such as the "#" sign at the end to indicate what tone of voice is used.
I am trying to create a Search where users can enter the phrase they are looking for, and will be returned the file (or combination of files) that contain this phrase.
My problem is, when I try to search for a string of text that includes the "#" I get 0 results everytime.
An example of what I am doing is this:
SELECT Speechfiles.Name FROM Speechfiles WHERE Speechfiles.Text LIKE 'aero#'
It works fine for 'aero' or '*aero*' but whenever I try to add a character that is not a letter, it won't work.
If anyone has any ideas, I would REALLY appreciate it!!! I am completely at a loss.
I want to create a function that searches for allowed characters within a table range (that contains the allowed characters) and replace any characters outside this range with a space.
For example -
'Bill123?', 'Jones12.z-' 'John&12/', 'QWERT123&4'
Wanted results – the single quotes are there to show the space for the replaced characters.
'Bill123 ' 'Jones12.z ' 'John&12 ' 'QWERT123 4'
Example SQL data
CREATE TABLE [Common].[AllowedCharacters] ( [Character] [varchar](1) NOT NULL, [Replacement] [varchar](10) NULL, [AlwaysInclude] [bit] NOT NULL) GO SET ANSI_PADDING OFF
[code]....
The function will wrap around the column names and I know it can be done without a table validate the characters but it must be done this way.
With this procedure,can't show if GiftTitle contains space ,nonalphabetic chars(&,-,..) and if start with numnber. How can i modify ?? Plz help me. Thanks.
CREATE PROCEDURE dbo.trymatrix AS DECLARE @SQLCommand varchar(4096), @column sysname
SET @SQLCommand = 'select c.CustomerID as Cust_ID,Name as Co_Name, ' + char(13)
DECLARE curGift CURSOR STATIC LOCAL FOR
select distinct GiftTitle from Redemption1
OPEN curGift
WHILE 1 = 1
BEGIN
FETCH curGift INTO @column
IF @@FETCH_STATUS <> 0
BREAK
SET @SQLCommand = @SQLCommand +
'sum(case GiftTitle when ''' +@column +''' then 1 else null end) as '+ @column + ','+char(13)
END
DEALLOCATE curGift
SET @SQLCommand = left (@SQLcommand, len(@SQLcommand)-2) + char(13)
Now I want to run a select query that will only bring the ones that have ‘CA’ or ‘US’ as the first two characters.
I can do that by running this:
select * from tDocISIN where sISIN like 'CA%'or sISIN like 'US%'
But my other where clause I want to add is only bring back the ones that have CA or US as the first two characters and any other character after the first two or in the rest on the string.
So US7636516745 is an ISIN I don’t want to bring back and US763TY16745 is an ISIN I do want to bring back.
The character that does exist after the first two characters will be anywhere within the rest of the string.
Hope that is clearly explain any help would be great.
In my application I must store over 16000 character in a sql table field . When I split into more than 1 field it gives "unclosed quotation mark" message. How can I store over 16000 characters to sql table field (only one field) with language specific characters?
Hi everybody, I would like to know if there is any property in sql2000 database to separate lowercase characters from uppercase characters. I mean not to take the values €˜child€™ and €˜Child€™ as to be the same. We are transferring our ingres database into sqlserver. In ingres we have these values but we consider them as different values. Can we have it in sqlserver too?
I am trying to find all the email addresses with a " ._" I use '%._%' but it returns all records. What is the correct syntax? Also, is there a way to search for a field where the underscore is followed by a single alpha letter and then another underscore? like bla_A_bla or bla_Z_bla.thanksMilton SELECT DISTINCT fname, lname, inet FROM ocadbo.notes where inet like '%._%'
the application registers the student details to a course. each student gets a new registration no during registration.
the app should identify repeaters to a particular course by checking another table RegHistory, which stores the details of student registrations for the previous 5 years.
to determine whether a student is a repeater or not, we have to search for an exact match in RegHistory table (where the student name, guardian name and date of birth in both tables match with the corresponding entries in Registration table).
here is my question,
if there are 100,000 students registering in each academic year, we will have 500,000 records in RegHistory Table and 100,000 records in studReg table
if i start searching for a repeater, i guess i will have to loop through all records in studReg, for an exact match in RegHistory, which wil be a time consuming process.
is there any other options to search for repeaters ?
hi all, I need help in selecting records from a table based on the given search criteria. spec: select * from table where col1='x' and col2='y'... and col6='q' i may give any combination of column values. I mean I can't provide 6 values in 'where' condition all the time i submit query. help me with a stored proc which has 6 input parameters for the 6 columns.
I am searching for an add-in to ssms which lets me choose which server to deploy my code.
For example, I have a complete statement with CREATE PROCEDURE and all code in my query window.
Now I want to run/deploy this code to many servers at once. Instead of having to reconnect to all server (5), I want an add-in which have checkboxes for me to select.
Hi,I have come to point in my db design where I'm trying to figure whichis the best approach in making it generic (does this really matter?!?)Senario - I have a table called JOBS and this table contains fieldsuch as JobTitle, JobDescription, Salary etcI want to add to this table other attributes which are specific to acertain Job Industries.Solution - Add a join table for each type of industry containingattributes (db is now not generic) OR add a new table with a IndustryType field and a XML field containing the industry specificattributes.If I go the XML way will this just make it complex and slow to query?If not, what is the best way to query an XML field?Thanks,Jack
I am having a problem with seaching my tables. On my asp.net page ihave 3 text boxes. One for an ID and NAME and ADDRESS. I want to beable to search a table by using all or any combination of the 3 tosearch. But i cant get it right. i am using c# and sql server.any help ideas would be a great helpthanks in advanceructions
i'm making a web page for a clinic.it needs to be able to search for patients by first name, surname, date of birth and patient number.i'm using visual web developer and i have my database, my data source and GridView grid.i want 4 text boxes for my first name, surname etc. when u click enter on any of them i want to retrieve all their data and display it in the gridview.at the moment i have one text box on the web page and through the "Configure data source" option on the grid view i can retrieve the specified data but for only this one item, e.g. SELECT * FROM [Patients] WHERE ([DOB] = @DOB). if i add another text box to my web page, and don't do anything to it, the query wont run. if i add and "AND" statement to the query, e.g. SELECT * FROM [Patients] WHERE (([DOB] = @DOB) AND ([FirstName] = @FirstName)), again it won'r run or return and data. any ideas on what i can do or where i'm going wrong. thanks
I have a table GO CREATE TABLE [dbo].[Speech] ( [SpeechId] [int] IDENTITY(1,1) NOT NULL CONSTRAINT PkSpeech_SpeechId PRIMARY KEY, [UniqueName] [varchar](52) NOT NULL, [NativeName] [nvarchar](52) NOT NULL, [Place] [nvarchar](52) NOT NULL, [Type] [smallint] NOT NULL, [LanguageId] [char](2) NOT NULL CONSTRAINT FkSpeech_LanguageId FOREIGN KEY (LanguageId) REFERENCES Language(LanguageId) ON UPDATE CASCADE ON DELETE CASCADE, [SpeakerId] [int] NOT NULL CONSTRAINT FkSpeech_SpeakerId FOREIGN KEY (SpeakerId) REFERENCES Speaker(SpeakerId) ON DELETE CASCADE, [IsFavorite] [bit] NOT NULL, [IsVisible] [bit] NOT NULL, [CreatedDate] [datetime] NOT NULL DEFAULT GETDATE(), [ModifiedDate] [datetime] NULL ) Now I want to search the Table Speech Sometimes by : SpeechIdSometimes by : SpeakerIdSometimes by : LanguageIdSometimes by : SpeechId And LanguageIdSometimes by : SpeakerId And LanguageId All can have conditions with IsVisible, IsFavorite and Type columns. for example I need all Speeches withany particular SpeakerId and LanguageIdwith IsVisible equals to trueand IsFvaorite No Matterand Type equals to Audio For these type of queries I think the solution is GO CREATE PROCEDURE [dbo].[sprocGetSpeech] @speechId int = NULL, @uniqueName varchar(52) = NULL, @nativeName nvarchar(52) = NULL, @place nvarchar(52) = NULL, @type smallint = NULL, @languageId char(2) = NULL, @speakerId int = NULL, @isFavorite bit = NULL, @isVisible bit = NULL AS SELECT SpeechId, UniqueName, NativeName, Place, Type, LanguageId, SpeakerId, IsFavorite, IsVisible, CreatedDate, ModifiedDate FROM Speech WHERE SpeechId = @speechId AND UniqueName = CASE WHEN @uniqueName IS NULL THEN [UniqueName] ELSE @uniqueName END AND NativeName = CASE WHEN @nativeName IS NULL THEN [NativeName] ELSE @NativeName END AND Place = CASE WHEN @place IS NULL THEN [Place] ELSE @place END AND Type = CASE WHEN @type IS NULL THEN [Type] ELSE @type END AND LanguageId = CASE WHEN @languageId IS NULL THEN [LanguageId] ELSE @languageId END AND SpeakerId = CASE WHEN @speakerId IS NULL THEN [SpeakerId] ELSE @speakerId END AND IsFavorite = CASE WHEN @isFavorite IS NULL THEN [IsFavorite] ELSE @isFavorite END AND IsVisible = CASE WHEN @isVisible IS NULL THEN [IsVisible] ELSE @isVisible END Can anyone tell me? Is it right way to do?Do you have any better solution?If my solution is better then Is there any performance loss with that query?
hello all..i have make a searching, but is not good. my code like that:Public Class getall Public Function getitem(ByVal id As String) As DataSet Dim con As SqlConnection = New SqlConnection("Data Source=BOYsqlexpress;Initial Catalog=GAMES;User ID=ha;Password=a") Dim ds As New DataSet() Dim adapter As New SqlDataAdapter("select * from [item] where name like '%" & id & "%'", con) Try con.Open() adapter.Fill(ds, "user") Return ds Catch ex As Exception Console.Write(ex.Message) Finally con.Close() con = Nothing End Try ' Next Return ds End Functionand class my item in database is containning dragon ball 3, counter strikeif i insert dragon, it can display dragon ball 3.but if i insert dragon 3, it not display dragon ball 3.it should display dragon ball 3 .how should i change my code?thx...
hello everyone i need C# code in wh we sent "UserID" to table named "Users" and if such "UserID" exists in "User" table we get his name from the table else we got message that no such record exists. i have tried to write that code ,it works only if the value exists . in case of no value an exception is thrown. please do sent me that c# code. thanks for your consideration.
Just wanted to run this idea past u all before I have a go at it.
I have two tables A & B that are similar to the below
Table A Name1 Name2 Name3 Tom Bill John Gary Harry Eric
TableB Name1 Name2 Name3 John Bill Tom Tom Eric john Leslie Philip Colin
What I wanted to do is see if the the records from tableA row 1 exist in tableB
As you can see they can appear in any order, partially or not at all.
What I propose to do is take tableA Name1 and see if it matches tableb row1 name 1 OR name 2 OR name 3 and if I find a match use a variable to assign the the value 1 (so I can then see if the match is full (score three) partial socre 1 and two or not at all (0)
Then I will need do the same for tableA row 2
Then goto row 2 of table a and start again.
Does this make sense? Are there beter ways of doing this.
hi i am working on sql server200.I m using "LIKE" to search the records.There is freetexttable and containstable table also.just like to know the difference between them.Could anyone provide me a good link regarding this??Thanks
I have a products table with product attributes in a second table, together they describe a full product. I have a product title, a list of providers, description text, and keywords. I would like to do a search across these fields, and so far my research has shown that the Full Text Search component of SQL Server is the way to go. However, I am not sure this will be possible based on what is installed on the hosted server, so I am wondering if there is a unique, cool way of doing this without Full Text Search?