Hi,I have to prepare an ER diagram for the objects in my SQL Serverdatabase. I have used the option "DIAGRAMS" in EnterPrise Manager ofSQL Server 2000. It is creating the diagram for the selected tables(but the diagram contains only the table which i have selected. It isnot displaying its depended tables). But i am not able to export it toany of the flat file like MS WORD or paint. I want this diagram to beuploaded to one Flat file and send to my customer for his reference.Could anyone suggest me how to create the ER Diagram for the SQL 2000database and export it to a flat file.Thanks for your help in advance.-Rao
passing serialised objects to a stored procedure for the purpose of data inserts. I see this as being a way to handle multiple row inserts efficiently.
However, in my limited use of XML data I am not so sure how to link the data when I have a dependency on another "object" within the serialised XML.
Below is a code snippet showing what I have so far.
The first insert statement works fine - but how to retrieve the identifier created by the DB - I want to use an SQL statement that finds the record in the table based on the XML representation (of the PluginInfo), allowing me to insert the ConfigurationInfo with the correct reference to the PluginInfo
DECLARE @Config NVARCHAR(MAX) DECLARE @Handle AS INT DECLARE @TransactionCount AS INT SELECT @Config = ' <ConfigurationDirectory > <ConfigurationInfo groupKey="Notifications" sectionKey="App.Customization.PluginInfo"
I will have a group of developers creating objects in a database. Currently they all create them with the SA account. I would like to have them mapped to the dbo or some method that when they create objects all objects are dbo.object name and not h1fed99.object name. Is there a good methor or practice to handle this
My website host allows me to create DB and DB users from its control panel and then I am able to use SQL server Management studio to Manage My DB. Therefore I create My DB (TBC20) and create a user for it(Tony) from Host Panel. When I want to Export My Local copy DB data to the remote DB using Import/Export wizard and set the It won’t Generate any DB objects. Even When I use aspnet_regsql Command I encounter Following error: SQL error number is 262 and the SqlException message is: CREATE DATABASE permiss ion denied in database 'master'. Creating the TBC20 database... ------------------------------------------------------ When I View permissions in Database properties window No Permission is Grant for user: Tony. Only some permission Grant for Grantor: dbo. When I check Boxes to Grant Permission for user Tony None of permissions will be grant to this user. How could I allow this user ti take ownership of DB and create DB objects
Hi, can we use sqlcmd.exe (successsor to osql) to run sql scripts against a compact edition database? Would like to use the output from Visual Studio Team Edition for Software Professionals to build the database structure on compact edition database.
Hi All, I have a SQL script which has creation of some table variables. When I run this query in Query Analyzer, I get proper results. But, when I use the same script to execute from VB Script, it is not running at all. I tried a simple select statement which works fine; but with the one I want to run, it fails to run. I am trying to print the SQL script from VB script, and it appears to be fine. I think the creation of DB objects is where it is getting stuck. Any help here please??
Below is the SQL Script.
Code Block DECLARE @COMPSINGRP TABLE (NAME VARCHAR(100)) INSERT INTO @COMPSINGRP SELECT NAME FROM COMPUTER WHERE IDCOMPUTER IN (SELECT INSTANCEID FROM [FN_COMPUTERSINGROUPLIKENAME] ('UBS: APPLICATIONS - DEALAXIS') ) DECLARE @COMPRESTARTS TABLE (NAME VARCHAR(100)) INSERT INTO @COMPRESTARTS SELECT COMPUTER FROM ( SELECT C.Name AS COMPUTER, --- FIRST COLUMN (SELECT AC.Description FROM Computer CC INNER JOIN [fn_ComputersInGroupLikeName] ('UBS: Applications - DealAxis') CCG ON CC.idComputer = CCG.InstanceID INNER JOIN Alert AC ON CCG.InstanceID = AC.idComputer WHERE (AC.Description Like '%down on a scheduled maintenance%') AND CC.Name = C.Name AND (CONVERT(NVARCHAR(12),A.TimeOfLastEvent,111) = CONVERT(NVARCHAR(12),GETDATE(),111) )) AS DOWN_DESCRIPTION, --- SECOND COLUMN (SELECT AC.Description FROM Computer CC INNER JOIN [fn_ComputersInGroupLikeName] ('UBS: Applications - DealAxis') CCG ON CC.idComputer = CCG.InstanceID INNER JOIN Alert AC ON CCG.InstanceID = AC.idComputer WHERE (AC.Description Like '%successfully up now after a scheduled reboot%' ) AND CC.Name = C.Name AND (CONVERT(NVARCHAR(12),A.TimeOfLastEvent,111) = CONVERT(NVARCHAR(12),GETDATE(),111) ) ) AS UP_DESCRIPTION --- THIRD COLUMN FROM Computer C INNER JOIN [fn_ComputersInGroupLikeName] ('UBS: Applications - DealAxis') CG ON C.idComputer = CG.InstanceID INNER JOIN Alert A ON CG.InstanceID = A.idComputer WHERE (CONVERT (NVARCHAR(12),A.TimeOfLastEvent,111) = CONVERT(NVARCHAR(12),GETDATE(),111) ) --ORDER BY C.NAME ) AS RESTARTS DECLARE @NOCLUE TABLE (NAME VARCHAR(100)) SELECT 'The Server '+ NAME+' did not have any restart information. Please Check.' FROM @COMPSINGRP WHERE NAME NOT IN (SELECT NAME FROM @COMPRESTARTS)
Any help or suggestion would help me out. Thanks a lot.
How to SQL server save information about create/drop objects action. How can I get this? Example for, a lot of objects(sp) in my database has been dropped, how I know who was dropped them (user login & time)?
I just upgraded our existing 6.5 installation with the new SQL server 7.0. I can't get any of the existing stored procedures which I imported from 6.5 into 7.0 to allow me to edit them. I do all of my design from Visual InterDev and the SQL Server 6.5 version would allow me to create and edit stored procedures. It would also allow me to create/design new tables.
With SQL Server 7.0 I do not have an option to edit or create any of these items. I have created a new login, assigned it a password, given it admin rights/roles and I am still unable to remotely create these items. What am I doing wrong?
MySql has a statement like: SHOW CREATE TABLE tablename;
that returns the precise CREATE TABLE statement for the specified tablename.
Sql Management Studio also allows scripting Create Statement for any object by right-clicking it. But I want to do this programatically, and fetch CREATE statements for Tables, Procedures & Views.
How can I retrive CREATE statements for Database objects progrmatically in Sql Server???
Is there a way to give someone the right to create only views and no other objects in a database? Currently I have given the individual ddladmin database rose, but would rather be more restrictive?
I use SQL code snippet to attach the CLR assembly (dll) to the SQL Server Express
CREATE ASSEMBLY [DatabaseAndImages] AUTHORIZATION [dbo] FROM 'C:CLR_File.dll' WITH PERMISSION_SET = SAFE
That file content CRL Codes for 10 Stored Procedures & 3 UDT & 5 Functions & 6 Triggers As you can see it's content large amount of DB objects !!
My Question is .. Is there any simple way can I use it to extract or automatic create all that Objects in the Database without use separate SQL Statement for each one ??
By Example , I will use this SQL statement to create the sp_AddImage that already located inside the CLR dll file
CREATE PROCEDURE [dbo].[sp_AddImage] @ImageID [uniqueidentifier], @ImageFileName [nvarchar](max), @Image [varbinary](max) WITH EXECUTE AS CALLER AS EXTERNAL NAME [DatabaseAndImages].[StoredProcedures].[sp_AddImage]
But as you know .. I have many objects .. and I am in development phase and I will do change to that object many time and also may I will add much more €¦
I thing it's not good to write SQL Statement for each object and do changes every time when I change the object definition
Is there any one line of SQL statement can I use it to automatically create and extract all the objects inside the assembly ?? Or is there any way to do that Issue by simple operation ??
We are in the process of trying to automate our production releases (what a concept ;-)
The database is SQL server 2005 All objects are being stored in VSS Using Nant and Cruise Control for the actual migrations. I have two directories - Create (for a brandnew database) and Change (db object changes)
In my 'Change' script, I do the following -
1 - Take backup of database 2 - Migrate objects from 'change' directory to production 3 - Script out all objects of database and save in the 'Create' directory
For the #3, I was hoping I could create an SSIS package that would script out all database objects and save them on the VSS server.
I'm new to SSIS and want to verify it's something that can be done before I start down that path. If anyone has any examples or references, it would be much appreciated.
I create a logon trigger on a sql server 2008 r2 instance,the trigger is very simple,like this:
CREATE TRIGGER tg_login ON ALL SERVER FOR LOGON AS IF ORIGINAL_LOGIN() IN('sa') AND HOST_NAME()='TestHost1'
[Code] ...
I use master.dbo.LoginRecord table to record the bad logon. When the trigger is working ,latches produced sometimes,wait type is PAGELATCH_UP and wait resource is 2:1:3. At this time, a large number of logon failed ,error message is "Logon failed for login 'login name' due to trigger execution."
I think logon trigger create internal temporary objects maybe,it is right?
This question is for Bill directly. Hi Bill, I have lots of experience with RS, implementing the beta in a production environment, I was so impressed. Currently my company uses Cognos for financial reporting, and I am hoping to replace this with RS and MSAS. I have little knowledge of MDX, so I have been using your various series of articles to get up to speed. However, I don't get the article Mastering OLAP Reporting: Cascading Prompts. I fully understand how to build the prompts, but there seems to be a step missing in the article. You never replace the hardcoded where clause in the base dataset, and I can't seem to work out how to pass the parameter from the cascading prompts to the report. Maybe I'm being stupid, but the article doesn't seem to tell us how to do that.
I would like to set up a prompt / filter as part of the model that carries through to the report builder. I have a query where I would like to force a prompt on the user as part of any report they create. Ideally, I would like to have it default as well.
I noticed that there is a prompt attribute in model designer. When I go to add the filter attribute in model designer, I get the same dialog box I get in the report builder - except it does not have the prompt as an option. Is there a way to accomplish this?
I have a request to hide certain parameters in a report based on the current user logged into our web based report viewer using the ReportViewer control fo asp.net.
I am doing the standard stuff required to display the report as shown below.
Code Snippet rptViewer.ServerReport.ReportServerUrl = new Uri("http://172.17.144.26/ReportServer"); // new Uri(MINETSecurity.WebSettings.WebServerPath, UriKind.Absolute); rptViewer.ServerReport.ReportPath = ReportName; rptViewer.ServerReport.DisplayName = "Report1"; rptViewer.ServerReport.ReportServerCredentials = new CustomReportCredentials("myUsername", "myPassword", "myDomain");
Now that i have loaded the report into the viewer i illiterate through the report parameters looking for the ones which the specified user should not see as show below.
Code Snippet ReportParameterInfoCollection MyReportParams = rptViewer.ServerReport.GetParameters(); foreach (ReportParameterInfo MyParameter in MyReportParams) { // returns a value from a custom class which is a predefined value for this user based on the current user logged into the website string Value = CustomParameterValues.ToString(GlobalUserSettings.CurrentUser.CustomValueList); if(Value != "") MyParameter.PromptUser = false; }
Here is where the promblem lies, when i try to set the value of PromptUser i get the following compiler error.
Property or indexer 'Microsoft.Reporting.WebForms.ReportParameterInfo.PromptUser' cannot be assigned to -- its is read only
Is there anything i can do to set certain parameters invisible to the user and set there value myself. I know i could create 2 seperate reports and set the PromptUser value in the designer but i dont really want to be duplicating reports just to hide or show parameters.
I have tried using the SetParameters method of the ReportViewer component to pass the value of the parameters that should be hidden and even set the visible property to false, but it dosn't seem to work.
We want to have one prompt (parameter) to set a point in time, so we can use this parameter as filter in other elements. e.g. We have a point in time prompt, that we can set and use to filter by examples illness records and availability record (by the same (one) prompt)
Suppose I have two prompts, say A and B. These two prompts are populated by using database queries. B is dependent on A. These prompts are multiselect.
I have noticed that it is not possible to deselect them once a value(s) are selected. If I deselect all in A. They automatically get selected again.
They work fine as long as some value selected. It is possible however to deselect all in B.
I have a little application that I have designed where I need to be able to execute create table and create function comands against the database. It seems that it does not like my sql file. Does anyone know of a different method of doing this?
Error message Line 2: Incorrect syntax near 'GO'. Line 4: Incorrect syntax near 'GO'. Line 8: Incorrect syntax near 'GO'. 'CREATE FUNCTION' must be the first statement in a query batch. Must declare the variable '@usb'. Must declare the variable '@usb'. Must declare the variable '@i'. A RETURN statement with a return value cannot be used in this context. Line 89: Incorrect syntax near 'GO'. Line 91: Incorrect syntax near 'GO'. Line 94: Incorrect syntax near 'GO'.
Protected Sub Install() Dim err As String = "" While err.Length < 1 ' Dim your StreamReader Dim TextFileStream As System.IO.TextReader 'Load the textfile into the stream TextFileStream = System.IO.File.OpenText(Request.PhysicalApplicationPath & "Scripts .sql") 'Read to the end of the file into a String variable. executesql(TextFileStream.ReadToEnd, err)
err = "Susscessful" End While If err = "Susscessful" Then Response.Redirect("Default.aspx") Else Me.lblError.Text = err End If End Sub Private Function executesql(ByVal s As String, ByRef err As String) As Boolean Try Dim conn As New Data.SqlClient.SqlConnection(GenConString()) Dim cmd As New Data.SqlClient.SqlCommand(s, conn) conn.Open() cmd.ExecuteNonQuery() conn.Close() Return True Catch ex As Exception err = ex.Message.ToString Return False End Try End Function
Example sql file SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MyFunc]') and xtype in (N'FN', N'IF', N'TF')) drop function [dbo].[MyFunc] GO CREATE FUNCTION [dbo].[MyFunc] ( -- Add the parameters for the function here
) RETURNS varchar(1000) AS BEGIN -- Declare the return variable here DECLARE @Result varchar(1000) -- Add the T-SQL statements to compute the return value here -- Do something here -- Return the result of the function RETURN @Result END GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
The following command works ok: create default [Zero] as 0
but the command: if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Zero]') and OBJECTPROPERTY(id, N'IsDefault') = 1) create default [Zero] as 0
returns: Server: Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'default'.
Env: Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
I have a requirement to create a dynamic SQL Command in an OLE DB Source due to the fact that I need to read data from another database based on a date range. For example, the SQL command would look like
SELECT * FROM Table1 WHERE DateField BETWEEN '17/03/2008' and '21/03/2008'
and I need to change the dates - '17/03/2008' and '21/03/2008' to different dates when the package is deployed in production, how do I do that ?
I am running a report which takes a long time to render. It has 500K rows in it that need to be summed and grouped. After 5 minutes IE prompts for a password. I set the report time out to 15 min just to see if it would make a difference. I even set the IIS timeout to an to 15 min as well.
I know that its bad to run a report this big, but I'm just curious why it prompts for a password. In case a user runs the report. Report uses dates so its possible they could go way back and not realize its 500K rows. I am assuming it is an IE issue with the browser and found a registry edit, but I don't really want to edit registries on my users' computers.
hye everyone, i have Problem for the prompts will display at the top of the report in the browser :
1)go to the report manager on computer and set the set the Prompt User check boxes to checked. --> auto check
2)select the report viewer control, if you are using it, and set the Parameters property to false. --> the eror mesage will be display " The ' field " parameter is missing value. "
what should i do...any idea thanks in advance thank you very much
This script will read the contents of a DB backup file, and generate a restore command.
Set the value of parameter @backup_path to point to the backup file, run in Query Analyzer, cut/paste the output into another Query Analyzer window, modify as necessary, and run.
This is just a barebones script to demo how this can be done. Modify as necessary to meet your own needs.
Works in SQL 2000 and 7.0. May work in SQL 2005, but it is not tested.
-- Create Restore Database Command from DB Backup File
select [--Restore--]= case when a.Seq = 1 then @cr+ @cr+'restore database '+c.DatabaseName+ @cr+'from disk ='+@cr+@tab+''''+ @backup_path+''''+@cr+'with'+@cr else '' end+ @tab+'move '''+a.LogicalName+ '''to '''+a.PhysicalName+''' ,'+ case when a.Seq = b.Seq then @cr+@tab+'replace, stats = 5 , recovery' else '' end from #filelist a cross join ( select Seq = max(b1.Seq) from #filelist b1 ) b cross join ( select DatabaseName = max(c1.DatabaseName) from #header c1 ) c order by a.Seq go drop table #header drop table #filelist
I dont know something weired happened on our MSSQL server today. We are able to connect to any Databases from Enterprise Manager from a Remote server.
Once we logged in and connected to a database on my database server, it keep prompting for the user id and password as we browsing through different tables in that database?
(Right click on the table then select Open Table -> Return all rows -> and it prompts for password )
Now when we enter password the contents of Table are displayed and now when we try to see contents of another table in the database it again prompts for password.
Any Idea whats wrong? How this can be resolved as it was not happening before .. :(
Any command which will make create script for my entire database including all sp's , tables, functions..i dont want to backup the db ..i want to create scripts for creating an entire database schema (only the structure and not data)
I have installed SQL Express 2005 and I want to create a new DB using sqlcmd.
I am running a command like: sqlcmd -i file.ini (I am logged like Administrator of PC)
the content of the file.ini is:
-- Get the SQL Server data path DECLARE @data_path nvarchar(256);
SET @data_path = 'c:Program FilesMyTestdatabase'
-- execute the CREATE DATABASE statement EXECUTE ('CREATE DATABASE DataCollection ON ( NAME = DC_dat, FILENAME = '''+ @data_path + 'DC.mdf'', SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5 ) LOG ON ( NAME = DC_log, FILENAME = '''+ @data_path + 'DClog.ldf'', SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB )' ) ; GO
I obtain this error:
Msg 1802, Level 16, State 4, Server TESTQ5SQLEXPRESS, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors. Msg 5123, Level 16, State 1, Server TESTQ5SQLEXPRESS, Line 1 CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'c:Program FilesMyTestdatabaseDC.mdf'.
If I change the security of directory database (I add "modify" permission to Users windows group) the error disappear.
I am logged like Administrator... why is it necessary to change directory permission?