My week starts on Monday rather than on Sunday which is default(US, English) in SQL Server and would like to change the same so I would get proper weeknumber and dayindex using DATEPART.
I am looking at different ways of setting DATEFIRST(SET DATEFIRST 1) in SQL Server 2005.
I could set in a stored procedure, but this isn't a feasible way for me because I am using .nettiers to generate by business objects and stored procedures. I need to alter the sp's everytime I newly generate the code and sp's.
I couldn't set it in a function which I was hoping initially. I understand this datefirst is stored in one of the sys table in MASTER DB and I couldn't find a straight forward way to change this.
Can anyone suggest me a way to set the DATEFIRST either at a database level or at a server level(probably by changing the sys table in MASTER DB).
We have a problem with DATEFIRST. Different users connecting to SQL 2005 and querying the value for DATEFIRST (SELECT @@DATEFIRST). Some users get 7 (Sun), others get 1 (Mon). What is giving rise to the different values ? (All users seem to have the same language settings in SQL and their regional settings are the same). This is impacting stored procs calling DATEPART that are run from within VB6 Apps using ADO.
So I need to select and average a whole bunch of data by week. Currently, I group by:GROUP BY TO_CHAR(m.ENDTIME, 'IW') and select using SELECT ... TO_CHAR(m.ENDTIME, 'IW') Week to summarize by week. Since the first day of the year was a monday, it sets the weeks as monday-monday. 2008 will start the week on Tuesday. I need to set the weeks to be Thursday 7pm to Thursday 7pm. How can this be achieved? I'm not sure if datefirst is the answer. Can it accept decimals? Is there another way to do this? I'm placing this query into a SqlDataSource selectcommand. Unfortunately I do not have the option of building a stored procedure. Thanks.
I am setting my Dataset in SSRS to define the First Day of the week to Sunday. So In the Dataset I put this scripting : ================================== SET DATEFIRST 7; SELECT city, country, datepart(wk,transactdate) as WeekNo from CatalogTable ================================== The select statement above working very fine in the report.
But then, when I put in the Parameter which I have set in Report Parameter for a field called Service then I will get the problem. For example the scripting below : ================================== SET DATEFIRST 7; SELECT city, country, datepart(wk,transactdate) as WeekNo from CatalogTable where Service IN (@PService) ================================== I have defined @PService in Report Parameter, and in the Parameter Tab in Dataset inside SSRS. But it kept prompting me with the eror message : Error Source : .Net SqlClient Data Provider Error Message : Must declare the scalar variable "@PService".
When I remove the first line SET DATEFIRST 7; then my query working fine.
It seems SSRS cannot accept SET statement, whenever we insert the parameter in there. Is there any workaround on this ?
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. this is the source error for this error An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) please any one can help me?
I want move data from informix to SQL server 7.0 every 10 seconds. I do not know what is the best way. It seems that I need create a DTS package and schdule the task from SQL server Agent, but can the task be schduled to reoccurred every 10 seconds?
I have to made a change and want to see it this is possible. The column IDPRT# is used here as MAX. THe user wants to exclude a few of the items which skews the average. Can i also select the IDPRT# a second time? and then in the CRystal reports I can select not =? but will this mess up the MAX line in any way?
SELECT "OEIND94"."IDDOCD" AS INV_DATE, "OEIND94"."IDORD#" AS ORD_NUM, "OEIND94"."IDORDT" AS ORD_TYPE, "OEIND94"."IDPRLC" AS PROD_FAMILY, "OEIND94"."IDPR$C" AS PRICE_CODE, "OEIND94"."IDCOM#", MAX("OEIND94"."IDPRT#") AS ITEM_REF, "ICPRT1"."IARCC4" AS PROD_TYPE,
How many ways are there to connect to a database in ASP.NET? Could someone list them in a 1,2,3... manner. For those who are going to ask why I want to know this and why I don't do one way, I'll explain after I get the answer.
I have I rather complex query and need to display a Sum in different ways. Now I'm wondering if the performance improves if you nest the queries in the described way. To me it looks, as if the sum just has to be calculated once?
select SUM(tiempo) as time_minutes, CONVERT(varchar(5), dateadd (minute,sum(tiempo),'1900-1-1 0:00'), 114) as time_hours, SUM(time)* 0.95 as time_discount from table
Select tiempo as time_minutes, CONVERT(varchar(5), dateadd (minute,tiempo,'1900-1-1 0:00'), 114) as time_hours, tiempo * 0.95 as time_discount From ( Select Sum(tiempo) as tiempo from table)a
I'm trying to simplify a SQL Stored Procedure.The query accepts an int, @ItemTypeID intI have the Query:SELECT ... FROM ItemList WHERE ItemTypeID = @ItemTypeIDor, if @ItemTypeID is 0,SELECT ... FROM ItemList Is there a way to do this query without doing:IF @ItemTypeID = 0BEGIN ...SELECT QUERY...ENDELSEBEGIN ...SELECT QUERY...END?
Hey - I am trying to create a procedure that will retrieve information from multiple SQL Servers. For example, I want to use a select statement on a systems table. Instead of running it from each server, I would rather run it from one and get info on all the servers. To do this, I know that i can 'link' a Server and then make select calls to that server. Some of the other administrators have expressed concern with this. Are there issues that I should research before linking servers. Is there a better way to do what I want to do? Any Input would be appreciated.
I need to know which are the best ways to connect to a remote SQL SERVER 2000 from inside a VB6 application. By remote I mean on a dedicated server outside my LAN that I can access by IP address.
Dear All, i've tried with indexed views, but because the view is referenceing another view, i was unable to create a clustered index on that view. so please let me know how can i improve the performance of the view.
thank you very much
Vinod Even you learn 1%, Learn it with 100% confidence.
Hi all, I am just wondering is there any other ways to execute an integration service package other than using sql server agent, dos command and manually execute the package in BIDS? I am thinking of running the package on web, is this possible? What I am trying to do is let user to run the integration service when they need to, so instead using SQL Server Management Studio to run the task being set in SQL Server Agent, I am thinking of something where user can log into a website (like the report server) and then run the integration, so that the data for the report server's reports are being update. Please help out if any know a solution to it. Thanks in advance.
I need to transfer my database from one server to database on another server every 24 hours. I can create windows application but it will be cumbersome to write bulk of code . So can u suggest me some service or any other way through query or stored procedure or by job scheduling which can run every 24 hours and move my data from one database on one server to another sql database. Both database systems are sql server 2000 but servers are diffeerent so how to connect them while transferring dbs. ? Any help is appreciated.
Hello.I would like to learn all the possible ways that we can access and modify data in ASP .net 2.0 programmatically.for example one way would be like this: StringBuilder sql = new StringBuilder();sql.Append(" SELECT *"); //count the total number of recordssql.Append(" FROM dbo.tblJobTitle "); //get the connection string from web servicesstring strConnection = new sqlconnection.SQLConnection().GetSQLConnectString(sqlconnection.SQLDSN.SCIC);//Use the Microsoft.practices SqlDatabase object to execute our sql.SqlDatabase SqlHelper = new SqlDatabase(strConnection);SqlDataReader reader = (SqlDataReader)SqlHelper.ExecuteReader(CommandType.Text, sql.ToString());the i can loop through reader and get the data OR I can create a DataSet like this: SqlDatabase db = new SqlDatabase(strConnection); DbCommand dbCommand = db.GetSqlStringCommand(sql.ToString()); DataSet dst = db.ExecuteDataSet(dbCommand);I want to know if there is a comprehensive book explainaning all these possible ways to access and modify data using C# under ASP .net 2.0I really really apreciate this.Thank you very much.
I am learning the Optimizer from the book "Querying Microsoft SQL Server 2012" for certificate exam 70-461. I really cannot understand how it explains the number of possible ways to execute a query joining three tables. the pseudo-query is:
SELECT A.col5, SUM(C.col6) AS col6sum FROM TableA AS A INNER JOIN TableB AS B ON A.col1 = B.col1 INNER JOIN TableC AS C ON B.col2 = c.col2 WHERE A.col3 = constant 1 AND B.col4 = constant2 GROUP BY A.col5;
The book says:"Start with the FROM part. Which tables should SQL Server join first, TableA and TableB or TableB and TableC? And in each join, which of the two tables joined should be the left and which one the right table? The number of all possibilities is six, if the two joins are evaluated linearly, one after another."
Q1: How could it be six possibilities? From my understanding, lets say, if the SQL Server has to join A and B first, and then join C, in this case I can think of 4 possibilities, which are:
1. When A Join B, Left: A, Right: B. When Join C, Left: result of A join B, Right: C
2. When A Join B, nbsp; When Join C, nbsp;When A Join B, nbsp; When Join C, nbsp;When A Join B, nbsp; When Join C, "line-height:13.5px;">
Q2: The section following the previous question says there are 4 different types of join.."This already gives four options for each join. So far, there are 6 x 4 = 24 different options for only the FROM part of this query."
How can it be 6 x 4? My understanding is 4 is only for 1 join, but in our case, there are 2 joins, so it should be 6 x 4 x 4.
Hi guys , is there any ways/suggestions for strengthen up the security for SQL server 2005 ? Due to several attacks from unknown places to my database's server , so I would like to get a way for increase the SQL security. Hope able to gather some info from web as well. Thx a lot guys.
I have a table (F_POLICY_TRANSACTION).This table has a couple of million rows in it.I am using a column named POLICY_TRANSACTION_BKEY to select records to delete (approximately 750k using the code below)This column has a non-clustered index applied..This is the code I have used:
WHILE 1 = 1 BEGIN DELETE TOP(50000) FROM F_POLICY_TRANSACTION with (tablockx)
[code]....
Problem is, it takes around 10 minutes to run.Is there any way it can be made more efficient?I have tried varying the rowcount with no success
Sorry for the less then descriptive post title but I didn't find a better way to describe it. I'm developing an app in the express editions of VB and SQLserver. The application is a task/resource scheduler. The main form will have a datepicker or weekly overview and show all tasks scheduled per day. The problem is, I've got one or more people assigned to tasks and I wonder what's the best way to design this. Personally, I'd go for one Task table, a People table and a table that provides a link between them (several record per task, one for each person assigned linking TaskID and PplID). However, I don't see a nice way of showing this data to the end user, allowing him to edit/add etc on ONE screen.
To fix that the only way I see is just add columns to the Task table for every person with select boxes. This way everything can be done on one simple screen. This obviously does present some future issues.
On top of this, which people are available on a day varies and there should be an option to allow a user to set who is available on a specific day. Which would lead me to my first idea and add another table that would provide this. but then I'm having design issues again for the form.
I'm kinda stuck atm, can anyone shed some light on this. I'm sure there is an elegant way of doing this but I'm failing at finding it.