SELECT DISTINCT schema_name(fk_tab.schema_id) + ‘.’ + fk_tab.name as foreign_table, ‘>-‘ as rel, schema_name(pk_tab.schema_id) + ‘.’ + pk_tab.name as primary_table FROM sys.foreign_keys fk INNER JOIN sys.tables fk_tab on fk_tab.object_id = fk.parent_object_id INNER JOIN sys.tables pk_tab on pk_tab.object_id = fk.referenced_object_id WHERE pk_tab.[name] = ‘Your table’ — enter table name here — and schema_name(pk_tab.schema_id) = ‘Your table schema […]
Tag: data
How to remove searching, filtering, ordering and info from Asp.NET MVC Datatable
var table = $(“#datatable”).DataTable({ “paging”: false, “ordering”: false, “searching”: false, “info”: false });
How to add Output Parameter to SqlDataSource
<asp:Parameter Name=”NewID” Direction=”Output” Type=”Int32″ DefaultValue=”0″ /> Here is a more detailed example in use: <asp:sqlDataSource ID=”EmployeeDetailsSqlDataSource” SelectCommand=”SELECT EmployeeID, LastName, FirstName FROM Employees WHERE EmployeeID = @EmpID” InsertCommand=”INSERT INTO Employees(LastName, FirstName) VALUES (@LastName, @FirstName); SELECT @EmpID = SCOPE_IDENTITY()” UpdateCommand=”UPDATE Employees SET LastName=@LastName, FirstName=@FirstName WHERE EmployeeID=@EmployeeID” DeleteCommand=”DELETE Employees WHERE EmployeeID=@EmployeeID” ConnectionString=”<%$ ConnectionStrings:NorthwindConnection %>” OnInserted=”EmployeeDetailsSqlDataSource_OnInserted” RunAt=”server”> <SelectParameters> <asp:Parameter […]
How to get stored procedure parameters details in SQL
select ‘Parameter_name’ = name, ‘Type’ = type_name(user_type_id), ‘Length’ = max_length, ‘Prec’ = case when type_name(system_type_id) = ‘uniqueidentifier’ then precision else OdbcPrec(system_type_id, max_length, precision) end, ‘Scale’ = OdbcScale(system_type_id, scale), ‘Param_order’ = parameter_id, ‘Collation’ = convert(sysname, case when system_type_id in (35, 99, 167, 175, 231, 239) then ServerProperty(‘collation’) end) from sys.parameters where object_id = object_id(‘MySchema.MyProcedureName’)
How to check column data types of a table in SQL
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=’your_table_name’;
Slice() method in Javascript
The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified. Syntax: slice() slice(start) slice(start, end) Parameters start Optional Zero-based index at which to start extraction. A negative index can be used, indicating […]
Default Values for Data Types in C#
Table below shows the default value for the different predefined data types. Type Default sbyte, byte, short, ushort, int, uint, long, ulong 0 char ‘\x0000’ float 0.0f double 0.0d decimal 0.0m bool false object null string null As you can see, for the integral value types, the default value is zero. The default value for […]
Passing parameters to JavaScript files
You can assign an id to the <script> element and passing the arguments as data-* attributes. The resulting <script> tag would look something like this:
Default Settings for Datatable in MVC
When working with DataTables over multiple pages it is often useful to set the initialisation defaults to common values (for example you might want to set dom to a common value so all tables get the same layout). This can be done using the $.fn.dataTable.defaults object. This object will take all of the same parameters as the DataTables initialisation […]
Search text in all tables in SQL Server
Please note that with a little bit changing you can also use this query as a stored procedure.