HiI been looking around how to get the date part and not the date & time. So I found this CONVERT(VARCHAR(10),TimeDateStamp,101). I know the 101 they said is the format of the date( mm/dd/yy).They said there are others but the link they give is dead and I don't know what you call this 101 character code.So where do I get a list of this stuff?Thanks
We are developing a new online booking system with asp.net and looking for optiosn for the data store. Currently the PHP applciation utlizes MySQL but we would like to use SQL Server in the rewrite. What limitations would we run into with Express over Standard for such a system? Is the 4GB size limit and advanced SQl features such as replication, etc the only differences? We are looking for something to run on a dedicated or VPS based Windows server that will only be running our app and database. System is an online hotel type booking system with approx 7000-12000 transactions per month which may double in the coming year. Express certainly has a cost advantage but we don't want to run into issues with this version if there are any we should watch out for.
I am building a small app that will display availability data for properties. I have a calendar that displays the dates for a whole year in month rows with each days colour representing the availability status, i.e. booked, on hold etc. My question is about how to store these dates in the db. At the moment I have the table below: TABLE Availability [PropertyID] [int] NOT NULL , [StatusID] [tinyint] NOT NULL , [StartDate] [smalldatetime] NOT NULL , [EndDate] [smalldatetime] NOT NULL I was planning on having four status's for any given date, unknown, available, on hold or booked. Displaying the dates has proved pretty simple but updating availability means I would need to query the db to see if any of the dates overlapped, I would then have to add the new date range/status as well as change any date ranges that overlapped, either in the sp or in the code and this is what made me wonder if there was a better way. Does this sound a reasonable approach? Any advice or pointers would be greatly appreciated, This is the first time I have had to store date ranges and I want to make sure I am doing it right.
How can I do this with Parameters? I can get a single parameter to filter for a single date (or even a combo list of the dates in DB). But I want my parameters to interact so that they specify a range. Is this possible?
Today I have got one scenario to calculate the (sum of days difference minus(-) the dates if the same date is appearing both in assgn_dtm and complet_dtm)/* Here goes the table schema and sample data */
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[temp_tbl]') AND type in (N'U')) DROP TABLE [dbo].[temp_tbl] GO CREATE TABLE [dbo].[temp_tbl]( [tbl_id] [bigint] NULL, [cs_id] [int] NOT NULL, [USERID] [int] NOT NULL,
I have a table that has hotel guests and their start stay date and end stay date, i would like to insert into a new table the original information + add all days in between.
I want to know if there is a way to compare dates in the sql statement with dates that I input into a database and todays date. the datatype that I'm using is smalldatetime.The statement I used is:Select Date from Table where Date > 'Today.now'I get an errorCould this be done or is there another approach?
I have to implement some logic in a view and I don't know how to do it. Let me outline the logic:
- I'm working with a view where records represent participant activities. - Some participants can have numerous activities. - Each activity has a start date and an activity code. - Only records with activity code 23 or 33 appear in the view currently.
What I need to do is NOT include records where the participant has another activity with code 26 (from another table, the one the current view is derived from) which has the same start date as the activity 23/33 record in the view currently. Also, this should only be implemented if the start date is the first start date (minimum start date for that participant).
I've noticed that there are a lot of questions on this forum, but not as many thank you's. I'm far from a DBA (more of a simple, small town, one stop shop), but have learned tons of information from reading your posts. I certainly appreciate everyone's willingness and excitment to contribute to the SQL community. So here's to you...thank you!
What am i doing wrong with this im tired and for the life of me it wont work Cheers Phil
if (Select sum(Unitprice*qtysold) from #DataExport_tmp where recordtype = 'L'group by transref )<> select Totalcost from #DataExport_tmp where recordtype = 'T' BEGIN PRINT 'no good' end
i use windows vista and installed visual net 2005 and sqlserver 2005 but i have some proplem: my step: 1.open vs net 2005 2.make one project 3.make one button 4.get data->datagridview 5.choose add data source 6.choose new data---> this step then choose microsoft sql server 7.typing servername 8.choose attach a database file and choose browe.. 9.link to folder have database(.dbf) but i have worked them very much but not run for me i dont know why it is like that
"login faild"or you dont have permission to pen this filecontact the file ower or an administrator to obtain permissio
pls help me i very need for learning
my Y!M: phok28a@yahoo.com pls contact me and help me
Hey guys... i cant figure this out for the life of me. I have a long T-sql query, and when i enter the string "Rental" into the Listingtype, it says invalid column name "Rental" ... im not looking for the value to be a column, im looking for it to match the value in the ListingType column... here's the query:
IF @Studio IS NOT NULL SET @SQL = @SQL + ' AND r.StudioFlag = ' + CONVERT(VARCHAR(20), @Studio) IF @Br1 IS NOT NULL SET @SQL = @SQL + ' AND r.BRFlag1 = ' + CONVERT(VARCHAR(20), @Br1) IF @Br2 IS NOT NULL SET @SQL = @SQL + ' AND r.BRFlag2 = ' + CONVERT(VARCHAR(20), @Br2) IF @Br3 IS NOT NULL SET @SQL = @SQL + ' AND r.BRFlag3 = ' + CONVERT(VARCHAR(20), @Br3) IF @Br4 IS NOT NULL SET @SQL = @SQL + ' AND r.BRFlag4 = ' + CONVERT(VARCHAR(20), @Br4) IF @OverBr4 IS NOT NULL SET @SQL = @SQL + ' AND r.OverBRFlag4 = ' + CONVERT(VARCHAR(20), @OverBr4) IF @Condo IS NOT NULL SET @SQL = @SQL + ' AND r.CondoFlag = ' + CONVERT(VARCHAR(20), @Condo) IF @ListingType IS NOT NULL SET @SQL = @SQL + ' AND r.ListingType = ' + CONVERT(char, @ListingType) IF @WindowAir IS NOT NULL SET @SQL = @SQL + ' AND a.WindowAir = ' + CONVERT(VARCHAR(20), @WindowAir) IF @CentralAC IS NOT NULL SET @SQL = @SQL + ' AND a.CentralAir = ' + CONVERT(VARCHAR(20), @CentralAC) IF @BalconyDeckPatio IS NOT NULL SET @SQL = @SQL + ' AND a.BalconyDeckPatio = ' + CONVERT(VARCHAR(20), @BalconyDeckPatio) IF @UseOfYard IS NOT NULL SET @SQL = @SQL + ' AND a.UseOfYard = ' + CONVERT(VARCHAR(20), @UseOfYard) IF @Dishwasher IS NOT NULL SET @SQL = @SQL + ' AND a.Dishwasher = ' + CONVERT(VARCHAR(20), @Dishwasher) IF @WasherDryer IS NOT NULL SET @SQL = @SQL + ' AND a.WasherDryer = ' + CONVERT(VARCHAR(20), @WasherDryer) IF @Fireplace IS NOT NULL SET @SQL = @SQL + ' AND a.Fireplace = ' + CONVERT(VARCHAR(20), @Fireplace) IF @EIK IS NOT NULL SET @SQL = @SQL + ' AND a.EIK = ' + CONVERT(VARCHAR(20), @EIK) IF @HardwoodFloors IS NOT NULL SET @SQL = @SQL + ' AND a.HardwoodFloors = ' + CONVERT(VARCHAR(20), @HardwoodFloors) IF @BroadBandNet IS NOT NULL SET @SQL = @SQL + ' AND a.BroadbandNet = ' + CONVERT(VARCHAR(20), @BroadbandNet) IF @TV IS NOT NULL SET @SQL = @SQL + ' AND a.TV = ' + CONVERT(VARCHAR(20), @TV) IF @Thermostat IS NOT NULL SET @SQL = @SQL + ' AND a.Thermostat = ' + CONVERT(VARCHAR(20), @Thermostat) IF @LandlordNotPresent IS NOT NULL SET @SQL = @SQL + ' AND a.LandLordNotPresent = ' + CONVERT(VARCHAR(20), @LandLordNotPresent) IF @Smoking IS NOT NULL SET @SQL = @SQL + ' AND a.Smoking = ' + CONVERT(VARCHAR(20), @Smoking) IF @NoPetsAllowed IS NOT NULL SET @SQL = @SQL + ' AND a.NoPetsAllowed = ' + CONVERT(VARCHAR(20), @NoPetsAllowed) IF @Cat IS NOT NULL SET @SQL = @SQL + ' AND a.Cat = ' + CONVERT(VARCHAR(20), @Cat) IF @MoreCats IS NOT NULL SET @SQL = @SQL + ' AND a.MoreCats = ' + CONVERT(VARCHAR(20), @MoreCats) IF @SmallDog IS NOT NULL SET @SQL = @SQL + ' AND a.SmallDog = ' + CONVERT(VARCHAR(20), @SmallDog) IF @LargeDogs IS NOT NULL SET @SQL = @SQL + ' AND a.LargeDogs = ' + CONVERT(VARCHAR(20), @LargeDogs) IF @Doorperson IS NOT NULL SET @SQL = @SQL + ' AND a.Doorperson = ' + CONVERT(VARCHAR(20), @Doorperson) IF @IngroundPool IS NOT NULL SET @SQL = @SQL + ' AND a.IngroundPool = ' + CONVERT(VARCHAR(20), @IngroundPool) IF @AboveGroundPool IS NOT NULL SET @SQL = @SQL + ' AND a.AboveGroundPool = ' + CONVERT(VARCHAR(20), @AboveGroundPool) IF @Elevator IS NOT NULL SET @SQL = @SQL + ' AND a.Elevator = ' + CONVERT(VARCHAR(20), @Elevator) IF @UseOfGarage IS NOT NULL SET @SQL = @SQL + ' AND a.UseOfGarage = ' + CONVERT(VARCHAR(20), @UseOfGarage) IF @LaundryFacilities IS NOT NULL SET @SQL = @SQL + ' AND a.LaundryFacilities = ' + CONVERT(VARCHAR(20), @LaundryFacilities) IF @HealthCenter IS NOT NULL SET @SQL = @SQL + ' AND a.Health Center = ' + CONVERT(VARCHAR(20), @HealthCenter) IF @StorageAreas IS NOT NULL SET @SQL = @SQL + ' AND a.StorageAreas = ' + CONVERT(VARCHAR(20), @StorageAreas) IF @WheelchairAccess IS NOT NULL SET @SQL = @SQL + ' AND a.WheelchairAccess = ' + CONVERT(VARCHAR(20), @WheelchairAccess) IF @BusinessCenters IS NOT NULL SET @SQL = @SQL + ' AND a.BusinessCenters = ' + CONVERT(VARCHAR(20), @BusinessCenters) IF @RentChargeMin IS NOT NULL AND @RentChargeMAX IS NOT NULL SET @SQL = @SQL + ' AND a.RentCharge BETWEEN ' + CONVERT(VARCHAR(20), @RentChargeMin) + ' AND ' + CONVERT(VARCHAR(20), @RentChargeMax) IF @RentChargeMin IS NOT NULL AND @RentChargeMAX IS NULL SET @SQL = @SQL + ' AND a.RentCharge >= ' + CONVERT(VARCHAR(20), @RentChargeMin) IF @RentChargeMAX IS NULL AND @RentChargeMAX IS NOT NULL SET @SQL = @SQL + ' AND a.RentCharge <= ' + CONVERT(VARCHAR(20), @RentChargeMax)
this query works, i want to add a 4th column that is the value of the 3rd column subracted from the value of the 2nd column, how can i add this?? SELECT `tagid` AS w1, (SELECT count( `value` )FROM tagsWHERE `value` =1AND `tagid` = w1) AS w2, (SELECT count( `value` )FROM tagsWHERE `value` =0AND `tagid` = w1) AS w3FROM tagsWHERE `value` > -1GROUP BY `tagid`ORDER BY w2 DESC
I know thsi is a silly question but gonna ask it anyway :)
When you are using the 'insert' statement to insert records in to a database are all of the fields in the db table required for a successfull adding of a record.
Just that i have 16 fields in my db table and want to insert only 11 fields in to the new record and it is giving me an error, and i am sure my SQL is correct
I just need something verified.. This has to do with IP's and names. We have a sql failover cluster. So is that 4 names.. One for each local machine, one for the cluster itself and one for the sql portion? I guess my question is can the cluster group and sql have the same name and IP or do they need to be different.
Does any one know a quicker way to get data in from TableA to TableB. Both tables have the same structure(Acct# varchar(9); Type varchar(12); Date1 datetime; Date2 datetime; Date3 datetime; Date4 datetime; and Date5 datetime No Nulls allow in Acct & Type field.
TableA has 5.5 Million Rows and TableB has about 1 million rows , I wrote a Stored Proc using cursor to select from TableA insert into TableB if the Acct# and Type doesn't exists.
I didn't want to use bcp because I only wanted rows(Acct#'s) that exists in TableA that where not in TableB. My procedure is working but at a rate of 100 records per minute. Any suggestions?
I have a client that's insisting on deploying SQL Server 2000 as Windows Authntication mode only (not mixed mode). I've always done mixed mode in the past and I'm just looking for some input here. So, what's everyone think?
try to guess what the result is for this query before you run it:SELECT 123.654, 123d6, 123e4, '123'e4comments welcome, but please do not spoil it for anyone who hasn't tried it yet
For a query like below ... How do i have to select only the latest revisions, if i need to filter last current revisions of each document ... where the revision could be either alphabetical or even numerical ...
Presently I get all revisions with the below query ... Note: csd_revi is the field of CSD table for revisions.
I asked a question over the weekend and got a answer very quick. I'm new to stored procedures and have to do a insert into two tables. I need to insert into the first table (Journal_log). This table has a colunm ID that is Identity is set to yes. After inserting that record I need to retrieve the ID from the Journal_log that I just inserted and insert it into the second table (District_Journal) with data for a new record into the second. Can this be done in one stored procedure or do I have to have two?
Table Individuals IndividualID (PK) Initials First Last
Is there an efficient way to query for a list of tests with the PretestTech,PostTestTech,and Project manager initials? I guess I'm stuck because I want to Join the Test and Individual tables but there are three fields that need to be joined. So this is the only way I can think to make it work:
SELECT TestID ,TestInfo ,(SELECT Individual.Initials FROM Individual WHERE Individual.IndividualID = Test.PretestTech) AS 'PretestTech Initials' ,(SELECT Individual.Initials FROM Individual WHERE Individual.IndividualID = Test.PostTestTech) AS 'PostTestTech Initials' ,(SELECT Individual.Initials FROM Individual WHERE Individual.IndividualID = Test.ProjectManager) AS 'ProjectManager Initials' FROM Test
Is this efficient or should I rethink my Table design?
I want help with a couple of SQL queries.I have two Tables Table A and Table B.Both tables have the same two fields Name and Hobbies.One Name can appear beside multiple hobbies in each table.There are three queries I wish to run.1) Find all the Hobbie and Name combinations in Table B not in Table Aonly for Names that exist in Table A2) Find all Hobbies and Name combinations in Table A not in Table B3) Return all data in Table B that contains a Name that exists in TableARegards,Ciarán
I am trying to run a batchfile or a external process ( exe ) from within a Script Task and read the process status returned by the process. Is there a sample VB script code that does this that you guys can share ? What modules do I have to Import ?