I need to group my ActiveRecords first by YEAR and then by MONTH, something like this: {2017=> "January"=> [Record1, record2, etc] "February"=> [Record1, record2, etc] 2016=> "January"=> [Record1, record2, etc]
Please help me to convert this SQL statement to Linq in C#: string cmd = "SELECT * FROM dbo.Personnel WHERE (dbo.Personnel.FName LIKE @FName + '%' AND dbo.Personnel.LName LIKE @LName +'%')"; if (objPPersonnel.PersonnelCode != 0) { cmd += "A
I've try following SQL and it was slow when I useing declare @NewCityJudge table and join it, but it was fast when I convert table into real number and join it. -- input id into @NewCityJudge, only one record declare @NewCityJudge table(CountryId int
Hi I have an SSIS package in which i have a main package that references child packages, is there a way I can make the location path external using a Relative path or just the file name. I cant use the full C: drive path as this is subject to change.
I have the first table 'users' | id | name ------------------ | 1 | james | 2 | johnny | 3 | Carl | 4 | Lea And my second table contain the linked users linked_users | id | linked_id -------------------- | 1 | 2 | 1 | 4 | 2 | 3 I need to get two fiel
I want to select all sections which do not have any students enrolled These are the three tables: ENROLLMENTS student_id, section_id SECTIONS course_id, section_id COURSES course_id, description The output table should look like this: course_id | des
Hello i have a sql statement that ranks my records and inserts the ranks into a database. The problem i am having is that when i run the script. It deletes the old rankings. And inserts the new rankings fine, but it inserts every ranking twice. So th
How could I write a while loop to populate data from a table to a variable to be used in a seperate query ? EX: select ITEM from Table1 ITEM A0001 B0001 C0003 D0005 E0032 If I can get all that results here under column ITEM to @var1 and then use it i
I've come across a slight issue when designing a trigger statement in our MySQL DB today: We have the following relevant tables: quote (quote_key, date, discount_rate, discount_period, supplier_key) part (part_key, part_name, ...) part_quote (pq_key,
I have multiple statements from oracle database and I need to use them in SQL Server insert into COMENZI (NR_COMANDA, DATA, MODALITATE, ID_CLIENT, STARE_COMANDA, ID_ANGAJAT) values (2456, to_timestamp('08-11-1998 07:53:25.989889', 'dd-mm-yyyy hh24:mi
I want to select nth record randomly from 100 of records by using select query in SQL ServerHere is a one-query solution: select top 1 t.* from table t order by newid();
I need to show some records sorted based on modified column (latest activity on top) (Post with new edit or comments at the top) App UI has twitter like 'more' post button for infinite scroll. each 'more' will add next 10 records to UI. Issue is that
I have a table which contains more than one row for a particular value . Here is the table structure: NAME,NUMBER,STATUS,DESC,START_DATE,END_DATE A,3,X,DetailsOfX,13-10-15,13-10-15 A,2,Y,DetailsOfY,13-10-15,13-10-15 A,2,Z,DetailsOfZ,13-10-15,13-10-15
I am having a query like this SELECT firstName FROM student WHERE LEN(firstName) > 5 There is a Non-Clustered Index on the 'firstName' column. It is normally advisable not to use SQL function with column of table in WHERE, HAVING etc, clauses. Otherw
I get the error message when I run the following query in MSSQL Server 2005. Error Message is Incorrect syntax near ','. I think query is ok. But I don't know why I get error. INSERT INTO PERSON (ID, EMP_NAME) VALUES ('E001', 'AAA'), ('E002', 'BBB');
If I have a table where each row is a customer booking, is it OK to have 2 foreign keys in this table: one which will be null and the other referencing the primary key approriate. The reason I have two tables with the foreign key constraint applied t
I have a table called CampRegistration with the following structure: [EID] INT, [CampName] VARCHAR(100), [StartDt] DATETIME EID is the identifier of the person who attended the camp. I wish to select the last camp each person in the CampRegistration
Platform: SQL Server 2005 Express Disclaimer: I'm quite a novice to SQL and so if you are happy to help with what may be a very simple question, then I won't be offended if you talk slowly and use small words :-) I have a table where I want to SUM th
hi i am trying to add data to the database that was created by some one but when am trying to insert or delete or update the exception is raising and entire project is not working properly and the error i am facing is "A network-related or instance-s
I want to use a stored procedure to copy a table from my test database to a linked server with the same ID's / Identity but I can't get it to work.. I've set the IDENTITY_INSERT to ON but it still complains about the ID column. Here's my procedure: C
I have simple table in database where are columns error_id, error_group_id and message. I want to show listing in UI which shows Message and occurrences of each error group. Error message may vary slightly (for eg: Settings X expired on date) where d
I have a remote SQL server. I want to make a local copy of all tables in this server. I don't care about the file format used locally, I'm looking for the fastest approach of getting the data from SQL server into the file. (note: server side backup i
In my application I have a datagrid that populates with info from a SQLserver DB. Amongst other things the data which populates the grid includes times. Now I struggled for some time getting the data from the DB to look the way I wanted. In the end m
How can I get the Service Account name for the SQL Agent service for a particular SQL Server (SQL 2005). Is it possible to get using SQL statements or WMI ?You can use the sc.exe. To find SQL instances services: sc \\<remote computer name> query | f
in where clause i am using like SELECT name FROM products WHERE id IN ( SELECT product_id FROM orders UNION SELECT 1); it taking time to perform union. please provide some other alternative to improve my query performancewhat about select name from p
Does anyone know of a good script (or good strategy) for doing a fuzzy street address search on a MySQL database? The key issues are: capitalization (easy -- just use LCASE) punctuation (could use REPLACE; not sure it there are more efficient options
I have a problem in retrieve the difference between EntryTime and ExitTime. I have a table named IOData and I am working on IOTime column. The format of the table is: HolderName IODate IOTime IOGateName IOStatus Dinesh Kumar 2010/07/09 00:50:05 Basem
I am attempting to return a rowcount from a subquery as part of a result set. Here is a sample that I've tried that didn't work: SELECT recordID , GroupIdentifier , count() AS total , (SELECT COUNT() FROM table WHERE intActingAsBoolean = 1) AS Approv
My Cursor and Output SET NOCOUNT ON DECLARE @vendor_id int, @vendor_name nvarchar(50) DECLARE @subvendor_id int, @subvendor_name nvarchar(50) PRINT '-------- Vendor Products Report --------' DECLARE vend_cursor CURSOR FOR SELECT * FROM MYSEQ OPEN ven
Consider the tables: (-> denotes a SQL defined relationship) USER (userid, username, imageid->IMAGE.imageid) EVENT (eventid, userid->USER.userid, description) IMAGE (imageid, location) Say I have a view (let's call it vw_UserInfo) defined as the