Is there a function to automatically update a column specifying who created a new record in a sql table? Something similar to the timestamp, but that instead of the time it shows the user who has …
Tag: sql
Get query results for all date values besides current month
I need to get values for data excluding current month and taking this year into account. What I currently have is the following WHERE 1=1 AND CAST(created_at AS DATE) >= ‘2018-01-01’ AND …
Stored function not returning a table in SQL Server
I’m trying to create a stored function called func_GetMenuItemsForMenu. For this function, I need to pass the ID of the menu to it. The function will find all MenuItems that are on the menu. It will …
Using Column Alias as Values in other columns of table in Case statement
I have a sql table that has columns FundId, BreakdownName, BreakdownType and BreakdownValue FundId BreakdownName BreakdownType BreakdownValue F00000OCVS Cash Long 10.69 …
Multi Part Identifier Can Not be Bound
I’m having trouble getting past this error. I’m using SQL Server 2017 (v14): The multi-part identifier “PS_FFC.Date” could not be bound. The multi-part identifier “PS_FFC.Date: could not be bound. …
How to get maximum of Five consecutive values in an Year?
I have a yearly list of sales of an item for the past 20 years. the data is like this. date ; sales value 2001-01-01 ; 423 2001-01-02 ; 152 2001-01-03 ; 162 2001-01-04 ; …
SQL: Having a primary key also be a foreign key
For this question, I am referring to the specific case where you have table T, it has primary key K, but K is a foreign key. Is this valid? And how would you write it in SQL99? All the other …
How to convert varchar to datetime, not working
I have imported some columns from a textfile into my table stuff. I had to import date as varchar(255). I want to convert datatype from varchar to datetime. The format of date data is: 6/2/2018 3:…
SQL Server – Create view using many fields of a row as names of columns
I present to you a simple and short example of what I want to resolve. I need to create a view from two tables. The table indicator stores in a single row the names of the indicators to be measured …
Cognos SQL WITH clause generating syntax error
I have an SQL query I’m running in Cognos 11 and am trying to use a WITH clause but keep getting an error for incorrect syntax near “WITH”. I thought my org admins had disabled WITH but I have …