MSSQL Management Studio View Editor Destroys Where-Clauses With Date-Functions

Nov 28, 2007



Hello,

i've written the following query:



SELECT dbo.KALENDER.KALENDER_ID, dbo.KALENDER.JAHR_BEZ, dbo.KALENDER.JAHR_WERT, dbo.KALENDER.HALBJAHR_WERT,

dbo.KALENDER.HALBJAHR_BEZ1, dbo.KALENDER.HALBJAHR_BEZ2, dbo.KALENDER.QUARTAL_WERT, dbo.KALENDER.QUARTAL_BEZ1,

dbo.KALENDER.QUARTAL_BEZ2, dbo.KALENDER.MONAT_BEZ, dbo.KALENDER.MONAT_WERT, dbo.KALENDER.TAGE_IM_MONAT,

dbo.TAG.KALENDERWOCHE, dbo.TAG.WOCHENTAG, dbo.TAG.TAG, s.STUNDE_ID, s.DATUM_ZEIT

FROM dbo.KALENDER INNER JOIN

dbo.TAG ON dbo.KALENDER.KALENDER_ID = dbo.TAG.KALENDER_ID INNER JOIN

dbo.STUNDE AS s ON dbo.TAG.TAG_ID = s.TAG_ID

WHERE (SELECT MONTH(s.datum_zeit)) = ((SELECT MONTH(GETDATE()))-2)and

(SELECT year(s.datum_zeit)) = (SELECT year(GETDATE()))

order by s.stunde_id



when copying that query to the view editor and executing it, it trys to fix it somehow to:


SELECT TOP (100) PERCENT dbo.KALENDER.KALENDER_ID, dbo.KALENDER.JAHR_BEZ, dbo.KALENDER.JAHR_WERT, dbo.KALENDER.HALBJAHR_WERT,

dbo.KALENDER.HALBJAHR_BEZ1, dbo.KALENDER.HALBJAHR_BEZ2, dbo.KALENDER.QUARTAL_WERT, dbo.KALENDER.QUARTAL_BEZ1,

dbo.KALENDER.QUARTAL_BEZ2, dbo.KALENDER.MONAT_BEZ, dbo.KALENDER.MONAT_WERT, dbo.KALENDER.TAGE_IM_MONAT,

dbo.TAG.KALENDERWOCHE, dbo.TAG.WOCHENTAG, dbo.TAG.TAG, s.STUNDE_ID, s.DATUM_ZEIT

FROM dbo.KALENDER INNER JOIN

dbo.TAG ON dbo.KALENDER.KALENDER_ID = dbo.TAG.KALENDER_ID INNER JOIN

dbo.STUNDE AS s ON dbo.TAG.TAG_ID = s.TAG_ID

WHERE ((SELECT MONTH(s.datum_zeit) AS Expr1

FROM ) =

(SELECT MONTH(GETDATE()) AS Expr1) - 2) AND

((SELECT YEAR(s.datum_zeit) AS Expr1

FROM ) =

(SELECT YEAR(GETDATE()) AS Expr1))

ORDER BY s.STUNDE_ID

... but this causes syntax-errors. I don't understand why this query works fine in the query editor but then gets automatically "destroyed" by the view editor. Do i have to use more statements to get the working query to run inside a view?

Thanks alot for reading.

View 1 Replies


ADVERTISEMENT

Function That Works In Sql Server Management Studio Does Not Work In Derived Column Transformation Editor

May 12, 2007

Hi

I'm a relative SQL Server newbee and have developed a function that converts mm/dd/yyyy to yyy/mm/dd for use as in a DT_DBDATE format for insert into a column with smalldatatime.



I receive the following erros when using the function in the Derived Column Transformation Editor. First, the function, then the error when using it as the expression Derived Column Transformation Editor.



Can anyone explain how I can do this transformation work in this context or suggest a way either do the transformation easier or avoid it altogerher?



Thanks for the look see...

******************************

ALTER FUNCTION [dbo].[convdate]

(

@indate nvarchar(10)

)

RETURNS nvarchar(10)

AS

BEGIN

-- Declare the return variable here

DECLARE @outdate nvarchar(10)

set @outdate =

substring(@indate,patindex('%[1,2][0-9][0-9][0-9]%',@indate),4)+'/'+

substring(@indate,patindex('%[-,1][0-9][/]%',@indate),2)+'/'+

substring(@indate,patindex('%[2,3][0,1,8,9][/]%',@indate),2)



RETURN @outdate

END

********************************



And the error...



expression "lipper.dbo.convdate(eomdate)" failed. The token "." at line number "1", character number "11" was not recognized. The expression cannot be parsed because it contains invalid elements at the location specified.

Error at Data Flow Task [Derived Column [111]]: Cannot parse the expression "lipper.dbo.convdate(eomdate)". The expression was not valid, or there is an out-of-memory error.

Error at Data Flow Task [Derived Column [111]]: The expression "lipper.dbo.convdate(eomdate)" on "input column "eomdate" (165)" is not valid.

Error at Data Flow Task [Derived Column [111]]: Failed to set property "Expression" on "input column "eomdate" (165)".

(Microsoft Visual Studio)

===================================

Exception from HRESULT: 0xC0204006 (Microsoft.SqlServer.DTSPipelineWrap)

------------------------------
Program Location:

at Microsoft.SqlServer.Dts.Pipeline.Wrapper.CManagedComponentWrapperClass.SetInputColumnProperty(Int32 lInputID, Int32 lInputColumnID, String PropertyName, Object vValue)
at Microsoft.DataTransformationServices.Design.DtsDerivedColumnComponentUI.SaveColumns(ColumnInfo[] colNames, String[] inputColumnNames, String[] expressions, String[] dataTypes, String[] lengths, String[] precisions, String[] scales, String[] codePages)
at Microsoft.DataTransformationServices.Design.DtsDerivedColumnFrameForm.SaveAll()

View 3 Replies View Related

How To View Permissions Using Management Studio?

Apr 5, 2007

How do you view permissions granted to an id, such as ALTER TRACE permission, using Management Studio? I want to see if ALTER TRACE permission has been granted to an id, but am unable to find this information in the GUI.

Thanks, Dave

View 2 Replies View Related

Shortcut To Insert New GUID Into Uniqueidentifier Cell In MSSQL Management Studio Express?

Jul 15, 2006

Hi,

anyone knows if there's an easy way to insert new GUIDs into uniqueidentifier cells when editing data in table on Management Studio Express? or Visual Studio 2005 Server Explorer? I can't find a shortcut, and copying from external tools is pain..

I suppose it's possible to build a VB macro in Visual Studio, would it work when editing table data?

Thanks in advance!

View 8 Replies View Related

Can Not View The Report From SQL Server Management Studio

Oct 12, 2007

After install SQL Server 2005, then run it sampel for report. Using VS2005 to deploy the report to report server.
The report can be previewed in VS2005.

After deploying, open SQL Server Management Studio.
1. Add local user Administrator to database AdventureWorks
2. Pick up one sample report Company Sales from AdventureWorks(Home-->AdventureWorks-->Company Sales), then go to
DataSource-->AdventureWorks, the setting for this datasource as below:

Data Source=localhost;Initial Catalog=AdventureWorks;Integrated Security=True

Select "Credentials stored securely on the report server" with following setting:
Login name: Administrator
Password: (right password here)

Checked for "Use as Windows credentials when connectiing to the data source"

3. Then right on ths report (Company Sales), from popup menu-->View Report
Then in browser, it ask for user name and password, input as:
User name: Administrator
Password: (right password here)

Get infomation as:
You are not authorized to view this page

The URL is: http://localhost/reportserver/?/AdventureWorks%20Sample%20Reports/Company%20Sales&rs:Command=Render

Then try a different setting, use different user account in Database, same error message.

What's wrong with it? How to solve this issue?

View 1 Replies View Related

How To View Foreign Key Relationships In Management Studio?

May 15, 2008



I cannot find a good way to view existing Foreigh Key Relationships in SQL Server Management Studio Express. In the Object Explorer, if you click on a table to expand it, you can see a tree view of EVERYTHING about the table (Columns, Keys, Contraints, Triggers, Indexes, Statistics), but NOTHING about Foreign Key Relationships!!

The only way I have found is that you have to open the table in Design mode, then right click, and choose Relationships, and only then can you see what FK Relationships are defined.

You should be able to see the FK Rletaionships in the tree view of the Object Explorer window!

View 3 Replies View Related

ı Cannot View Existing Database In Management Studio !!!

Jul 5, 2007

Hi

ı have sharepoint 2007 server and everthing is ok

it is working

ı can view database name in sharepoint central administration

but ı cannot view same database in sql management studio

what is the problem

how can i view it

Thanks

View 3 Replies View Related

DB Design :: Schema Binding A View In Management Studio

Oct 13, 2015

I'm using SQL Server 2008 R2 Management Studio. I have a view that I'd like to index. Obviously, that requires that the view be schema bound to the underlying table. I have found myriad explanations for how to programmatically create a schema bound view, but I've never created a view like that before, and since I'm more a mechanical engineer than a database manager, I'd like to be able to do it the 'easy' way, by just creating the view in Management Studio by going to the database, right clicking on 'Views', clicking on 'New View...' and then, hopefully, checking some box somewhere that schema binds the table to the view.

View 2 Replies View Related

Created View In Sql Management Studio Not Showing In Ssrs

Mar 17, 2008

hi all

Using Sql Server 2005 / Reporting Services

I created a view in sql server management Studio but can't see it in Reporting Services.

I appear to have the same security permissions?

what else am I missing?

thanks
jewel

View 1 Replies View Related

Single Record View In SQL Server Management Studio (2005)

Apr 17, 2008

Hello,
In SQL Server Management Studio (2005), 'Open table' command or a SELECT query displays table rows in a grid (or text).Please tell how to view a single row at a time i.e. all only ONE row is displayed at a time (evenly arranged to cover the screen).
This feature (Single record view) is available in other database client like TOAD.
Thank You

View 5 Replies View Related

View Data From A Compact Database With The Management Studio Express ?

Jan 23, 2007

Hi there, after some hours of installing and experiments i can now open and sql server compact database (sdf) iam also able to create a new database and add tables and columns. (everything with the ms sql server management studio express)

i can also open the northwind database. but iam not able to view the data .

if i rightclick on a normal database table i can choose ->open table and see its content.

but on a compact table i have at rightclick only

edit table
properties
delete

refresh



how can i see the data in the table or add new content ?

thanks

View 8 Replies View Related

ADO.NET Returns Different Colum Value When Compared To View Results In SQL 2005 Management Studio

Feb 7, 2007

I have a complex view in my sql 2005 database.
The view returns a column that could be null (as the result of a left outer join).
The coulmn that is returned is an integer.
Everything works fine if I run the view from SQL 2005 Management Studio.
My column value is always null if I use ADO.NET's SqlAdapter to return a DataTable.
Has anybody seen this behaviour before?
Any help appreciated.
Regards,
Paul.

View 2 Replies View Related

How To View Permissions Of User-defined Database Roles In Management Studio?

Dec 20, 2005

As part of our security project, I've done the following when logged in as 'sa':

Created database roles 'dbrole1' within dbAccount

Created login and user 'user1' and added user to be a member of 'dbrole1'

Granted execute permissions on sp1 and sp2 to 'dbrole1'

However, I didn't see the above permissions listed in SQL Server Management Studio - Database - Security - Roles - Database Roles - 'dbrole1' properties - securables

Any ideas?  Thanks!

View 4 Replies View Related

Management Studio - Script Date Comments

Aug 22, 2007

Hello,

This may sound like a stupid question, but I have looked a number of times where the options are for the comments that are added to a SQL Script that is updated or newly created.

Ex this is the line that is added:


/****** Object: StoredProcedure [dbo].[Rpts_SelectDesignLumberInv] Script Date: 08/21/2007 19:42:50 ******/

I would like to be able to add the developer name, date created etc to the default comment that is added by the designer.. So more or less I would like to be able to define what is commented.

Does anyone know how to do this?

Thanks, Leo

View 3 Replies View Related

Management Studion Express Alongside Full-blown Management Studio?

Oct 9, 2006

Is it possible to run both Sql Server Management Studio: Express and full blown side by side?

I am developing with the full blown product but would like to test Management Studio Express on the same box.
Is this possible?

Thanks

Eric

View 3 Replies View Related

SQL Server Management Express Studio Management Tools

Apr 5, 2007



I have recently installed the SQL Server Management Studio Express but I do not find Management Tools in order to create scheduled backups and shrinking of the databases. I was under the impression that this should be included in the Management Studio. I use the SQL 2005 Express for smaller customers who run the SQL on a desktop unit. I need a way to backup the data to a server machine for backup purposes. I have uninstalled and reinstalled to no avail.

View 7 Replies View Related

Visual Studio Database File And SQL Server Management Studio Express Question

Mar 17, 2007

I have a database in my "App_Data" folder of my visual studio project.  I can view it fine in Visual Studio's built-in tools for managing a database attached to a solution.  However i recently started playing around with the SQL Server Management Studio Express program.  When i attach my database to Management Studio, and try to run my program it crashes.  I think it might be a permissions error?!? When i detatch it and reattach it in visual studio it runs fine again.   Any suggestions? ThanksJason 

View 1 Replies View Related

Visual Studio 2005 Standard And SQL Server Management Studio?

Sep 4, 2007

I am new to visual studio and I am still not sure of all its components and features.

I installed visual studio 2005 standard edition but cannot find SQL Server Management Studio?

I guess this must be because it is not included with Visual studio 2005 standard. Is it included with VS 2005 professional?

I want to add pictures of products to my shopping site using an SQL database and I’ve been told that SQL Server Management studio is required as it is a graphical tool.

How would I go about obtaining the SQL server management studio. There seems to be different versions of SQL server that it is confusing to know which one to purchase.

Will the SQL server 2005 version that comes with Visual studio standard be sufficient for me now right? I want to create a shopping site with hundreds, perhaps even thousands of products. I want to use an SQL server 2005 database. The database will include ‘dynamically generated’ product images if that is the correct terminology.

My goodness, it seems I still have so much to learn.

Thanks

View 1 Replies View Related

The Database Created Using Management Studio Cannot Be Connected To Visual Studio???help

May 13, 2008

 
 
I have created a database under management studio and i want it to be connected in visual studio but it failed
the error msgs said that the database can't be connected coz the database with same name exits but that is not true

View 2 Replies View Related

Disable Automatic Renaming Of Source Tables By View Editor?

Sep 29, 2012

Is there a way to disable to automatic renaming of source tables by the View editor? (SLQ Server 2008 R2)

I have a view that is using several sub-queries (including a "rank/partition") and even though each sub-query is contained in ( ) and given an alias, the view designer automatically adds the _1, _2 to all of the tables it thinks are duplicates, which then invalidates the and explicit field calls in CASE WHEN statements ...

View 1 Replies View Related

How Do I Get The Database That I Am Using In Visual Studio Into My SQL Server Management Studio?

Sep 12, 2007

How do i get the database that i am using in visual studio into my SQL server management studio?
i need to create some scripts to create stored procedures on a live server.

View 1 Replies View Related

Is Management Studio Express Compatible With Visual Studio?

Sep 13, 2006

I have installed Visual Studio 2005 which includes SQL Server Express but not the Management Studio.

Can I install SQL Server Management Studio Express?

View 1 Replies View Related

What Is The Different Between Manangement Studio And Management Studio Express

Jan 18, 2007

In Microsoft.COM website do we have a comparision between Management Studio and Management Studio express in term of functions and features of the tool ? (Not SQL Server and SQL Server Express !)

View 1 Replies View Related

Protecting Functions From View It

Dec 22, 2006

Hello,I wrote some complicated functions (and stored procedures) in databaseat my work. System administrator (and every db user) can view codes(in Enterprise Manager for eg.). My employer needs periodic modifyingof code and so I'm required to do it. But I can loose my job :)because users are able to modify code (althout they ware too lazy tocreate it by themselves).Is this possible to protect functions from view it?[please, don't mind my english]

View 5 Replies View Related

SSIS Excel Destination Editor Date Formatting Issue

Apr 14, 2008



Hi All
I have seen several posts on this issue but as yet no answer. So i'm hoping that somewhere out there knows what the issue is.

SSIS package queries database creates MS spreadsheets per customer and then emails each customer their list.
Anyway all works fine apart from the fact that the Excel Destination Editor converts the date from uk to us format. My routine is already using an MS Excel template (correctly formatted) which it copies as part of the package.
Any ideas anyone?

rgds

View 2 Replies View Related

Best MSSQL Management Tools

Aug 21, 2007

Hi everyone.

I manage 100+ databases spread across the country. When it comes to perform an update or offsite backup, it is a nightmare. I have to repeat the same code and the same process for 100+ times.

Is there any tools other than MS Enterprise manager we can use to perform this type of maintenance works in a batch manner? For example, we place a update sql file within the program, and the program does the rest (of course, we predefine the login credential for each databases)

Cheers~

gmefmax:angel:

View 13 Replies View Related

Problems Saving Edited SQL Database Functions With Visual Studio .Net 2003

Nov 20, 2005

I'm fairly new to using SQL Server and I'm having problems just trying to edit Functions in the SQL server database with Visual Studio .Net 2003.

View 1 Replies View Related

Copy View And User Defined Functions To Another Database Without Replacing Data

Mar 5, 2008

I work on a copy of SQL Server Express on my desktop. After modifying and creating views and user defined functions, I would like to copy and paste them into the working database. Is there a method programmatically of doing this or must I copy and paste the t-sql language from the existing view to the new database--then save the new view on the working database?

View 6 Replies View Related

Date Functions

Oct 28, 1999

I have a table of sales transactions that I'd like to group by date, but this is a datetime field so it groups by the date and time, and so it returns more records that I want. Is there an easier way to do this other than using the datepart function to build a date? How can I just look at only the date of a datetime field?

View 1 Replies View Related

Date Functions

May 19, 2005

I am re writing my help desk app so that it can use popular databases at the backend. Although I am OK with MySQL I have no experience with MsSql. Most of my querys are standard stuff, but I have some datetime querys which I need help with.

Firstly can I use iso date times (yyyy-mm-dd hh:mm:ss)

How would I convert the following MySql query to MsSql or could someone point me in the right direction to get the required info?


PHP Code:




 $today = "2005-05-19 21:13:00";

$querystr = "
    SELECT
        WEEKDAY('$today')       as js_weekday,
        DAYOFMONTH('$today')    as js_dayofmonth,
        MONTH('$today')         as js_month,
        YEAR('$today')          as js_year,
        HOUR('$today')          as js_hour,
        MINUTE('$today')        as js_minute,
        p.p_name, p.p_hours as priority_hours,
        ct.cont_name, ct.sunday, ct.monday, ct.tuesday, ct.wednesday, ct.thursday,
        ct.friday, ct.saturday, ct.hours as contract_hours, ct.bankhols,
        HOUR(ct.start_time)   as ss_hour,
        MINUTE(ct.start_time) as ss_minute,
        HOUR(ct.end_time)     as se_hour,
        MINUTE(ct.end_time)   as se_minute,
        (time_to_sec(ct.end_time)-time_to_sec(ct.start_time))/60 as std_minutes
    FROM  customer c, priority p, cont_cat ct
    WHERE c.cust_id = $cust_id
    AND   p.priority_cat_id = $priority_id
    AND   ct.cat_type_id = p.p_cat_type_id
    AND   c.cont_type_id = ct.cont_type_id"; 

View 3 Replies View Related

Date Functions SQL

May 7, 2007

I need some help with some date functions:
this is how they are stored in the database '5/4/2007 1:00:00 PM'
if i were to query a list of all records with todays date, how do i achieve that.
also if i were to set a query to fetch all records within a two week date range how do i so that

Melvin Felicien
IT Manager
DCG Properties Limited

View 13 Replies View Related

Date Functions

Sep 11, 2007

Hi All,
I need to do this.

For ex:'2007-02-28' is the firstdate I have
and 02-28-2007 is a Wednesday..

I need the nextdate to be a Wednesday and for next year
like 02-27-2008 which is also a wednesday.

so far I have this much.but I am stuck

declare @firstdate datetime,@newdate datetime

set @firstdate ='2007-02-28'

set @newdate=dateadd(mm, 12, @nextdate)
select @newdate

select datename(dw,@firstdate) as one
select datename(dw,@newdate) as two

How do i proceed from here.
Thanks for any input

View 1 Replies View Related

Date Functions

Oct 10, 2007

i have tables
customer id name address city
items itemid code itname cost
sales sid invno date cid amount (what are the sales done in date)
purchases pid invno date cid amount (what are the purchases done in date)

dsales dtsid sid code qty cost amount (detail of sales)
dpurchase dtpid pid code qty cost amount (details of purchases)


i want a query like

customer itemname jan feb march - - - - - - - - -
sai tv 1 2 0
nalini radio 0 2 1 ------------








sai krishna

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved