PowerDesigner - Prevent DB name to be uppercase in generated SQL - sybase

I am currently beginning playing around with Sybase PowerDesigner and its Physical Data Model (PDM).
I have managed to create some entities/tables, columns, et cetera, and the case in the generated SQL (to create the database from the model) is like I want.
However, regarding the database name, PowerDesigner insists for it to be always in uppercase. Actually, I am not getting any error message or anything like that and I'm actually allowed to type in a mixed-case database name but as soon as I close the "Model Properties" window and come back to it to check, the database code name is back to uppercase.
I obviously unticked the "=" button connecting the logic name to the code name so I can type a different code name, but it still doesn't work (while it does for tables).
Is there any way to have a database name in the generated SQL script corresponding to the case I specified in PowerDesigner? The DBMS type is SQL Server 2008 (tried previous versions and the problem is the same).
Thanks a lot in advance.

I found how to do it:
Right-click on an empty spot in the model area.
Select "Model Options..." from the context menu.
Select "Naming Convention" from the tree.
Select "Code" from the tab group.
Select "Mixed case" beside "Character case".
Click OK.

Right-click on an empty spot in the model area.
Select "Model Options..." from the context menu.
Select "Naming Convention" from the tree.
Select "name to code" check "Apply name to code convertion"

Related

SQL Server Mgmt Studio shows "invalid column name" when listing columns?

I'm used to scripting in Python or Matlab, and my first couple hours with SQL have been infuriating. I would like to make a list of columns appear on the screen in any way, shape, or form; but when I use commands like
select *
from "2Second Log.dbo.TagTable.Columns"
I keep getting the error:
Invalid column name '[the first column in my table]'.
even though I never explicitly asked for [the first column in my table], it found it for me. How can you correctly identify the first column name, and then still claim it's invalid!? Babies will be strangled.
This db was generated by Allen Bradley's FactoryTalk software. What I would really like to do is produce an actual list of "TagName" strings...but I get the same error when I try that. If there were a way to actually double click the table and open it up and look at it (like in Matlab), that would be ideal.
Echoing juergen's suggestion in the comment above. It looks like you're running the query on the master database, not the 2Second Log database that actually has your table. (You can tell this by looking at the database in the dropdown in the top left of your screenshot). Two things you can do:
Change the dropdown in the top left to 2Second Log. This will target your query to a different database
Put your database name in brackets as suggested by juergen i.e. select * from [2Second Log].dbo.TagTable
As an side, if you're looking for a good SQL tutorial, I highly recommend the Mode SQL tutorial. It's a fantastic interactive platform to get your SQL feet wet.
always use brackets when names/field have spaces or dashes.
select * from [2Second Log].dbo.TagTable

How to extract my table_names+descriptions from my "database navigator" from IBM?

I have a my database navigator that contains a lot of tables with descriptions. I need to search within descriptions in order to find the table I need, but in the database navigator from ibm this feature is not available. Because of this I want to export all data to a excel sheet. But how?
This SQL statement will give you the schema (library), table name, and description for every table you have access to.
SELECT TABLE_SCHEMA, NAME, TABLE_TEXT
FROM QSYS2.SYSTABLES
You can get it into Excel in a few ways. I am not a big fan of iSeries Navigator, so I tend to use Microsoft Query to get my data into Excel.
Here's how I do it:
Go to the Data ribbon (I'm on 2007)
Select "From Other Sources"
Select "From Microsoft Query"
choose your data source and click OK
Cancel out of the Query Wizard
Answer "Yes" to the question "Do you want to continue editing this query in Microsoft Query?"
Close out of the "Add Tables" dialog.
Hit the SQL button on the tool bar (or choose "SQL..." from the "View" menu).
Paste in the SQL statement and click OK.
If "SQL Query can't be represented graphically. Continue anyway?" comes up, click OK.
Choose "Return data to Microsoft Office Excel" from the "File" menu.
Yes, it's a klunky process, but it works. The only downside is that Microsoft Query runs the query to show it to you, the Excel runs it again to pull the data. That might not always be a good idea if it's an expensive query to run. I wouldn't worry about it in this case.
You can also do it the old fashioned way, if you have access to green screen and the command line.
Use WRKOBJPDM LIB(youiSerieaLibraryName) OBJTYPE(*FILE)
then use F17 Subset (Shift and F5 ) and enter your search criteria for the file description next to TEXT

Change A Database's Table's Name (SQL Server 2008)

I got a table named tblHello and I wanna rename it to Hello
Right click on the table and select rename in management studio
You can also use sp_rename:
sp_rename 'old_table_name', 'new_table_name'
I want to point out that table renaming is not as simple as just changing the name when you have queries written. You also need to change all references to the old name in every stored proc, view, function and dynamic sql code. This is not something to be taken on lighty in something that is already on production.
But #jonH has the answer for how to do it (you run that in the query window making sure you switch to the correct database first). Of course you have to have the right security permissions to rename objects.
If its a small project,
you can directly change it from User Interface.
In Server Explorer, right-click the table you want to rename and Open Table Definition.
Right-click the table in the Table Definition window and choose Properties from the shortcut menu.
In the field for the Name value in the Properties, type a new name for the table.
Save the table.
And its done.

MS Access Database Check Box List Filters Missing On SQL Server back end

When I connect Access 2007 to SQL Server (whether by ADO recordset or by linked table) I no longer get check box lists (of available filter values) in the datasheet column filters.
Is this feature available only with MDB/ACCDB and/or DAO?
I think the check box in datasheet view of native Access tables is governed by the "Display Control" property in the table design. I don't recall what's available when the table is in SQL Server. If you provide a form in "datasheet view", you should be able to bind a check box control to the SQL Server column.
Edit: I think I misunderstood your question yesterday. If you click the Office Button, select Current Database, then put a check in the "ODBC fields" box under "Filter lookup options" ... does that do what you want?
I know we're breaking protocol by not opening a new question, but I'm going to answer this nevertheless so this thread will be complete. This is a more complete answer than the previous ones.
I think I have this topic nailed down now.
The lookup filters won't work with a recordsource that is not an Access object, and they don't work in linked tables directly.
You have to create a query of the linked table, for example: Select * from tblOrders, and use that query as the recordsource in order to get the lookup filters.
HOWEVER, I found a more flexible approach as well. I create passthrough queries to SQL/Server and use that as my recordsource. Then, in code, I set the SQL of the passthrough queries like this:
Currentdb.QueryDefs("qpstOrders").SQL="Select * from Orders where OrderID =" & Me.OrderID
In the current event of my subform, I change the query on the fly to pass the appropriate record -- or it can just be a more generic query. The lookup filters work fine this way and the interaction with SQL/Server is lightning fast.
Open the database that you want to optimize.
Click File > Options to open the Access Options dialog box.
In the left pane of the Access Options dialog box, click Current Database.
In the right pane, under Filter lookup options, mark "ODBC Fields" check box.

How can I stop SQL Server Management Studio replacing 'SELECT *' with the column list?

SQL Server Mgmt Studio is driving me crazy.
If I create a view and SELECT '*' from a table, it's all OK and I can save the view.
Looking at the SQL for the view (eg.by scripting a CREATE) reveals that the 'SELECT *' really is saved to the view's SQL.
But as soon as I reopen the view using the GUI (right click > modify), SELECT * is replaced with a column list of all the columns in the table.
How can I stop Management Studio from doing this ? I want my 'SELECT *' to remain just that.
Perhaps it's just the difficulty of googling 'SELECT *' that prevented me from finding anything remotely relevant to this (i did put it in double quotes).
Please, I am highly experienced in Transact-SQL, so please DON'T give me a lecture on why I shouldn't be using SELECT *. I know all the pros and cons and I do use it at times. It's a language feature, and like all language features can be used for good or evil (I emphatically do NOT agree that it is never appropriate to use it).
Edit: I'm giving Marc the answer, since it seems it is not possible to turn this behaviour off. Problem is considered closed. I note that Enterprise Manager did no similar thing.
The workaround is to either edit SQL as text, or go to a product other than Managment Studio. Or constantly edit out the column list and replace the * every time you edit a view. Sigh.
When SQL Server Mgmt Studio creates a view, I assume they're expanding the * to the complete list of columns that are present in the underlying table(s) at that particular time exactly for this reason: what if one of the underlying tables changes? Do you want the new columns to just simply show up in every view that references that table?? Seriously???
I think Microsoft tries to impmenent the "element of least surprise" here - your view will contain those columns that are present at the time the view gets created - and it stays that way, unless you explicitly and knowingly change that.
I for one wouldn't want to have my views suddenly having more columns than before, when an underlying table changes..... do you??
And I don't think there's any setting in Mgmt Studio to turn this behavior off, sorry.
Don't use the GUI editor.
Instead use the T-SQL editor. You get this by selecting "Script View As" -> "ALTER to" -> "New Query Window" from the right-click menu.
Try either of these: they are alternatives to using the GUI and can be setup as snippets with keyboard shortcuts:
select view_definition
from information_schema.views
where table_name = 'viewname'
or
exec sp_helptext 'viewname'
The results will retain the "select *". (Tested)

Resources