I have a field in my database which stores product codes. This field
is a varchar. Some users use characters in their codes but most just
use numbers. Whenever I go to sort the products by code the order of
the numbers go something like: 1, 100, 101, 2, 210, 220, 2500, 3, ...
I understand why this is sorted this way but is there anyway I can
have it sort the numbers in their proper numeric order (1,2,3,100,
....) and just have them always appear before any codes that contain
characters? Right now I just have users put zeros in front of their
numbers like: 0001, 0100, 0101, 0002, ...
Su writes "I'm trying to use a stored procedure to dynamically update a table whenever other staff in other departments update their do any changes to their databaseds. and thanks for your web site taught me how to pass table names as parameters. But I still have problems withe sql command. You have an example in your article ('dynamic sql 2'), showing how to do a sql SELECTION using a table name and a local variable. But the sql command only use a local variable of varchar type. I'm trying to do INSERT with local variables with different data types. For example:
CREATE PROCEDURE KPISU_F_TotalByF @inputT_From varchar(10), @inputT_To varchar(10), @TableName varchar(1000) AS ----------------------------------------------------- --------input variable------------------------------- DECLARE @inputTerm_From varchar(10), @inputTerm_To varchar(10), @sql_empty varchar(2000), @sql_refresh varchar(2000) ---------------------------------------------------- IF EXISTS (select * from tempdb.dbo.sysobjects where id LIKE object_id('tempdb..#tmpOTLTotalByF')) DROP TABLE #tmpOTLTotalByF
Server: Msg 245, Level 16, State 1, Procedure KPISU_F_TotalByF, Line 256 Syntax error converting the varchar value 'INSERT KPISU_F_OTLTotalByF06 VALUES (14-19 Academy, 2005, ' to a column of data type int. -----------------------------------------------------------
I guess I could change all the columns in the table to data type of varchar. But are there any other way to solve this problem?
When the autogenerate property of datagrid is set to true, how to perform sorting on date fields.
Example:
SELECT DC_NO AS [Document No],CONVERT(CHAR(10),DC_DT,103) AS [Document Date], [Name] FROM XYZ
Here we convert the date field to the format "dd/mm/yyyy" so when sorting is done it is done in the format "dd/mm/yyyy". But instead sorting should be done in "yyyy/mm/dd" format.
I am having an issue which I'm guessing everyone has at one point. I just can't seem to find the answer. I might be misunderstanding something as I'm relatively new to SQL and data types etc.
Here is my issue.
I have a table with a column that has a nvarchar data type. The following is an example of field values in that column.
asystem1 zsystem19 zsystem9 bsystem23 bsystem3
I would like to sort that data alphabetically and then by number like so.
asystem1 bsystem3 bsystem23 zsystem9 zsystem19
A basic ORDER BY obviously will sort it alphabetically but will put 23 before 3. These system names are already named and can't be changed otherwise I would use "0" in front of single digit numbers.
I just can't figure out how to accomplish this. Is there a convert or cast (unfamiliar with those functions) that I can do or does it involve something more sophisticated?
I've got a report built and I'm trying to figure out how sorting and grouping works. I can group the report by Patient, Albumin and it groups as I would expect.
Patient Date Albumin Adams, John 01/28/2007 4.1 Adams, John 12/30/2007 3.9 Adams, John 01/15/2007 3.2 Barker, Mark 01/18/2007 4.3 Barker, Mark 01/22/2007 4.1 Barker, Mark 01/05/2007 3.9
However, when I try to group by Albumin, Patient, it just sorts by Albumin. Patient Date Albumin Barker, Mark 01/18/2007 4.3 Adams, John 01/28/2007 4.1 Barker, Mark 01/22/2007 4.1 Adams, John 12/30/2007 3.9 Barker, Mark 01/05/2007 3.9 Adams, John 01/15/2007 3.2
What I'm looking for is this: Patient Date Albumin Barker, Mark 01/18/2007 4.3 Barker, Mark 01/22/2007 4.1 Barker, Mark 01/05/2007 3.9 Adams, John 01/28/2007 4.1 Adams, John 12/30/2007 3.9 Adams, John 01/15/2007 3.2
Is this something that can be done with grouping and sorting?
I have a varchar field which holds IDs like (1, 3, 5, 19, 23) when I order it, i get it ordered in ASCII order like (1, 19, 23, 3, 5) rather than (1, 3, 5, 19, 23) Even if I convert it to int, I won't be able to order it.
is there any way I can order a varchar field numerically?
I need to be able to suppress the printing of a particular value when exporting, but not when displaying on a web viewer on-line. I can place an IIF() condition around the field to do this, but do not know how to obtain a parameter/value/function which would recognize that the viewer has selected an export (To .PDF for example). I would prefer there be a direct parameter I can read from the RDL language, however recognizing the selection while setting up the viewer to be displayed in the code-behind and setting an external parameter is also an option.
Is there a syntax to create indexes on user-defined type's fields and methods? Can I index UDT-fields?
I tried but only get syntax error.
Code Snippet
-- put an index on the picture luminance
CREATE INDEX myIdx ON myTbl(picMetaData.Brightness) -- !! error
GO
Error message:
Code Snippet
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.
According to books online (BOL), section User-defined types requirements says In the SQL Server 2005 RTM version, CLR UDTs with user-defined serialization were allowed to have their fields indexed as part of non-persisted computed columns or views. In such situations, non-deterministic UDT serialization/deserialization could lead to index corruption, and therefore has been removed from SQL Server 2005 SP1. In SQL Server 2005 SP1, UDT fields must use native serialization or be persisted in order to be indexed. Any existing indexes on UDT fields should continue to function as before.
What are BOL trying to say about index on UDT fields?
i have a database with 300 tables. All the data types of the fields of my tables are custom. Ex. IFGint:int and stuff like that.
I want to know how can i through a stored procedure, change in batch mode all the fields of my tables. I don't want to modify by hand everytable. It's a lot of work and i think that maybe there might be a way for this programatically.
I'm using the SQL below to work out recruitment figures. The query works well, but I now need to build this query into a DotNet application as a webpage. I therefore need to declare and manipulate the values such as 'Total', 'Jan' to 'Dec' and 'YearRecruited' in order to write these values into my chosen data control. I therefore need to know the datatypes of these calculated values.
Total I think is straightforward as DNAScreeningID is an int datatype. But what about the others?
SELECT YEAR(SamplingDate) AS YearRecruited,
COUNT(CASE WHEN month(SamplingDate) = 1 THEN DNAScreeningID END) AS 'Jan', COUNT(CASE WHEN month(SamplingDate) = 2 THEN DNAScreeningID END) AS 'Feb', COUNT(CASE WHEN month(SamplingDate) = 3 THEN DNAScreeningID END) AS 'Mar', COUNT(CASE WHEN month(SamplingDate) = 4 THEN DNAScreeningID END) AS 'Apr',
I have an OLE DB Source and i want to transform the data type fields of the table before i export the table in an OLE DB Destination. Is there a way to transform numeric value to float, and numeric to nvchar?
I have a report where I am giving the users a parameter so that they can select which field they would like to sort on.The report is also grouping by that field. I have a gruping section, where i have added code to group on the field I want based on this parameter, however I also would like to changing the sorting order but I checked around and I did not find any info.
So here is my example. I am showing sales order info.The user can sort and group by SalesPerson or Customer. Right now, I have code on my dataset to sort by SalesPerson Code and Order No.So far the grouping workds, however the sorting does not.
SSRS 2012 - VS2010...The report compares two years with a sort order on a value that has been engineered based on text switched to int. Â When sorting A-Z this is the result in the horizontal axis is: 5th, K, 1st, 2nd, 3rd, 4th, 5th..When sorting Z-A the result in the horizontal axis is:5th, 4th, 3rd, 2nd, 1st, PreK..Z-A is correct but A-Z sorting shows 5th as the start and end. Â The magnitude of the PreK location is correct but the label is wrong on the A-Z sort order. Â The sorting is implemented using the Category Group sorting option.
I had several databases under sqlserver ce 2.0 (in my Pocket PC) which contained ntext fields. The size of the databases varies from 50,000 to 700,000 records. The size of an ntext field is from 4 bytes to 2 megabytes.
When I recreated my databases under sql server 2005 mobile on my desktop using VS2005 (see my post just under this one), I saw a big difference between the old and new database sizes. This problem was mentioned in one of the posts in this forum and the reply was to replace ntext data with ncharvar type.
Since most of my data was longer than 4000 bytes (which is the limit for nvarchar type), I couldn't use this suggestion. Instead, I changed my ntext type to image type and used a GetByte conversion.
No change! The size of the new database is still 50 % larger than the original. Since the difference is around 300 MB, this is an unacceptable thing.
Now, I either wait from somebody to suggest a new solution (apart from keeping the ntext data in a separate binary file and keep index of the records of this file in the records of sql database) or, most preferably, have
If I install SQL Server using a certain Windows Login, does that login assume some sort of "sa" alias? (I'm trying to explain the behaviour that when I login in to a server using the same username that I used when i installed the SQL Server instance, using trusted authentication, then use a database within which I haven't created any users, I seem to get full permissions, as if I had gone in as "sa")
In the scenario where you are installing MSDE/SQL Server at a customer site (not your own) is this true:
Assuming the customer has a (Windows) login with admin rights (or is a member of the admins group) over the PC which the server was installed on, there is no way of locking the customer out of any part of the SQL Server installation and its databases as Mixed Authentication (which you can't turn off) will always allow members of the (Windows) admins group to also be a member of the SQL Server admins group???
Hi All,We have started to get the strangest errors with our SQL Server. We useWindows and SQL Server authentication, and have done successfully forthe last year or so. However last week i had trouble connecting to theenterprise manager with my domain credentials. Users connecting to QueryAnalyser have no problems when using their SQL Server logins, the issueonly seems to arrise when a Domain account is provided forauthentication. If we reboot the server all is well for about 1 - 2hours and then we loose the Domain credentials again. Even SQL Agentfails to work when stated with the DOMAINAdministrator account!As i said this has worked for a long time, and we have not made anychanges to the Domain or installed any patches for any of the servers.The error messages normally involve something along the lines of "NoUser 'NULL' blah blah" and "No Trusted SQL Server". We also have anexcel report that is failing with the SQL Server error number 18452. Ihave looked this up on MSDN, and this seems to fall in to the samecategory as our other errors.Any Ideas?We can't reboot the server every 2 hours!*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
After installing SQL Server 2005 I found that I inadvertantly used Windows Authentication Mode and I would like to change to Mixed Mode (Windows Authentication and SQL Server Authentication) - what is the best way to do this? In Microsoft SQL Server 2000 you could simply go into Enterprise Manager, edit the SQL Server Registration Properties, edit the Properties of the SQL Server and edit the Properties of the SQL Server Agent.
Ok guys, I€™ve summarized doubts regarding SSIS as well as odd behaviour that sometimes I suffer for my lack of knowledge or for other reasons. So this way, I€™m a pain and bore individual only one time€¦
Question 1:
When you have a ForEach container, i.e using as enumeraton ADO and you are debugging and seeing how is going everything, whats tasks are executing and so on, you never knows if those that were in green (executed succesfully) now are executing again or not. Well, I€™ll try to explain better: In every iteration of the loop, tasks previously executed keep its colour (green) instead of turn into white.
Question 2:
Parameter Size property is a new property for Sql Task when you have installed sp2. Well, what is it for really? I mean I€™ve got some .dtsx with Sql Tasks and its values are simply -1
Question 3:
When you€™re debugging a dtsx you have in the bottom locals showing you variables and so on. Problems come when you have more than 40 variables€¦ is there any search tool? Ok, you can use
Question 4:
Outline for the tasks is lost all the time. What a nuisance! Concretely it happens in workstations running either sp1 or sp2. Amazingly it works fine in a server (2003). Memory is not related, I€™m afraid, in all the scenarios 2Gb.
Question 5:
Is it possible disallow math case for variables? Sometimes when you€™re using lots of variables, it€™s easy commit errors when you write code.
Question 6:
Assemblies 1.0/1.1 will be allow in VSA in a future??
Question 7:
Is it possible to change the scope for a variable in run-time? Devious question, I admit€¦
Question 8:
When you€™re writing a Script Task you can export the script into VB extension and then be imported from a project or whatever. What does make sense?
Question 9:
ScriptTask_32dcba2feae9428386d768f38922e162 (that€™s an example) is really stored anywhere? (When you save a script task inside the IDE) Root NameSpace is too symbolic??
Question 10:
I€™m developing against Windows 2003 english version. The whole Sql25k too. No spanish at all but sometimes I receive spanish messages related with SSIS. I don€™t understand how it can be. Nothing to do with for the fact I€™m using Terminal Server, I guess.
Hi! I have quite strange problem, that I haven't seen before. When I use update command: UPDATE categorys SET banner_valid= '0', section_id= '1', main_cat_default= '0', banner= '', b_link= '', external_text= 'NÄ?kotnes parks ', in_frontpage= '1', name = '100. pants' WHERE (id = 130) Then the field EXTERNAL_TEXT should have value NÄ?kotnes parks but instead of this it makes it Nakotnes parks. I changed collation to Latvian and this did not work. But!!! When I open Enterprise manager and just type in NÄ?kotnes parks and save it then it is ok, but it does not work with Update/add script Any help or ideas???
Is it possible to convet a string with characters and numbers to an all numeric value (e.g. '010-112d3') and then perform arithmatic on the converted value?
Here is what I need to do: given the original value of: 01011201 I need to order a result set by asc order of the difference between the original and each individual record.
If this was all numeric I would simply: select...,(01011201 - column1) as difference from table1 order by difference
BUT my recordset looks like this [010-112d3, 01011202, 0a511345...] so I get I get arithmatic overflow errors (due to the characters). Ive tried casting as numeric and binary and even converting the string to ascii value but that only works for single characters. Any Ideas would be greatly appreciated.
BTW, This search will be the most common hit on the database so a cursor is not really an option.
I would like to set 'SQL Server and Windows Authentication mode' of Sql Server 2005 so when user connects to Server he must supply username and password. Here are steps I make :
1. Open Microsoft SQL ServerManagement Studio Express 2. In Object Explorer right click on first (Server) node 3. Select 'Properties' 4. Select Page 'Security' 5. set 'Server authentication' to 'SQL Server and Windows Authentication mode' 6. press OK 7. in popup window fill password ******** and press OK 8. get error message ''operation is not valid due to the current state of the object. (Microsoft.SqlServer.Express.SqlManagerUI)
I program in C# with SQL Server 2005. I need to connect to Server in security mode.
In connection string I supply UserID = myuser Password = mypassword Persist Security Info = True
In Server I set mixed authentication mode,create login 'mylogin' with password = mypassword after that in my database I create user with username = myuser and loginName = mylogin
There are two problems :
1. in login creation after I fill password, close window and open it again there is old (default) password but not my password 2. Application fails to connect to DB
First post, so greetings!I've been using ASP.NET 2 authentication from an MS SQL 2k5 database now in the web application for my company's customer accounts (file serving, custom webreports, etc). There is currently no support for employees through this web app, but in our plan to go paperless it's become of interest to let the employees access much of their information through the same web portal. The catch is, I'd rather not make them have to use two accounts (one for their domain authentication and one for their web authentication). It's already taken a lot of conditioning to get them to memorize a single username and password.So what I really need is the single Login.aspx page to accept both ASP.NET logins and Domain digest logins, and the Domain digest login needs to be HTTP based (not named pipes). Is this possible at all, and if so, is it possible without making an isapi filter? After all, Microsoft Office Outlook Web Access is served by the exchange server and accepts active directory passwords. So how could I do authentication in this way, and if so, is it possible to have the Outlook Web Access form be accessible from the same session as that of my web server? Thanks, I surely hope someone can help. . . -Brandon
I am trying to create a graph that consists of a bar chart and line graph - both to appear on the same graph.
They will show different information, but will essentially come from the same dataset.
So far I have not been able to achieve this and it would seem that you cannot mix chart types. This is very disappointing given the plaudits associated with this product.
Can anyone restore my faith in this product by telling me that the above is possible and, if so, how do I go about it.
Hi AllI am trying to switch from Windows to Mixed mode authentication on SQLServer 2000. I am right-clicking the server instance in EnterpriseManager and selecting the correct option from the Security tab.Unfortunately, the change I make does not persist when I click OK. Iget no error message, but when I re-open the server properties, theoption has returned to being Windows authentication.Any ideas?Thanks,Kulgan.
Let's say I have a result set (records) containing numbers such as:01239162145100101102103104105106How might someone write a procedure to get the next lowest number inthis sequence? In this case it would be: 4. Some combination ofSelect, Min & When, I am sure, but it escapes me at the moment.Thoughts? Thanks...
Hi, I'm seeing confusing results coming back from a query and I want to make sure my joins are working as expected.
I have 3 tables, tbl_family, tbl_familyPhone, and tbl_phone. tbl_FamilyPhone is a linking table between families and phones that specifies if it's the primary number.
So a family has many familyPhones and a phone has many family phones. I'm trying to get all the families and their home phone only, if they have one. I don't want families to duplicate and I don't want any left out. Here's what I've got
Code Snippet select [whatever]
from tbl_family LEFT OUTER JOIN tbl_familyphone on tbl_family.pk_familyid = tbl_Familyphone.fk_familyid inner JOIN tbl_phone on tbl_familyphone.fk_phoneID = tbl_phone.pk_phoneid and tbl_phone.fk_phonetypeid = 'E6F1688E-015B-481D-8C41-DCC1FEA5D5AB'
My thinking is the inner join between tbl_Phone and tbl_FamilyPhone will cause any FamilyPhone record without a phone record to be left out (fk_phonetypeid is the id of a home phone). Though some FamilyPhone records may be left out, I will not lose any families because it is left outer joined to familyphone. Is this right? Because if I just do select count(*) from families I get 4517 records, but when running the query above with the joins, I get 4383 records.
Currently in production we have a publisher, remote distributor, and subscriber all running 2000.
We want to upgrade the subscriber and possibly the remote distributor to 2005 while leaving the publisher 200 for now, i need a good link or article about the proper proceudre to accomplish this.
I am trying to create a query that can determine if a user id is using mixed mode/windows/both authentication. I need to do this so that it can run on both sql server 2000 and 2005, meaning I can't use any of the sys.* views. Is there a single query could use for both systems? -Kyle