The intent of the following algorithm is to extract certain set of fields from a key (in this example, extract first 2 fields), and it works. The fields are delimited by a colon: Result: Field-1:Field-2 Microsoft document says that the first parameter is an expression, but I think what they mean by that in th…
Tag: sql-server
Get the newest record using date and time portion, getting error on aggregate function
I am trying to get the most recent record(s) with a status of Registered, Expired, using the status date value to get the latest one. The query I have , I am using a specific lot number that has 13 …
SQL does not recognize tablename from select statement
If I write the tablename after ‘FROM’ the query works. If I use the result of a select statement the query does not resolve. Is there a workaround? I have tried resolving the tablename as an output …
Create a view in SQL Server and lookup with another table
I’m very new to SQL and am trying to create a view in SQL Server using 2 tables. There are some conditions will impact the way of selecting data and I would appreciate some guidance on what’s the …
Trying to write an inner join to filter out some conditions
I’m currently struggling with carrying out some joins and hoping someone can shed some light on this. I have three tables: A,B,C Table C lists names of individuals Table A lists the food they …
Conditionally add a column with a default value to an existing table in SQL Server
I want to add a new column in existing SQL table with default values depending upon some cases/conditions. I want to know if this is possible. If yes how? if not why? Alternative : One option is …
SQL Query with date range Male Female
I have a query that works but I need to incorporate in that query the following: For male date is older or equals 3 months; For female date is older or equals 4 months; SELECT * FROM Davaoci WHERE …
How to add parameters in a SQL select query?
How to add parameters in a SQL select query? string time = 2013-09-25 00:00:00; I wish to use the time variable in the below mentioned SQL query Select LastUpdated from Employee where LastUpdated &…
Selecting and ordering by the top from each country
I am scoring events where there are 2 individuals from each country in an event, BUT only the top finisher from a country receives points. If a country finishes 1st and 2nd, the 2nd place is dropped …
Export ER diagrams from SSMS
I have some ER diagrams created in the development server. I want to export this as PDF and share with my analyst for further usage. The diagram needs to be in PDF format alone since the analyst doesn’…