Easy Stuff
Jul 1, 2004hi.. guys this is simple for you guys how can i make ms access to display the current date in a col.... when i go to insert a new line i how can i make it so that its allready there? i dont have to type it??????
View 3 Replieshi.. guys this is simple for you guys how can i make ms access to display the current date in a col.... when i go to insert a new line i how can i make it so that its allready there? i dont have to type it??????
View 3 RepliesHi all,
I'm running under Windows Server 2000 datacenter sp4 with sql server 2000 Sp4
on 16GB Ram.
I enabled the /PAE in the boot.ini file and also enabled the AWE and set the SLQ Server maximum memory to 6144.
Do I need to include the /3GB switch in the boot.ini file?
I'm a little bit confused with the article found on the site. http://support.microsoft.com/default.aspx/kb/274750
Here are the lines.
Use of the /PAE switch in the Boot.ini and the AWE enable option in SQL Server allows SQL Server 2000 to utilize more than 4 GB memory. Without the /PAE switch SQL Server can only utilize up to 3 GB of memory.
or-Use of the /3GB switch in the Boot.ini file allows SQL Server 2000 to use up to 3 GB of available memory.
Regards,
Larry
Hi,
You might just be able to save me downloading and installing SQL Server French...
I'm having localization problems with some .NET code - and I might be able to solve the problem if I know how SQL is parsed in different locales. Say my table MyTable contains a float column FloatColumn. In English, I would say
SELECT * FROM MyTable WHERE FloatColumn = 2.3
If my locale was, say for argument's sake, French, would I have to write
SELECT * FROM MyTable WHERE FloatColumn = 2,3
???
Thanks for your help,
T
Overview. Machine data is fed into DOWNTIMELOG via a Cimplicity. I do not have the ability to change the way that it goes in. It contains the time that a machine has stopped and where the stoppage has occurred. Via a web page I want to give the operator the amount of time the machine stopped. From that they will provide some more detail. As they enter time, I need to subtract what they entered from the total (DOWNTIMELOG). That is the reason I created ENTERED_TIME. [PDNTOTAL_TEMP_VAL0] hold the total time for each stoppage, [TOTTIME] is intended to hold the value that has been accounted for. [DWNCATEGORY_TEMP_VAL0] holds the category and matches up with [DWNCATEGORY]. Also, I need to match Date and Shift. The problem is that DOWNTIMELOG does not capture shift. However, 1st shift occurs between 700 and 1500, 2nd shift occurs between 1500 and 2300, 3rd shift occurs between 2300 and 700. 3rd shift presents a problem as it occurs across 2 dates. Could someone please help me with a query that provides the net between the two tables that is matched by date, shift and category?
CREATE TABLE [dbo].[DOWNTIMELOG] (
[timestamp] [datetime] NOT NULL ,
[DWNTIMESTAMP_VAL0] [varchar] (25) NULL ,
[UPTIMESTAMP_VAL0] [varchar] (25) NULL ,
[PDNHOUR_VAL0] [int] NULL ,
[PDNMIN_VAL0] [int] NULL ,
[PDNSEC_VAL0] [int] NULL ,
[PDNTOTAL_TEMP_VAL0] [int] NULL ,
[DWNMSG_TEMP_VAL0] [int] NULL ,
[DWNCATEGORY_TEMP_VAL0] [varchar] (50) NULL
CREATE TABLE [dbo].[ENTERED_TIME] (
[REC_ID] [int] IDENTITY (1, 1) NOT NULL ,
[DWNCATEGORY] [varchar] (50) NULL ,
[DWNMSG] [int] NULL ,
[ENTRYDATE] [smalldatetime] NULL ,
[SHIFT] [int] NULL ,
[TOTTIME] [int] NULL
Where can i learn about making the sql server execute task when a certain situation happens. Like lets say make the server delete all entrys older than 40 days? Or have a entry deleted automatically when a certain situation happens like lets say it take 4 votes and a entry get deleted how do i make it do that automatically
View 2 Replies View RelatedThis is my code, table and result,
declare @t_JobNoticeID table (cvid int, JobNoticeID int)
insert into @t_JobNoticeID values(2456, 24);
insert into @t_JobNoticeID values(4000, 124);
insert into @t_JobNoticeID values(245, 9);
insert into @t_JobNoticeID values(2456, 19);
insert into @t_JobNoticeID values(4000, 904);
insert into @t_JobNoticeID values(4000, 11);
insert into @t_JobNoticeID values(24, 19);
[Code] ....
My question is -
How update statement looks like compare RESULT A1 with x_JobMatching?
So, my FINAL RESULT shown as follow,
CVIDJobNoticeIDisMatch
1925450
6590690
459130
2456191
4569110
40009041
24560
900240
24191
Hello,I need to be able to replace only the first occurance of a space characterin a column.Reason being is the data in the column I am trying to replace seems to haveumpteen space characters after each entry, so a simple replace functionwill replace all the spaces after it with what I want!I have thought of RTRIM to get rid of the spaces after and then replace, Ihave also thought of CHARINDEX to find the first occurance of a space andSTUFF to replace it.I have done my homework on these functions!But I am having trouble writing such a statement,I've never written a query which would use more then one function on onecolumn you see and I am getting confused!I'll tell you what I want to do in simple stepsReplace only the first found space in a name column, but then if a name hasa middle initial that will be a problem,Replace that with a dot.then concatanate '@emailaddress;@emailaddress2' after itso when SQLServer does the select it will bring back something likejoe.bloggs@emailaddress;emailaddressBut I guess I'd also need joe.n.bloggs@emailaddress;emailaddressThe data in the column looks like this at the momentjoe bloggsBut I guess there may come a time when we havejoe n bloggs, just to complicate things!What is your advice, and how do I write a query like thisI have been playing around with it in Query Analyser but as I said I amgetting confused and need some help if you don't mindThanks a lot to all who reply :-)RegardsJayne
View 2 Replies View RelatedFor example if I make a column not null the SQL Script generated.
Removes all indexes, keys, etc... than creates a temp tableThan moves the data into the temp tablethen deletes the old tablerenames the temp tableRecreate all the indexes, keys, etc...
Is there a structure reason for it? Like now that the DB is being alerted that the column is not null it wants to re insert all the data so it can re-organize it?
Because I can just write my own script to the effect of
ALTER [TABLE] [COLUMN] PARAM TYPE NOT NULLone line of script that seemingly does the exact same thing..
So I'm just curious when I change a column to non null why doesn't it just generate a simple one liner?
Hi
View 1 Replies View RelatedI have this query that calculates the next possible shipping day, based on 3 conditions:
- It has to be a workingday (WORKTIMECONTROL: 1 workingday, 0 holiday) - marked green
- There might be extra days (@xdays) required by the process - marked blue
- Customer wants their goods to be shipped on special days - marked red:select TOP 1 Transdate
from WORKCALENDARDATE
where Transdate > @startday and WORKTIMECONTROL = 1 and DATEPART(WEEKDAY,TRANSDATE)-1 in (2,4) and
[code]...
So customer 123456 accepts shipping of goods only on tuesday and thursday as in the above example "... in (2,4)". Multiple shipping days means that the Subquery returns more than one record, which gives me a headache as I don't see how to integrate this portion into my query. I tried to use the stuff function as I formally need a result that can be provided that way; but the format is incorrect as it in varchar, while an array of integer is needed.
DATEPART(WEEKDAY,TRANSDATE)-1 in (select stuff((select ',' + CAST(DELIVERYDAY as nvarchar) from CollectiveShipment where custaccount = '123456'
for xml path('')),1,1,''))
Hi,
This is probably for most of you a very basic question. My goal is to define in a seperate instance from application all infos related to DataSets and DataAdapters that are needed when connecting to a specific database. Why?
First, I would like to be able to have in a single instance everything needed when hooking to a SQL Server Express database and in an other everything needed when hooking to a SQL Server CE database. Then, from application, I would like to be able following a few basic configuration steps to choose from one or the other, or even both in specific cases.
Second, I want to be able to seperate Database related stuff from application so that I can re-use everything from any other application when needed.
I've read several books, articles on the subject and would like to have your opinion as several approaches were illustrated through them. What would you use for this:
- Component class?
- Class library?
- or else?
Any good articles on the subject?
Thanks in advance for sharing,
Stéphane
CREATE TABLE BILL_DETAIL
([objid] int,[x_billable_to] varchar(19), [x_bill_quantity] int,
   [x_billable_yn] int, [x_bill_rate] int,  [COST_TYPE] varchar(19) )
INSERT INTO BILL_DETAIL
([objid], [x_billable_to], [x_bill_quantity], [x_billable_yn], [x_bill_rate],[COST_TYPE])
[code]...
how to get records using stuff keyword as above i want to query using where condition with where objid=1 and should frame output as Parking, Toll only 1 input parameter need to given.
Since I couldnt find an easy way to connect Orcas Beta 2 with SQL CE 3.1
I'll try by a connection string
since im totally new at this
does anyone have any idea how to get started?
Thxs!
I'm implementing merge replication between SQL CE and sql server 2005 SP2. Here is the problem I'm facing
I have dynamic filters on some tables like
Select * from table1 inner join table2
ON table1.field1 = table2.field3
and table2.flag = true
When table2 flag turns true then all the matching records in table1 should be returned to the subscriber.
But that is not happening. The filter does not return any records to the subscriber even though i see records when i run the query on the server. My take on this is the publisher thinks there is no changes on table1 so there is nothing to update. So to fix that i run dummy updates like
update table1
set [name] = [name]
where table1.field1 in
(Select field2 from table2 where flag=true)
This updates the records and the publisher updates the subscriber the first time. When i set the flag to false, it is supposed to remove the data from the subscriber but i get this error.
The merge process failed because it detected a mismatch between the replication metadata of the two replicas, such that some changes could be lost leading to non-convergence. This could be due to the subscriber not having synchronized within the retention period, or because of one of the replicas being restored to a backup older than retention period, or because of the publisher performing more aggressive cleanup on articles of type download-only and articles with partition_options = 3. (Source: MSSQL_REPL, Error number: MSSQL_REPL-2147199363)
Get help: http://help/MSSQL_REPL-2147199363
The common generation watermark is invalid at this replica since it does not exist or metadata for changes not yet propagated may have been cleaned up. (Source: MSSQLServer, Error number: 21800)
Get help: http://help/21800
I have no idea whats going on. Any clues, anyone? Thanks for your help.
Ramesh
I have a project. Originally when I created this project, I called it "Project_A", (and I did not create a solution directory).
Doing this created a folder called "Project_A" with the following files within it. I guess these are meta data files and I shouldnt be messing around with them. Anyway, I see
(1) Package.dtsx (The default package that gets created with a new project)
(2) Project_A.database
(3) Project_A.dtproj
(4) Project_A.dtproj.user
(5) Project_A.sln
(6) Project_A.suo
When I rename my project in the Solution Explorer to "Project_B", the following happens in my folder.
Everything remains the same except Project_A.dtproj gets renamed to Project_B.dtproj and a new file called Project_B.dtproj.user gets created.
Now, my questions.
Question 1: What if I wanted my folder to have the same name as my project? Can I just change the folder name in Windows Explorer without having any ill-behaviors later on? I always have 1 project to 1 solution so I want to use the convention of keeping my folder named the same as my project.
Question 2: What about the files that are still named with Project_A dot blah blah. Is it bad if I renamed these to Project_B dot blah blah?
A whole bunch of exciting new stuff announced around the Visual Studio Express Editions today. VS Express is now free for good, not just 1 year (just like SQL Server!). Also lots of great new content and fun projects to do.
See Dan Fernandez's blog posting at http://blogs.msdn.com/danielfe/archive/2006/04/19/579109.aspx for lots of details.
Best, MJ
Hi everyone,
Primary platform is 64-bit on A-P cluster.
Our needs are on yearly basis and on monthly basis. We're forced to keep up five years for the majority of the production tables.
In terms of years, I see three ways:
1.Create all the ranges for a FILEGROUP with a only NDF
2004, 2005, 2006 => FG1 => ONE.NDF
2.Create all the ranges for a FILEGROUP along with more than one NDF.
2004, 2005, 2006 => FG1 => ONE.NDF
TWO.NDF
3.Create each range to a FILEGROUP where there will be one NDF or (n) NDF
2004 => FG0=> ZERO.NDF
2006 => FG1 => ONE.NDF
2005 => FG2 => TWO.NDF
What is the best approach in terms of availability, performance and best practices? Maybe is a silly question, I'm sorry if it is.
As usual, thanks a lot for your time.
I'm trying to do some basic stuff in SQL Server 2005 that I could do in Oracle. I'm sure there's a way to do these things, I just don't know how. My most immediate question is this:
Is there any easy way to run a SQL script and have it spool to HTML tables to a file? The 'results to text' from SSMS is not adequate for display purposes. I'm trying to display table/column descriptions.
Beyond that, does anyone know of any good resources that provide an 'Oracle to SQL Server' matrix so I can help figure out how to do some of these things in SQL Server?
Thanks in advance,
Mike
Hi everyone,
BACKGROUND:
I just set up a network with 2 computers (direct cable network, no routers/hubs), one computer is running Windows 2000 Server and the other is running Windows XP Professional. They both recognize each other and I can access each computer on either computer. The WinXP computer has SQL Server 2005 express edition installed on it.
BASIC PROBLEM:
I am trying to install a database server on my Windows 2000 Server OS computer. This computer is a 350MHz, 256mb RAM computer. How would I go about doing this?
Thanks.
I have the following query that supposes to merge multiple result in a single one and put it into a temporary table:
SELECT DISTINCT [AlphaExtension],
STUFF((SELECT A.[NoteText] + '< BR />' FROM #temp A
WHERE A.[AlphaExtension]=B.[AlphaExtension]
FOR XML PATH('')),1,1,'') As [NoteText]
FROM #temp B
GROUP BY [AlphaExtension], [NoteText]
It is working fine unless by a simple detail. If you look at the second line of the query you will see that I am stuffing together a < BR /> tag (break line) because the contents of the field is going to be spitted directly to the screen and I want that the multiple results be displayed in different lines.
OK, the issue is that it is stuffing & lt ; BR / & gt ; instead < BR /> and therefore the browser is displaying the tag instead to break a line.
I have a column which needs to be 9 digits long. The first four digits are independent from the other digits. The following digits need to be 5 and I have to add leading zeros if they're less than 5. This is an awful design and I'd love to change it but I can't.
SELECT Cg.Fiid,
--Original Formula
SUBSTRING( CONVERT( varchar, Cg.Fiid ),1, 4 ) + RIGHT( '00000' + SUBSTRING( CONVERT(varchar, Cg.Fiid ), 5, 10 ), 5 ),
--My solution
STUFF(Cg.Fiid, 5, 0, REPLICATE('0', 9 - LEN(Cg.Fiid)))
FROM (VALUES(71927),
(498932),
(498934),
(38061278))Cg(Fiid)
I found something very strange...stufff function working with self join but not working with left or right join,. I have a table
**Id name**
1 samar
1 Harry
2 jack
I want the output as
**Id name**
1 samar Harry
2 jack
The below query works fine with self join
Select b.id, stuff ((select ` ` + a.name from #test a where a.id = b.id
for xml path (``)),1,1,``)
From #test b
Group by id
But when i do right join i get error _ invalid object name `b`. ....
Select b.id, stuff ((select ` ` + a.name from #test a
right join b on b.id = a.id for xml path (``),1,1,``)
From #test b
Group by id
Hi all,I'm hoping somebody here might be able to point me in the rightdirection.Basically, I'm looking for a "good" way to build tables such thatdifferent kinds of stuff can grouped.For example, let's say I have "rooms" and they can contain "people"and/or "books" and/or "furniture" -- each of those objects (rooms,people, books, furniture, etc) may have their own attributes -- but theidea is that a room may contain 0 or more of each of the others.I'll need to do lots of selects to retrieve the contents of specificrooms.Is there a standard / good way to go about this sort of thing?Somehow giving people, books, furniture a room_ID (foreign key) seems abit clumbsy -- ie, do I have to run a select for each?thanks kindly, -Scott
View 6 Replies View RelatedI would like to have some key-value pairs set up in the form of a XML file and read the same from within a SSIS package. What I mean is something like business information needs to be configured using XML or INI or something similar. Could anyone help me with a similar sample solutions or give me some links which will lead me to the solution.
View 5 Replies View RelatedI think it was Pat Phelan who posted a little trick here where he used the STUFF function to create a string fo values from a column without using a cursor.
I am starting a brand new project and I did my table design and I am awaiting a finalized requirements document to start coding and I thought I would spend a little time writing some code to autogenerate some generic one record at a time SELECT, INSERT,UPDATE and DELETE stored procedures. With the coming holiday things are getting quiet around here.
The code that is not working is listed below. It does not work. It returns Null. I suck.
DECLARE @column_names varchar(8000)
SET @column_names = ''
SELECT @column_names = STUFF(@column_names,LEN(@column_names),0,C.COLUMN_ NAME + ', ')
FROM INFORMATION_SCHEMA.COLUMNS C
WHERE TABLE_NAME = 'MyTable'
SELECT @column_names
little help?
I downloaded the AdventureWorks2012 OLTP script. When I ran it it gave me some errors. I also noticed that it tried to install into the bult-in master database, it created a lot of tables and objects. Some questions :
1) How can I remove everything that the script installed into master database?
2) Do I need to create 1st an empty database and then run the script there?
3) I am running the script from a custom path (C:DownloadsMicrosoft SQL Server 2012AdventureWorks 2012 OLTP Script.zipAdventureWorks 2012 OLTP Script) not sure if this is causing some of the errors as the script, in the beggining has a path to other folders :
:setvar SqlSamplesDatabasePath  "C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERMSSQLDATA"
-- NOTE: Change this path if you copied the script source to another path
:setvar SqlSamplesSourceDataPath "C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVERToolsSamplesAdventureWorks 2012 OLTP Script"
4) Final question, I also downloaded the AdventureWorks 2012 simple database (AdventureWorks2012_Data.mdf). Is this file the same database as the one created by the OLTP script?
I'm banging my head against the wall. It's probably pretty simple so here goes...
I have a form that supposed to add records to a table on the database. I'm pretty sure I have the dataAdapter and Dataset set right but when I add a record, it complains that the primary key can’t be null. I’ve tried different things, including removing those fields and variables from the stored Proc, changing the Identity Properties of the Table, changing the AutoIncrement settings on the Dataset for that field, but all give me different errors. Nothing actually makes it work. This database has many records in it and the Primary key is a decimal field that starts at 5, then next was 10, then 28, then it started getting consecutive after 110. (111, 112, 113, etc.) (I'm porting over an old database to a new web site, so I'm somewhat contrained by the database.)
I guess my question is for adding records in to a database that has a primary unique key constraint. Certainly this is a pretty common thing. Obviously I do not want users to enter that in themselves, I thought it should simply autocreate/autonumber. So what is the best procedure and gotcha’s I need to watch out for?
if i have the following code, how do i know if the transaction was actually successful, so basically where in this code can i write TRANSACTION SUCCESFUL?
try
{
//Open up the connection
conn.Open();
//Setup the Transaction
trans = conn.BeginTransaction();
//First query in transaction
pre_query = "Delete from Menu where spec_name="
+ "'"
+ spec_name_array[i].Text.ToString()
+ "'" ;
//Second query in transaction
query = "INSERT into Menu VALUES ('"
+ Calendar1.SelectedDate
+"','"
+ spec_name_array[i].Text.ToString()
+"','"
+ spec_desc_array[i].Text.ToString()
+"','"
+spec_price_array[i].Text.ToString()
+"',1)";
SqlCommand comm = new SqlCommand(pre_query,conn);
//Setup the command to handle transaction
comm.Transaction = trans;
//Execute first query
comm.ExecuteNonQuery();
//Add in second query
comm.CommandText = query;
//Execute second query
comm.ExecuteNonQuery();
trans.Commit();
}
catch(SqlException ex)
{
com_label.Text = "Submission Not complete, did you forget the date or something else?";
//Undo all queries
trans.Rollback();
}
finally
{
conn.Close();
}
This may not be the right place for this post...but my head is hurting and I can't think right now.
I have a SQL table of users. Each record has a required 'Birthdate' field. I'd like to order this by the days left till the give birthday, keeping in mind that the year may be 1980 or their birthday might have been 2 weeks ago.
Can someone cure my headache?
I have written 2 custom connection mgr€™s.
One connects the data from an oracle source
One connects so I can put the data on a sql server.
These both work well and it makes it a lot easier across development, test, production.
But now I would like a good way to do this
I have 10 tables to copy from oracle. The only difference is just the name of the table.
static string[] g_tables =
{
"table_name_1",
"table_name_2",
"table_name_3",
€¦
};
foreach (string str_table in g_tables)
{
Oracle.DataAccess.Client.OracleCommand OracleCommand = new Oracle.DataAccess.Client.OracleCommand
(
"select * from " + str_table,
OracleConnection
);
Oracle.DataAccess.Client.OracleDataReader OracleDataReader =
OracleCommand.ExecuteReader();
// dump out to raw file destination
}
I understand there are some pieces left out but that is the basic idea. It seems like I€™m going to have write custom pieces for each step.
It does not seem like there is any advantage to using SSIS. Should I give up now and stick to writing windows services for stuff like this?
I could just write a specific piece for each table but the only difference is the table name.
I need to determine the top 20 most frequent occurences of a value in a specific field using SQL.
My table structure...
enddt datetime(8)
status varchar(20)
when enddt time equal to server time.
I want to change status field to expired.
What is the easy way to do this?.
enddt status
8/22/2005 7:00:00 PM expired
9/22/2005 8:30:00 PM expired
10/30/2005 7:30:00 PM live
11/22/2005 9:30:00 PM live
I completely forgot how to do this. I want one of my groups in the matrix to take its week number (1-7) as Monday-Sunday.
so it would kind of be like this:
=IIF(Fields!DayOfWeek.Value=2,"Mon",
ELSE(Fields!DayOfWeek.Value=3,"Tues",
Else(Fields!DayOfWeek.Value=4,"Wed",
etc etc
Am i doing this right, or am i off??