I have a set of transactions occurring at specific points in time:
CREATE TABLE Transactions (
TransactionDate Date NOT NULL,
TransactionValue Integer NOT NULL
)
The data might be:
INSERT INTO Transactions (TransactionDate, TransactionValue)
VALUES ('1/1/2009', 1)
INSERT INTO Transactions (TransactionDate, TransactionValue)
V...
I have the following need
I have a logging table which logs som leads generated each day.
Now I need to pull a report over the amount of leads for each day over the last 10 days.
Lets say the table looks like this:
tbl_leads
id int,
first_name nvarchar(100),
last_name nvarchar(100),
created_date datetime
And I need to count the num...
Am I correct in saying it is TSQL? I am a novice at database scripting. Is this called scripting? I am a novice at this, really I am.
I just wrote a stored procedure in SQL Server Management Studio:
CREATE PROCEDURE dbo.LogTable_Count
@Count INT OUT
AS
SELECT @Count = Count(ExperimentId) FROM LogTable
GO
I would like to test ...
I have a table that has 4 sets of 25 columns in a BIT concept. Actually field is smallint but it is either 0 or 1 in it's data.
Here is my code that is an attempt to get the total for the first group of 25 cols.
Declare @rows int
, @ID uniqueidentifier
, @LocTotal bigint
select @rows = ( select count(*) from #t1 )
while @rows > 0
...
I have a stored procedure..
Proc:
spMyStoredProcedure
Takes a Param:
@List varchar(255)
The @List would be a comma separated list of values i.e... @List = '1,2,3'
(clarity.. a single value of 1 would mean all records with col1 = true)
I have a table with these columns: ID int, col1 bit, col2 bit, col3 bit, col4 bit.
ID | col1 | ...
I have been given a spec that requires the ISO 8601 date format, does any one no the conversion codes or a way of getting these 2 examples:
ISO 8601 Extended Date 2000-01-14T13:42Z
ISO 8601 Basic Date 20090123T105321Z
...
How can you insert the date in the filename (a dynamic filename) used in a T-SQL backup script? Using SQL Enterprise Manager to create and schedule a backup job, I'd like to edit the T-SQL created to change the filename of the backed up database to be dbname_date.bak (i.e. northwind_5-1-2009.bak). The next time the backup runs, it will...
Hi Friend,
Can somebody please, help me with a query to delete only 500 rows from a table which has 20000 rows. Also has to be older than a particular date.
Thanks for your help,
Soofy
...
Hi,
I would like to hear if any of you have an idea to do the following:
I have one table containing some cardefinitions [id][Company][Mode], this could e.g. be Audi 100, Ford Mustan etc. I then have another field which is a string containing both the car and the model, this could be "Ford Mustang 2.5T", I then need to find the correct I...
Hello,
I have a polygon structure in an sql2005 db as described below.
CREATE TABLE [dbo].[Polygons](
[PolygonID] [int] IDENTITY(1,1) NOT NULL,
[PolygonName] [varchar](255) NOT NULL,
[PolygonColor] [varchar](7) NOT NULL,
[PolygonRuleID] [int] NOT NULL)
CREATE TABLE [dbo].[Polylines](
[LineID] [int] IDENTITY(1,1) NO...
I'm copying data from one database to another and massaging the data while I'm at it. Both databases have tables called Clients and Jobs.
However, in database "Alpha" the Jobs table does not have a relationship to the Clients table, where database "Epsilon" does. Alpha's Jobs table just has the Clients name in an nvarchar column.
I...
The title kind of says it, but I’ll elaborate a bit.
I use SQL Server 2005, and I'm writing an export query that’ll return a list of users. Some users have profile images, some don’t. The profile image is not represented in the database, at all. There’s just a file on the filesystem, named [username].jpg. So what I need to do is to chec...
Hello,
I am querying a database and I have 2 bit columns I need to combine (for this example if one is true the column must be true).
Something like: Select col1 || col2 from myTable
What is the easiest way of achieving this?
...
Here is an example of my input csv file:
...
0.7,0.5,0.35,14.4,0.521838919218
0.7,0.5,0.35,14.4,0.521893472678
0.7,0.5,0.35,14.4,0.521948026139
0.7,0.5,0.35,14.4,0.522002579599
...
I need to select the top row where the last float > random number. My current implementation is very slow (script has a lot of iterations of this and ou...
Let's say I have a table:
SELECT SUM(quantity) AS items_sold_since_date,
product_ID
FROM Sales
WHERE order_date >= '01/01/09'
GROUP BY product_ID
This returns a list of products with the quantity sold since a particular date. Is there a way to select not only this sum, but ALSO the sum WITHOUT the where condition? I'd like...
MyDataSource.SelectParameters["startDate"].DefaultValue =
fromDate.SelectedDate.Date.ToString();
As you can see I am setting the default value of a parameter in my .Net SqlDataSource. I don't think the string is outputting the correct format though. What is the correct format so a T-SQL Datetime wil...
I am looking for a way to increment a uniqueidentifier by 1 in TSQL. For example, if the id is A6BC60AD-A4D9-46F4-A7D3-98B2A7237A9E, I'd like to be able to select A6BC60AD-A4D9-46F4-A7D3-98B2A7237A9F.
@rein It's for a data import. We have an intermediate table with IDs that we're generating records from, and we join on those IDs later...
For example, if I wanted to know the current value of the quoted_identifier server option, is there a query that can give me this information?
...
sql server 2005 : i have a column empid in employee table with identity on.if there is some error while inserting data into table .identity is incremented .i want identity to be incremented only if record is inserted .like if i have generated emp id from 1 to 5 and then on 6th record insertion error ocurrs.and on next record insertion id...
I have a problem getting Stored Procedure debugging to work in Visual Studio 2008: When I start debugging, I get these success messages in the output window, however the actual stored procedure windows does not show up.
Auto-attach to process '[1640] [SQL] stagsql' on machine 'stagsql' succeeded.
The thread 'stagsql [67]' (0xf80) has ex...